[systemd-devel] [PATCH] manager: Ensure user's systemd runtime directory exists.
Zbigniew Jędrzejewski-Szmek
zbyszek at in.waw.pl
Sun Nov 2 10:18:59 PST 2014
On Sun, Nov 02, 2014 at 02:04:20PM +0000, Colin Guthrie wrote:
> This mirrors code in dbus.c when creating the private socket and
> avoids error messages like:
>
> systemd[1353]: bind(/run/user/603/systemd/notify) failed: No such file or directory
> systemd[1353]: Failed to fully start up daemon: No such file or directory
Seems reasonable. But why not move the mkdir_parent_label() to the shared
code path? Even if the dir is created elsewhere, it seems cleaner to ensure
here that it is available.
Zbyszek
> ---
> src/core/manager.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/src/core/manager.c b/src/core/manager.c
> index ed7fdc7..2c77757 100644
> --- a/src/core/manager.c
> +++ b/src/core/manager.c
> @@ -662,9 +662,11 @@ static int manager_setup_notify(Manager *m) {
> return -errno;
> }
>
> - if (m->running_as == SYSTEMD_SYSTEM)
> + if (m->running_as == SYSTEMD_SYSTEM) {
> m->notify_socket = strdup("/run/systemd/notify");
> - else {
> + if (!m->notify_socket)
> + return log_oom();
> + } else {
> const char *e;
>
> e = getenv("XDG_RUNTIME_DIR");
> @@ -674,9 +676,11 @@ static int manager_setup_notify(Manager *m) {
> }
>
> m->notify_socket = strappend(e, "/systemd/notify");
> + if (!m->notify_socket)
> + return log_oom();
> +
> + mkdir_parents_label(m->notify_socket, 0755);
> }
> - if (!m->notify_socket)
> - return log_oom();
>
> strncpy(sa.un.sun_path, m->notify_socket, sizeof(sa.un.sun_path)-1);
> r = bind(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path));
> --
> 2.1.2
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
More information about the systemd-devel
mailing list