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");
}
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));
#ifdef HAVE_AUDIT
_cleanup_free_ char *p = NULL;
+ const char *msg;
int audit_fd;
audit_fd = get_audit_fd();
p = unit_name_to_prefix_and_instance(u->id);
if (!p) {
- log_error_unit(u->id,
- "Failed to allocate unit name for audit message: %s", strerror(ENOMEM));
+ log_oom();
return;
}
- if (audit_log_user_comm_message(audit_fd, type, "", p, NULL, NULL, NULL, success) < 0) {
- if (errno == EPERM) {
+ msg = strappenda("unit=", p);
+
+ if (audit_log_user_comm_message(audit_fd, type, msg, "systemd", NULL, NULL, NULL, success) < 0) {
+ if (errno == EPERM)
/* We aren't allowed to send audit messages?
* Then let's not retry again. */
close_audit_fd();
- } else
+ else
log_warning("Failed to send audit message: %m");
}
#endif