systemctl.c   systemctl.c 
skipping to change at line 459 skipping to change at line 459
if (arg_full) { if (arg_full) {
e = ellipsize(id, id_len, 33); e = ellipsize(id, id_len, 33);
if (!e) if (!e)
return log_oom(); return log_oom();
id = e; id = e;
} }
if (circle_len > 0) if (circle_len > 0)
printf("%s%s%s", on_circle, circle ? draw_special_c har(DRAW_BLACK_CIRCLE) : " ", off_circle); printf("%s%s%s ", on_circle, circle ? draw_special_ char(DRAW_BLACK_CIRCLE) : " ", off_circle);
printf("%s%-*s%s %s%-*s%s %s%-*s %-*s%s %-*s", printf("%s%-*s%s %s%-*s%s %s%-*s %-*s%s %-*s",
on_active, id_len, id, off_active, on_active, id_len, id, off_active,
on_loaded, load_len, u->load_state, off_loaded, on_loaded, load_len, u->load_state, off_loaded,
on_active, active_len, u->active_state, on_active, active_len, u->active_state,
sub_len, u->sub_state, off_active, sub_len, u->sub_state, off_active,
job_count ? job_len + 1 : 0, u->job_id ? u->job_type : ""); job_count ? job_len + 1 : 0, u->job_id ? u->job_type : "");
if (desc_len > 0) if (desc_len > 0)
printf("%.*s\n", desc_len, u->description); printf("%.*s\n", desc_len, u->description);
skipping to change at line 620 skipping to change at line 620
if (arg_recursive) { if (arg_recursive) {
_cleanup_strv_free_ char **machines = NULL; _cleanup_strv_free_ char **machines = NULL;
char **i; char **i;
r = sd_get_machine_names(&machines); r = sd_get_machine_names(&machines);
if (r < 0) if (r < 0)
return r; return r;
STRV_FOREACH(i, machines) { STRV_FOREACH(i, machines) {
_cleanup_bus_unref_ sd_bus *container = NULL; _cleanup_bus_close_unref_ sd_bus *container = NULL;
int k; int k;
r = sd_bus_open_system_container(&container, *i); r = sd_bus_open_system_container(&container, *i);
if (r < 0) { if (r < 0) {
log_error("Failed to connect to container % s: %s", *i, strerror(-r)); log_error("Failed to connect to container % s: %s", *i, strerror(-r));
continue; continue;
} }
k = get_unit_list(container, *i, patterns, &unit_in fos, c, &reply); k = get_unit_list(container, *i, patterns, &unit_in fos, c, &reply);
if (k < 0) if (k < 0)
skipping to change at line 1145 skipping to change at line 1145
return 0; return 0;
} }
static usec_t calc_next_elapse(dual_timestamp *nw, dual_timestamp *next) { static usec_t calc_next_elapse(dual_timestamp *nw, dual_timestamp *next) {
usec_t next_elapse; usec_t next_elapse;
assert(nw); assert(nw);
assert(next); assert(next);
if (next->monotonic != (usec_t) -1 && next->monotonic > 0) { if (next->monotonic != USEC_INFINITY && next->monotonic > 0) {
usec_t converted; usec_t converted;
if (next->monotonic > nw->monotonic) if (next->monotonic > nw->monotonic)
converted = nw->realtime + (next->monotonic - nw->m onotonic); converted = nw->realtime + (next->monotonic - nw->m onotonic);
else else
converted = nw->realtime - (nw->monotonic - next->m onotonic); converted = nw->realtime - (nw->monotonic - next->m onotonic);
if (next->realtime != (usec_t) -1 && next->realtime > 0) if (next->realtime != USEC_INFINITY && next->realtime > 0)
next_elapse = MIN(converted, next->realtime); next_elapse = MIN(converted, next->realtime);
else else
next_elapse = converted; next_elapse = converted;
} else } else
next_elapse = next->realtime; next_elapse = next->realtime;
return next_elapse; return next_elapse;
} }
skipping to change at line 1691 skipping to change at line 1691
static int compare_machine_info(const void *a, const void *b) { static int compare_machine_info(const void *a, const void *b) {
const struct machine_info *u = a, *v = b; const struct machine_info *u = a, *v = b;
if (u->is_host != v->is_host) if (u->is_host != v->is_host)
return u->is_host > v->is_host ? -1 : 1; return u->is_host > v->is_host ? -1 : 1;
return strcasecmp(u->name, v->name); return strcasecmp(u->name, v->name);
} }
static int get_machine_properties(sd_bus *bus, struct machine_info *mi) { static int get_machine_properties(sd_bus *bus, struct machine_info *mi) {
_cleanup_bus_unref_ sd_bus *container = NULL; _cleanup_bus_close_unref_ sd_bus *container = NULL;
int r; int r;
assert(mi); assert(mi);
if (!bus) { if (!bus) {
r = sd_bus_open_system_container(&container, mi->name); r = sd_bus_open_system_container(&container, mi->name);
if (r < 0) if (r < 0)
return r; return r;
bus = container; bus = container;
skipping to change at line 3173 skipping to change at line 3173
usec_t inactive_enter_timestamp; usec_t inactive_enter_timestamp;
bool need_daemon_reload; bool need_daemon_reload;
/* Service */ /* Service */
pid_t main_pid; pid_t main_pid;
pid_t control_pid; pid_t control_pid;
const char *status_text; const char *status_text;
const char *pid_file; const char *pid_file;
bool running:1; bool running:1;
int status_errno;
usec_t start_timestamp; usec_t start_timestamp;
usec_t exit_timestamp; usec_t exit_timestamp;
int exit_code, exit_status; int exit_code, exit_status;
usec_t condition_timestamp; usec_t condition_timestamp;
bool condition_result; bool condition_result;
bool failed_condition_trigger; bool failed_condition_trigger;
bool failed_condition_negate; bool failed_condition_negate;
skipping to change at line 3444 skipping to change at line 3445
get_process_comm(i->control_pid, &c); get_process_comm(i->control_pid, &c);
if (c) if (c)
printf(" (%s)", c); printf(" (%s)", c);
} }
printf("\n"); printf("\n");
} }
if (i->status_text) if (i->status_text)
printf(" Status: \"%s\"\n", i->status_text); printf(" Status: \"%s\"\n", i->status_text);
if (i->status_errno > 0)
printf(" Error: %i (%s)\n", i->status_errno, strerror(i-
>status_errno));
if (i->control_group && if (i->control_group &&
(i->main_pid > 0 || i->control_pid > 0 || (i->main_pid > 0 || i->control_pid > 0 ||
((arg_transport != BUS_TRANSPORT_LOCAL && arg_transport != BUS _TRANSPORT_CONTAINER) || cg_is_empty_recursive(SYSTEMD_CGROUP_CONTROLLER, i ->control_group, false) == 0))) { ((arg_transport != BUS_TRANSPORT_LOCAL && arg_transport != BUS _TRANSPORT_CONTAINER) || cg_is_empty_recursive(SYSTEMD_CGROUP_CONTROLLER, i ->control_group, false) == 0))) {
unsigned c; unsigned c;
printf(" CGroup: %s\n", i->control_group); printf(" CGroup: %s\n", i->control_group);
if (arg_transport == BUS_TRANSPORT_LOCAL || arg_transport = = BUS_TRANSPORT_CONTAINER) { if (arg_transport == BUS_TRANSPORT_LOCAL || arg_transport = = BUS_TRANSPORT_CONTAINER) {
unsigned k = 0; unsigned k = 0;
skipping to change at line 3503 skipping to change at line 3506
static void show_unit_help(UnitStatusInfo *i) { static void show_unit_help(UnitStatusInfo *i) {
char **p; char **p;
assert(i); assert(i);
if (!i->documentation) { if (!i->documentation) {
log_info("Documentation for %s not known.", i->id); log_info("Documentation for %s not known.", i->id);
return; return;
} }
STRV_FOREACH(p, i->documentation) { STRV_FOREACH(p, i->documentation)
if (startswith(*p, "man:"))
if (startswith(*p, "man:")) { show_man_page(*p + 4, false);
const char *args[4] = { "man", NULL, NULL, NULL }; else
_cleanup_free_ char *page = NULL, *section = NULL;
char *e = NULL;
pid_t pid;
size_t k;
k = strlen(*p);
if ((*p)[k-1] == ')')
e = strrchr(*p, '(');
if (e) {
page = strndup((*p) + 4, e - *p - 4);
section = strndup(e + 1, *p + k - e - 2);
if (!page || !section) {
log_oom();
return;
}
args[1] = section;
args[2] = page;
} else
args[1] = *p + 4;
pid = fork();
if (pid < 0) {
log_error("Failed to fork: %m");
continue;
}
if (pid == 0) {
/* Child */
execvp(args[0], (char**) args);
log_error("Failed to execute man: %m");
_exit(EXIT_FAILURE);
}
wait_for_terminate(pid, NULL);
} else
log_info("Can't show: %s", *p); log_info("Can't show: %s", *p);
}
} }
static int status_property(const char *name, sd_bus_message *m, UnitStatusI nfo *i, const char *contents) { static int status_property(const char *name, sd_bus_message *m, UnitStatusI nfo *i, const char *contents) {
int r; int r;
assert(name); assert(name);
assert(m); assert(m);
assert(i); assert(i);
switch (contents[0]) { switch (contents[0]) {
skipping to change at line 3664 skipping to change at line 3628
int32_t j; int32_t j;
r = sd_bus_message_read(m, "i", &j); r = sd_bus_message_read(m, "i", &j);
if (r < 0) if (r < 0)
return bus_log_parse_error(r); return bus_log_parse_error(r);
if (streq(name, "ExecMainCode")) if (streq(name, "ExecMainCode"))
i->exit_code = (int) j; i->exit_code = (int) j;
else if (streq(name, "ExecMainStatus")) else if (streq(name, "ExecMainStatus"))
i->exit_status = (int) j; i->exit_status = (int) j;
else if (streq(name, "StatusErrno"))
i->status_errno = (int) j;
break; break;
} }
case SD_BUS_TYPE_UINT64: { case SD_BUS_TYPE_UINT64: {
uint64_t u; uint64_t u;
r = sd_bus_message_read(m, "t", &u); r = sd_bus_message_read(m, "t", &u);
if (r < 0) if (r < 0)
return bus_log_parse_error(r); return bus_log_parse_error(r);
skipping to change at line 4864 skipping to change at line 4830
init = cmdline_init; init = cmdline_init;
} }
if (isempty(init)) if (isempty(init))
init = NULL; init = NULL;
if (init) { if (init) {
const char *root_systemd_path = NULL, *root_init_path = NUL L; const char *root_systemd_path = NULL, *root_init_path = NUL L;
root_systemd_path = strappenda(root, "/" SYSTEMD_BINARY_PAT H); root_systemd_path = strappenda(root, "/" SYSTEMD_BINARY_PAT H);
root_init_path = strappenda3(root, "/", init); root_init_path = strappenda(root, "/", init);
/* If the passed init is actually the same as the /* If the passed init is actually the same as the
* systemd binary, then let's suppress it. */ * systemd binary, then let's suppress it. */
if (files_same(root_init_path, root_systemd_path) > 0) if (files_same(root_init_path, root_systemd_path) > 0)
init = NULL; init = NULL;
} }
log_debug("Switching root - root: %s; init: %s", root, strna(init)) ; log_debug("Switching root - root: %s; init: %s", root, strna(init)) ;
r = sd_bus_call_method( r = sd_bus_call_method(
skipping to change at line 5035 skipping to change at line 5001
if (!endswith(name, ".service")) if (!endswith(name, ".service"))
continue; continue;
if (path_is_absolute(name)) if (path_is_absolute(name))
continue; continue;
STRV_FOREACH(k, paths.unit_path) { STRV_FOREACH(k, paths.unit_path) {
_cleanup_free_ char *path = NULL; _cleanup_free_ char *path = NULL;
if (!isempty(arg_root)) path = path_join(arg_root, *k, name);
asprintf(&path, "%s/%s/%s", arg_root, *k, n if (!path)
ame); return log_oom();
else
asprintf(&path, "%s/%s", *k, name);
if (!path) {
r = log_oom();
goto finish;
}
found_native = access(path, F_OK) >= 0; found_native = access(path, F_OK) >= 0;
if (found_native) if (found_native)
break; break;
} }
if (found_native) if (found_native)
continue; continue;
if (!isempty(arg_root)) p = path_join(arg_root, SYSTEM_SYSVINIT_PATH, name);
asprintf(&p, "%s/" SYSTEM_SYSVINIT_PATH "/%s", arg_ if (!p)
root, name); return log_oom();
else
asprintf(&p, SYSTEM_SYSVINIT_PATH "/%s", name);
if (!p) {
r = log_oom();
goto finish;
}
p[strlen(p) - strlen(".service")] = 0; p[strlen(p) - strlen(".service")] = 0;
found_sysv = access(p, F_OK) >= 0; found_sysv = access(p, F_OK) >= 0;
if (!found_sysv) if (!found_sysv)
continue; continue;
/* Mark this entry, so that we don't try enabling it as nat ive unit */ /* Mark this entry, so that we don't try enabling it as nat ive unit */
args[f] = (char*) ""; args[f] = (char*) "";
log_info("%s is not a native service, redirecting to /sbin/ chkconfig.", name); log_info("%s is not a native service, redirecting to /sbin/ chkconfig.", name);
skipping to change at line 5082 skipping to change at line 5037
if (!isempty(arg_root)) if (!isempty(arg_root))
argv[c++] = q = strappend("--root=", arg_root); argv[c++] = q = strappend("--root=", arg_root);
argv[c++] = basename(p); argv[c++] = basename(p);
argv[c++] = argv[c++] =
streq(verb, "enable") ? "on" : streq(verb, "enable") ? "on" :
streq(verb, "disable") ? "off" : "--level=5"; streq(verb, "disable") ? "off" : "--level=5";
argv[c] = NULL; argv[c] = NULL;
l = strv_join((char**)argv, " "); l = strv_join((char**)argv, " ");
if (!l) { if (!l)
r = log_oom(); return log_oom();
goto finish;
}
log_info("Executing %s", l); log_info("Executing %s", l);
pid = fork(); pid = fork();
if (pid < 0) { if (pid < 0) {
log_error("Failed to fork: %m"); log_error("Failed to fork: %m");
r = -errno; return -errno;
goto finish;
} else if (pid == 0) { } else if (pid == 0) {
/* Child */ /* Child */
execv(argv[0], (char**) argv); execv(argv[0], (char**) argv);
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }
j = wait_for_terminate(pid, &status); j = wait_for_terminate(pid, &status);
if (j < 0) { if (j < 0) {
log_error("Failed to wait for child: %s", strerror( -r)); log_error("Failed to wait for child: %s", strerror( -r));
r = j; return j;
goto finish;
} }
if (status.si_code == CLD_EXITED) { if (status.si_code == CLD_EXITED) {
if (streq(verb, "is-enabled")) { if (streq(verb, "is-enabled")) {
if (status.si_status == 0) { if (status.si_status == 0) {
if (!arg_quiet) if (!arg_quiet)
puts("enabled"); puts("enabled");
r = 1; r = 1;
} else { } else {
if (!arg_quiet) if (!arg_quiet)
puts("disabled"); puts("disabled");
} }
} else if (status.si_status != 0) { } else if (status.si_status != 0)
r = -EINVAL; return -EINVAL;
goto finish; } else
} return -EPROTO;
} else {
r = -EPROTO;
goto finish;
}
} }
finish:
/* Drop all SysV units */ /* Drop all SysV units */
for (f = 0, t = 0; args[f]; f++) { for (f = 0, t = 0; args[f]; f++) {
if (isempty(args[f])) if (isempty(args[f]))
continue; continue;
args[t++] = args[f]; args[t++] = args[f];
} }
args[t] = NULL; args[t] = NULL;
skipping to change at line 5489 skipping to change at line 5435
puts("unknown"); puts("unknown");
return 0; return 0;
} }
if (!arg_quiet) if (!arg_quiet)
puts(state); puts(state);
return streq(state, "running") ? EXIT_SUCCESS : EXIT_FAILURE; return streq(state, "running") ? EXIT_SUCCESS : EXIT_FAILURE;
} }
static int systemctl_help(void) { static void systemctl_help(void) {
pager_open_if_enabled(); pager_open_if_enabled();
printf("%s [OPTIONS...] {COMMAND} ...\n\n" printf("%s [OPTIONS...] {COMMAND} ...\n\n"
"Query or send control commands to the systemd manager.\n\n" "Query or send control commands to the systemd manager.\n\n"
" -h --help Show this help\n" " -h --help Show this help\n"
" --version Show package version\n" " --version Show package version\n"
" --system Connect to system manager\n" " --system Connect to system manager\n"
" --user Connect to user service manager\n" " --user Connect to user service manager\n"
" -H --host=[USER@]HOST\n" " -H --host=[USER@]HOST\n"
skipping to change at line 5614 skipping to change at line 5560
" halt Shut down and halt the sy stem\n" " halt Shut down and halt the sy stem\n"
" poweroff Shut down and power-off t he system\n" " poweroff Shut down and power-off t he system\n"
" reboot [ARG] Shut down and reboot the system\n" " reboot [ARG] Shut down and reboot the system\n"
" kexec Shut down and reboot the system with kexec\n" " kexec Shut down and reboot the system with kexec\n"
" exit Request user instance exi t\n" " exit Request user instance exi t\n"
" switch-root ROOT [INIT] Change to a different roo t file system\n" " switch-root ROOT [INIT] Change to a different roo t file system\n"
" suspend Suspend the system\n" " suspend Suspend the system\n"
" hibernate Hibernate the system\n" " hibernate Hibernate the system\n"
" hybrid-sleep Hibernate and suspend the system\n", " hybrid-sleep Hibernate and suspend the system\n",
program_invocation_short_name); program_invocation_short_name);
return 0;
} }
static int halt_help(void) { static void halt_help(void) {
printf("%s [OPTIONS...]%s\n\n" printf("%s [OPTIONS...]%s\n\n"
"%s the system.\n\n" "%s the system.\n\n"
" --help Show this help\n" " --help Show this help\n"
" --halt Halt the machine\n" " --halt Halt the machine\n"
" -p --poweroff Switch off the machine\n" " -p --poweroff Switch off the machine\n"
" --reboot Reboot the machine\n" " --reboot Reboot the machine\n"
" -f --force Force immediate halt/power-off/reboot\n" " -f --force Force immediate halt/power-off/reboot\n"
" -w --wtmp-only Don't halt/power-off/reboot, just write wt mp record\n" " -w --wtmp-only Don't halt/power-off/reboot, just write wt mp record\n"
" -d --no-wtmp Don't write wtmp record\n" " -d --no-wtmp Don't write wtmp record\n"
" --no-wall Don't send wall message before halt/power- off/reboot\n", " --no-wall Don't send wall message before halt/power- off/reboot\n",
program_invocation_short_name, program_invocation_short_name,
arg_action == ACTION_REBOOT ? " [ARG]" : "", arg_action == ACTION_REBOOT ? " [ARG]" : "",
arg_action == ACTION_REBOOT ? "Reboot" : arg_action == ACTION_REBOOT ? "Reboot" :
arg_action == ACTION_POWEROFF ? "Power off" : arg_action == ACTION_POWEROFF ? "Power off" :
"Halt"); "Halt");
return 0;
} }
static int shutdown_help(void) { static void shutdown_help(void) {
printf("%s [OPTIONS...] [TIME] [WALL...]\n\n" printf("%s [OPTIONS...] [TIME] [WALL...]\n\n"
"Shut down the system.\n\n" "Shut down the system.\n\n"
" --help Show this help\n" " --help Show this help\n"
" -H --halt Halt the machine\n" " -H --halt Halt the machine\n"
" -P --poweroff Power-off the machine\n" " -P --poweroff Power-off the machine\n"
" -r --reboot Reboot the machine\n" " -r --reboot Reboot the machine\n"
" -h Equivalent to --poweroff, overridden by -- halt\n" " -h Equivalent to --poweroff, overridden by -- halt\n"
" -k Don't halt/power-off/reboot, just send war nings\n" " -k Don't halt/power-off/reboot, just send war nings\n"
" --no-wall Don't send wall message before halt/power- off/reboot\n" " --no-wall Don't send wall message before halt/power- off/reboot\n"
" -c Cancel a pending shutdown\n", " -c Cancel a pending shutdown\n",
program_invocation_short_name); program_invocation_short_name);
return 0;
} }
static int telinit_help(void) { static void telinit_help(void) {
printf("%s [OPTIONS...] {COMMAND}\n\n" printf("%s [OPTIONS...] {COMMAND}\n\n"
"Send control commands to the init daemon.\n\n" "Send control commands to the init daemon.\n\n"
" --help Show this help\n" " --help Show this help\n"
" --no-wall Don't send wall message before halt/power- off/reboot\n\n" " --no-wall Don't send wall message before halt/power- off/reboot\n\n"
"Commands:\n" "Commands:\n"
" 0 Power-off the machine\n" " 0 Power-off the machine\n"
" 6 Reboot the machine\n" " 6 Reboot the machine\n"
" 2, 3, 4, 5 Start runlevelX.target unit\n" " 2, 3, 4, 5 Start runlevelX.target unit\n"
" 1, s, S Enter rescue mode\n" " 1, s, S Enter rescue mode\n"
" q, Q Reload init daemon configuration\n" " q, Q Reload init daemon configuration\n"
" u, U Reexecute init daemon\n", " u, U Reexecute init daemon\n",
program_invocation_short_name); program_invocation_short_name);
return 0;
} }
static int runlevel_help(void) { static void runlevel_help(void) {
printf("%s [OPTIONS...]\n\n" printf("%s [OPTIONS...]\n\n"
"Prints the previous and current runlevel of the init system .\n\n" "Prints the previous and current runlevel of the init system .\n\n"
" --help Show this help\n", " --help Show this help\n",
program_invocation_short_name); program_invocation_short_name);
return 0;
} }
static int help_types(void) { static void help_types(void) {
int i; int i;
const char *t; const char *t;
puts("Available unit types:"); if (!arg_no_legend)
puts("Available unit types:");
for (i = 0; i < _UNIT_TYPE_MAX; i++) { for (i = 0; i < _UNIT_TYPE_MAX; i++) {
t = unit_type_to_string(i); t = unit_type_to_string(i);
if (t) if (t)
puts(t); puts(t);
} }
return 0;
} }
static int systemctl_parse_argv(int argc, char *argv[]) { static int systemctl_parse_argv(int argc, char *argv[]) {
enum { enum {
ARG_FAIL = 0x100, ARG_FAIL = 0x100,
ARG_REVERSE, ARG_REVERSE,
ARG_AFTER, ARG_AFTER,
ARG_BEFORE, ARG_BEFORE,
ARG_SHOW_TYPES, ARG_SHOW_TYPES,
skipping to change at line 5777 skipping to change at line 5708
{ "recursive", no_argument, NULL, 'r' }, { "recursive", no_argument, NULL, 'r' },
{ "preset-mode", required_argument, NULL, ARG_PRESE T_MODE }, { "preset-mode", required_argument, NULL, ARG_PRESE T_MODE },
{} {}
}; };
int c; int c;
assert(argc >= 0); assert(argc >= 0);
assert(argv); assert(argv);
while ((c = getopt_long(argc, argv, "ht:p:alqfs:H:M:n:o:ir", option s, NULL)) >= 0) { while ((c = getopt_long(argc, argv, "ht:p:alqfs:H:M:n:o:ir", option s, NULL)) >= 0)
switch (c) { switch (c) {
case 'h': case 'h':
return systemctl_help(); systemctl_help();
return 0;
case ARG_VERSION: case ARG_VERSION:
puts(PACKAGE_STRING); puts(PACKAGE_STRING);
puts(SYSTEMD_FEATURES); puts(SYSTEMD_FEATURES);
return 0; return 0;
case 't': { case 't': {
char *word, *state; const char *word, *state;
size_t size; size_t size;
FOREACH_WORD_SEPARATOR(word, size, optarg, ",", sta te) { FOREACH_WORD_SEPARATOR(word, size, optarg, ",", sta te) {
_cleanup_free_ char *type; _cleanup_free_ char *type;
type = strndup(word, size); type = strndup(word, size);
if (!type) if (!type)
return -ENOMEM; return -ENOMEM;
if (streq(type, "help")) { if (streq(type, "help")) {
skipping to change at line 5839 skipping to change at line 5771
} }
case 'p': { case 'p': {
/* Make sure that if the empty property list /* Make sure that if the empty property list
was specified, we won't show any properties. */ was specified, we won't show any properties. */
if (isempty(optarg) && !arg_properties) { if (isempty(optarg) && !arg_properties) {
arg_properties = new0(char*, 1); arg_properties = new0(char*, 1);
if (!arg_properties) if (!arg_properties)
return log_oom(); return log_oom();
} else { } else {
char *word, *state; const char *word, *state;
size_t size; size_t size;
FOREACH_WORD_SEPARATOR(word, size, optarg, ",", state) { FOREACH_WORD_SEPARATOR(word, size, optarg, ",", state) {
char *prop; char *prop;
prop = strndup(word, size); prop = strndup(word, size);
if (!prop) if (!prop)
return log_oom(); return log_oom();
if (strv_consume(&arg_properties, p rop) < 0) if (strv_consume(&arg_properties, p rop) < 0)
skipping to change at line 6009 skipping to change at line 5941
case 'i': case 'i':
arg_ignore_inhibitors = true; arg_ignore_inhibitors = true;
break; break;
case ARG_PLAIN: case ARG_PLAIN:
arg_plain = true; arg_plain = true;
break; break;
case ARG_STATE: { case ARG_STATE: {
char *word, *state; const char *word, *state;
size_t size; size_t size;
FOREACH_WORD_SEPARATOR(word, size, optarg, ",", sta te) { FOREACH_WORD_SEPARATOR(word, size, optarg, ",", sta te) {
char *s; char *s;
s = strndup(word, size); s = strndup(word, size);
if (!s) if (!s)
return log_oom(); return log_oom();
if (strv_consume(&arg_states, s) < 0) if (strv_consume(&arg_states, s) < 0)
skipping to change at line 6050 skipping to change at line 5982
} }
break; break;
case '?': case '?':
return -EINVAL; return -EINVAL;
default: default:
assert_not_reached("Unhandled option"); assert_not_reached("Unhandled option");
} }
}
if (arg_transport != BUS_TRANSPORT_LOCAL && arg_scope != UNIT_FILE_ SYSTEM) { if (arg_transport != BUS_TRANSPORT_LOCAL && arg_scope != UNIT_FILE_ SYSTEM) {
log_error("Cannot access user instance remotely."); log_error("Cannot access user instance remotely.");
return -EINVAL; return -EINVAL;
} }
return 1; return 1;
} }
static int halt_parse_argv(int argc, char *argv[]) { static int halt_parse_argv(int argc, char *argv[]) {
skipping to change at line 6090 skipping to change at line 6021
int c, r, runlevel; int c, r, runlevel;
assert(argc >= 0); assert(argc >= 0);
assert(argv); assert(argv);
if (utmp_get_runlevel(&runlevel, NULL) >= 0) if (utmp_get_runlevel(&runlevel, NULL) >= 0)
if (runlevel == '0' || runlevel == '6') if (runlevel == '0' || runlevel == '6')
arg_force = 2; arg_force = 2;
while ((c = getopt_long(argc, argv, "pfwdnih", options, NULL)) >= 0 ) { while ((c = getopt_long(argc, argv, "pfwdnih", options, NULL)) >= 0 )
switch (c) { switch (c) {
case ARG_HELP: case ARG_HELP:
return halt_help(); halt_help();
return 0;
case ARG_HALT: case ARG_HALT:
arg_action = ACTION_HALT; arg_action = ACTION_HALT;
break; break;
case 'p': case 'p':
if (arg_action != ACTION_REBOOT) if (arg_action != ACTION_REBOOT)
arg_action = ACTION_POWEROFF; arg_action = ACTION_POWEROFF;
break; break;
skipping to change at line 6137 skipping to change at line 6069
case 'n': case 'n':
/* Compatibility nops */ /* Compatibility nops */
break; break;
case '?': case '?':
return -EINVAL; return -EINVAL;
default: default:
assert_not_reached("Unhandled option"); assert_not_reached("Unhandled option");
} }
}
if (arg_action == ACTION_REBOOT && (argc == optind || argc == optin d + 1)) { if (arg_action == ACTION_REBOOT && (argc == optind || argc == optin d + 1)) {
r = update_reboot_param_file(argc == optind + 1 ? argv[opti nd] : NULL); r = update_reboot_param_file(argc == optind + 1 ? argv[opti nd] : NULL);
if (r < 0) if (r < 0)
return r; return r;
} else if (optind < argc) { } else if (optind < argc) {
log_error("Too many arguments."); log_error("Too many arguments.");
return -EINVAL; return -EINVAL;
} }
skipping to change at line 6222 skipping to change at line 6153
{ "kexec", no_argument, NULL, 'K' }, /* n ot documented extension */ { "kexec", no_argument, NULL, 'K' }, /* n ot documented extension */
{ "no-wall", no_argument, NULL, ARG_NO_WALL }, { "no-wall", no_argument, NULL, ARG_NO_WALL },
{} {}
}; };
int c, r; int c, r;
assert(argc >= 0); assert(argc >= 0);
assert(argv); assert(argv);
while ((c = getopt_long(argc, argv, "HPrhkt:afFc", options, NULL)) >= 0) { while ((c = getopt_long(argc, argv, "HPrhkt:afFc", options, NULL)) >= 0)
switch (c) { switch (c) {
case ARG_HELP: case ARG_HELP:
return shutdown_help(); shutdown_help();
return 0;
case 'H': case 'H':
arg_action = ACTION_HALT; arg_action = ACTION_HALT;
break; break;
case 'P': case 'P':
arg_action = ACTION_POWEROFF; arg_action = ACTION_POWEROFF;
break; break;
case 'r': case 'r':
skipping to change at line 6275 skipping to change at line 6207
case 'c': case 'c':
arg_action = ACTION_CANCEL_SHUTDOWN; arg_action = ACTION_CANCEL_SHUTDOWN;
break; break;
case '?': case '?':
return -EINVAL; return -EINVAL;
default: default:
assert_not_reached("Unhandled option"); assert_not_reached("Unhandled option");
} }
}
if (argc > optind && arg_action != ACTION_CANCEL_SHUTDOWN) { if (argc > optind && arg_action != ACTION_CANCEL_SHUTDOWN) {
r = parse_time_spec(argv[optind], &arg_when); r = parse_time_spec(argv[optind], &arg_when);
if (r < 0) { if (r < 0) {
log_error("Failed to parse time specification: %s", argv[optind]); log_error("Failed to parse time specification: %s", argv[optind]);
return r; return r;
} }
} else } else
arg_when = now(CLOCK_REALTIME) + USEC_PER_MINUTE; arg_when = now(CLOCK_REALTIME) + USEC_PER_MINUTE;
skipping to change at line 6336 skipping to change at line 6267
{ 'u', ACTION_REEXEC }, { 'u', ACTION_REEXEC },
{ 'U', ACTION_REEXEC } { 'U', ACTION_REEXEC }
}; };
unsigned i; unsigned i;
int c; int c;
assert(argc >= 0); assert(argc >= 0);
assert(argv); assert(argv);
while ((c = getopt_long(argc, argv, "", options, NULL)) >= 0) { while ((c = getopt_long(argc, argv, "", options, NULL)) >= 0)
switch (c) { switch (c) {
case ARG_HELP: case ARG_HELP:
return telinit_help(); telinit_help();
return 0;
case ARG_NO_WALL: case ARG_NO_WALL:
arg_no_wall = true; arg_no_wall = true;
break; break;
case '?': case '?':
return -EINVAL; return -EINVAL;
default: default:
assert_not_reached("Unhandled option"); assert_not_reached("Unhandled option");
} }
}
if (optind >= argc) { if (optind >= argc) {
telinit_help(); log_error("%s: required argument missing.",
program_invocation_short_name);
return -EINVAL; return -EINVAL;
} }
if (optind + 1 < argc) { if (optind + 1 < argc) {
log_error("Too many arguments."); log_error("Too many arguments.");
return -EINVAL; return -EINVAL;
} }
if (strlen(argv[optind]) != 1) { if (strlen(argv[optind]) != 1) {
log_error("Expected single character argument."); log_error("Expected single character argument.");
skipping to change at line 6401 skipping to change at line 6333
static const struct option options[] = { static const struct option options[] = {
{ "help", no_argument, NULL, ARG_HELP }, { "help", no_argument, NULL, ARG_HELP },
{} {}
}; };
int c; int c;
assert(argc >= 0); assert(argc >= 0);
assert(argv); assert(argv);
while ((c = getopt_long(argc, argv, "", options, NULL)) >= 0) { while ((c = getopt_long(argc, argv, "", options, NULL)) >= 0)
switch (c) { switch (c) {
case ARG_HELP: case ARG_HELP:
return runlevel_help(); runlevel_help();
return 0;
case '?': case '?':
return -EINVAL; return -EINVAL;
default: default:
assert_not_reached("Unhandled option"); assert_not_reached("Unhandled option");
} }
}
if (optind < argc) { if (optind < argc) {
log_error("Too many arguments."); log_error("Too many arguments.");
return -EINVAL; return -EINVAL;
} }
return 1; return 1;
} }
static int parse_argv(int argc, char *argv[]) { static int parse_argv(int argc, char *argv[]) {
skipping to change at line 6899 skipping to change at line 6831
} }
printf("%c %c\n", printf("%c %c\n",
previous <= 0 ? 'N' : previous, previous <= 0 ? 'N' : previous,
runlevel <= 0 ? 'N' : runlevel); runlevel <= 0 ? 'N' : runlevel);
return 0; return 0;
} }
int main(int argc, char*argv[]) { int main(int argc, char*argv[]) {
_cleanup_bus_unref_ sd_bus *bus = NULL; _cleanup_bus_close_unref_ sd_bus *bus = NULL;
int r; int r;
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
log_parse_environment(); log_parse_environment();
log_open(); log_open();
/* Explicitly not on_tty() to avoid setting cached value. /* Explicitly not on_tty() to avoid setting cached value.
* This becomes relevant for piping output which might be * This becomes relevant for piping output which might be
* ellipsized. */ * ellipsized. */
original_stdout_is_tty = isatty(STDOUT_FILENO); original_stdout_is_tty = isatty(STDOUT_FILENO);
 End of changes. 51 change blocks. 
128 lines changed or deleted 59 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/