if (arg_no_pager)
return;
- pager_open();
+ pager_open(false);
}
static void ask_password_agent_open_if_enabled(void) {
if (r < 0)
return r;
- dbus_message_iter_init(reply, &iter);
+ if (!dbus_message_iter_init(reply, &iter)) {
+ log_error("Failed to initialize iterator.");
+ return -EIO;
+ }
+
r = bus_parse_strv_iter(&iter, &list);
if (r < 0) {
log_error("Failed to parse value list.");
if (i->id && arg_transport != TRANSPORT_SSH) {
printf("\n");
- if(arg_scope == UNIT_FILE_SYSTEM)
- show_journal_by_unit(stdout,
- i->id,
- arg_output,
- 0,
- i->inactive_exit_timestamp_monotonic,
- arg_lines,
- flags);
- else
- show_journal_by_user_unit(stdout,
- i->id,
- arg_output,
- 0,
- i->inactive_exit_timestamp_monotonic,
- arg_lines,
- getuid(),
- flags);
+ show_journal_by_unit(stdout,
+ i->id,
+ arg_output,
+ 0,
+ i->inactive_exit_timestamp_monotonic,
+ arg_lines,
+ getuid(),
+ flags,
+ arg_scope == UNIT_FILE_SYSTEM);
}
if (i->need_daemon_reload)
DBusMessage _cleanup_dbus_message_unref_ *reply = NULL;
bool enabled;
char **name;
+ char *n;
dbus_error_init(&error);
STRV_FOREACH(name, args+1) {
UnitFileState state;
- state = unit_file_get_state(arg_scope, arg_root, *name);
+ n = unit_name_mangle(*name);
+ if (!n)
+ return log_oom();
+
+ state = unit_file_get_state(arg_scope, arg_root, n);
+
+ free(n);
+
if (state < 0)
return state;
STRV_FOREACH(name, args+1) {
const char *s;
+ n = unit_name_mangle(*name);
+ if (!n)
+ return log_oom();
+
r = bus_method_call_with_reply (
bus,
"org.freedesktop.systemd1",
"GetUnitFileState",
&reply,
NULL,
- DBUS_TYPE_STRING, name,
+ DBUS_TYPE_STRING, &n,
DBUS_TYPE_INVALID);
+
+ free(n);
+
if (r)
return r;
}
static int talk_initctl(void) {
- struct init_request request;
- int r, fd;
+ struct init_request request = {0};
+ int r;
+ int _cleanup_close_ fd = -1;
char rl;
- if (!(rl = action_to_runlevel()))
+ rl = action_to_runlevel();
+ if (!rl)
return 0;
- zero(request);
request.magic = INIT_MAGIC;
request.sleeptime = 0;
request.cmd = INIT_CMD_RUNLVL;
request.runlevel = rl;
- if ((fd = open(INIT_FIFO, O_WRONLY|O_NDELAY|O_CLOEXEC|O_NOCTTY)) < 0) {
-
+ fd = open(INIT_FIFO, O_WRONLY|O_NDELAY|O_CLOEXEC|O_NOCTTY);
+ if (fd < 0) {
if (errno == ENOENT)
return 0;
errno = 0;
r = loop_write(fd, &request, sizeof(request), false) != sizeof(request);
- close_nointr_nofail(fd);
-
- if (r < 0) {
+ if (r) {
log_error("Failed to write to "INIT_FIFO": %m");
return errno ? -errno : -EIO;
}
{ "condreload", MORE, 2, start_unit }, /* For compatibility with ALTLinux */
{ "condrestart", MORE, 2, start_unit }, /* For compatibility with RH */
{ "isolate", EQUAL, 2, start_unit },
- { "set-cgroup", MORE, 2, set_cgroup },
- { "unset-cgroup", MORE, 2, set_cgroup },
- { "get-cgroup-attr", MORE, 2, get_cgroup_attr },
- { "set-cgroup-attr", MORE, 2, set_cgroup_attr },
- { "unset-cgroup-attr", MORE, 2, set_cgroup },
+ { "set-cgroup", MORE, 3, set_cgroup },
+ { "unset-cgroup", MORE, 3, set_cgroup },
+ { "get-cgroup-attr", MORE, 3, get_cgroup_attr },
+ { "set-cgroup-attr", MORE, 4, set_cgroup_attr },
+ { "unset-cgroup-attr", MORE, 3, set_cgroup },
{ "kill", MORE, 2, kill_unit },
{ "is-active", MORE, 2, check_unit_active },
{ "check", MORE, 2, check_unit_active },