mirror of
https://github.com/systemd/systemd.git
synced 2024-11-06 08:26:52 +03:00
core: reuse manager_get_runtime_prefix() at more places
This commit is contained in:
parent
e4bb56c7a9
commit
92dd7c4965
@ -676,6 +676,7 @@ static int manager_setup_notify(Manager *m) {
|
|||||||
.sa.sa_family = AF_UNIX,
|
.sa.sa_family = AF_UNIX,
|
||||||
};
|
};
|
||||||
static const int one = 1;
|
static const int one = 1;
|
||||||
|
const char *e;
|
||||||
|
|
||||||
/* First free all secondary fields */
|
/* First free all secondary fields */
|
||||||
m->notify_socket = mfree(m->notify_socket);
|
m->notify_socket = mfree(m->notify_socket);
|
||||||
@ -687,19 +688,13 @@ static int manager_setup_notify(Manager *m) {
|
|||||||
|
|
||||||
fd_inc_rcvbuf(fd, NOTIFY_RCVBUF_SIZE);
|
fd_inc_rcvbuf(fd, NOTIFY_RCVBUF_SIZE);
|
||||||
|
|
||||||
if (MANAGER_IS_SYSTEM(m))
|
e = manager_get_runtime_prefix(m);
|
||||||
m->notify_socket = strdup("/run/systemd/notify");
|
if (!e) {
|
||||||
else {
|
log_error("Failed to determine runtime prefix.");
|
||||||
const char *e;
|
return -EINVAL;
|
||||||
|
|
||||||
e = getenv("XDG_RUNTIME_DIR");
|
|
||||||
if (!e) {
|
|
||||||
log_error_errno(errno, "XDG_RUNTIME_DIR is not set: %m");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
m->notify_socket = strappend(e, "/systemd/notify");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m->notify_socket = strappend(e, "/systemd/notify");
|
||||||
if (!m->notify_socket)
|
if (!m->notify_socket)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
|
@ -140,14 +140,9 @@ static int specifier_runtime(char specifier, void *data, void *userdata, char **
|
|||||||
|
|
||||||
assert(u);
|
assert(u);
|
||||||
|
|
||||||
if (MANAGER_IS_SYSTEM(u->manager))
|
e = manager_get_runtime_prefix(u->manager);
|
||||||
e = "/run";
|
if (!e)
|
||||||
else {
|
return -EOPNOTSUPP;
|
||||||
e = getenv("XDG_RUNTIME_DIR");
|
|
||||||
if (!e)
|
|
||||||
return -EOPNOTSUPP;
|
|
||||||
}
|
|
||||||
|
|
||||||
n = strdup(e);
|
n = strdup(e);
|
||||||
if (!n)
|
if (!n)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
Loading…
Reference in New Issue
Block a user