#include <fcntl.h>
#include <sys/socket.h>
#include <sys/stat.h>
+#include <stddef.h>
#include <dbus/dbus.h>
#include "exit-status.h"
#include "bus-errors.h"
#include "build.h"
+#include "unit-name.h"
static const char *arg_type = NULL;
static char **arg_property = NULL;
streq(args[0], "stop") ? "StopUnit" :
streq(args[0], "reload") ? "ReloadUnit" :
streq(args[0], "restart") ? "RestartUnit" :
- streq(args[0], "try-restart") ? "TryRestartUnit" :
+ streq(args[0], "try-restart") ||
+ streq(args[0], "condrestart") ? "TryRestartUnit" :
streq(args[0], "reload-or-restart") ? "ReloadOrRestartUnit" :
streq(args[0], "reload-or-try-restart") ||
- streq(args[0], "force-reload") ||
- streq(args[0], "condrestart") ? "ReloadOrTryRestartUnit" :
+ streq(args[0], "force-reload") ? "ReloadOrTryRestartUnit" :
"StartUnit";
mode =
pid_t control_pid;
const char *status_text;
bool running:1;
+#ifdef HAVE_SYSV_COMPAT
bool is_sysv:1;
+#endif
usec_t start_timestamp;
usec_t exit_timestamp;
printf("status=%i", p->status);
+#ifdef HAVE_SYSV_COMPAT
if ((c = exit_status_to_string(p->status, i->is_sysv ? EXIT_STATUS_LSB : EXIT_STATUS_SYSTEMD)))
+#else
+ if ((c = exit_status_to_string(p->status, EXIT_STATUS_SYSTEMD)))
+#endif
printf("/%s", c);
} else
printf("status=%i", i->exit_status);
+#ifdef HAVE_SYSV_COMPAT
if ((c = exit_status_to_string(i->exit_status, i->is_sysv ? EXIT_STATUS_LSB : EXIT_STATUS_SYSTEMD)))
+#else
+ if ((c = exit_status_to_string(i->exit_status, EXIT_STATUS_SYSTEMD)))
+#endif
printf("/%s", c);
} else
i->description = s;
else if (streq(name, "FragmentPath"))
i->path = s;
+#ifdef HAVE_SYSV_COMPAT
else if (streq(name, "SysVPath")) {
i->is_sysv = true;
i->path = s;
- } else if (streq(name, "DefaultControlGroup"))
+ }
+#endif
+ else if (streq(name, "DefaultControlGroup"))
i->default_control_group = s;
else if (streq(name, "StatusText"))
i->status_text = s;
return 0;
}
+ case DBUS_TYPE_DOUBLE: {
+ double d;
+ dbus_message_iter_get_basic(iter, &d);
+
+ printf("%s=%g\n", name, d);
+ return 0;
+ }
+
case DBUS_TYPE_STRUCT: {
DBusMessageIter sub;
dbus_message_iter_recurse(iter, &sub);
hashmap_free(m);
}
-static bool unit_name_valid(const char *name) {
-
- /* This is a minimal version of unit_name_valid() from
- * unit-name.c */
-
- if (!*name)
- return false;
-
- if (ignore_file(name))
- return false;
-
- return true;
-}
-
static int install_info_add(const char *name) {
InstallInfo *i;
int r;
assert(will_install);
- if (!unit_name_valid(name))
+ if (!unit_name_is_valid_no_type(name)) {
+ log_warning("Unit name %s is not a valid unit name.", name);
return -EINVAL;
+ }
if (hashmap_get(have_installed, name) ||
hashmap_get(will_install, name))
if (!(n = strndup(w, l)))
return -ENOMEM;
- r = install_info_add(n);
- free(n);
-
- if (r < 0)
+ if ((r = install_info_add(n)) < 0) {
+ log_warning("Cannot install unit %s: %s", n, strerror(-r));
+ free(n);
return r;
+ }
+
+ free(n);
}
return 0;
STRV_FOREACH(s, i->aliases) {
- if (!unit_name_valid(*s)) {
+ if (!unit_name_is_valid_no_type(*s)) {
log_error("Invalid name %s.", *s);
r = -EINVAL;
goto finish;
if (streq(verb, "disable"))
rmdir_parents(alias_path, config_path);
}
-
r = 0;
finish:
assert(config_path);
STRV_FOREACH(s, i->wanted_by) {
- if (!unit_name_valid(*s)) {
+ if (!unit_name_is_valid_no_type(*s)) {
log_error("Invalid name %s.", *s);
r = -EINVAL;
goto finish;
}
for (j = 1; j < n; j++)
- if ((r = install_info_add(args[j])) < 0)
+ if ((r = install_info_add(args[j])) < 0) {
+ log_warning("Cannot install unit %s: %s", args[j], strerror(-r));
goto finish;
+ }
while ((i = hashmap_first(will_install))) {
int q;
zero(msghdr);
msghdr.msg_name = &sockaddr;
- msghdr.msg_namelen = sizeof(sa_family_t) + 1 + sizeof("/org/freedesktop/systemd1/shutdownd") - 1;
+ msghdr.msg_namelen = offsetof(struct sockaddr_un, sun_path) + 1 + sizeof("/org/freedesktop/systemd1/shutdownd") - 1;
msghdr.msg_iov = &iovec;
msghdr.msg_iovlen = 1;