chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
man: bring systemctl man page and --help text into the same order
[elogind.git]
/
src
/
systemctl
/
systemctl.c
diff --git
a/src/systemctl/systemctl.c
b/src/systemctl/systemctl.c
index 3d939f050b707722eb20a0017ec6a85522b9bba0..74528dd5b6cbbefae35d610b0af78c745ab76085 100644
(file)
--- a/
src/systemctl/systemctl.c
+++ b/
src/systemctl/systemctl.c
@@
-176,7
+176,6
@@
static void ask_password_agent_open_if_enabled(void) {
ask_password_agent_open();
}
ask_password_agent_open();
}
-#ifdef HAVE_LOGIND
static void polkit_agent_open_if_enabled(void) {
/* Open the polkit agent as a child process if necessary */
static void polkit_agent_open_if_enabled(void) {
/* Open the polkit agent as a child process if necessary */
@@
-192,7
+191,15
@@
static void polkit_agent_open_if_enabled(void) {
polkit_agent_open();
}
polkit_agent_open();
}
-#endif
+
+static OutputFlags get_output_flags(void) {
+ return
+ arg_all * OUTPUT_SHOW_ALL |
+ arg_full * OUTPUT_FULL_WIDTH |
+ (!on_tty() || pager_have()) * OUTPUT_FULL_WIDTH |
+ on_tty() * OUTPUT_COLOR |
+ !arg_quiet * OUTPUT_WARN_CUTOFF;
+}
static int translate_bus_error_to_exit_status(int r, const sd_bus_error *error) {
assert(error);
static int translate_bus_error_to_exit_status(int r, const sd_bus_error *error) {
assert(error);
@@
-2697,6
+2704,7
@@
static int start_unit(sd_bus *bus, char **args) {
assert(bus);
ask_password_agent_open_if_enabled();
assert(bus);
ask_password_agent_open_if_enabled();
+ polkit_agent_open_if_enabled();
if (arg_action == ACTION_SYSTEMCTL) {
enum action action;
if (arg_action == ACTION_SYSTEMCTL) {
enum action action;
@@
-3020,6
+3028,8
@@
static int kill_unit(sd_bus *bus, char **args) {
assert(bus);
assert(args);
assert(bus);
assert(args);
+ polkit_agent_open_if_enabled();
+
if (!arg_kill_who)
arg_kill_who = "all";
if (!arg_kill_who)
arg_kill_who = "all";
@@
-3224,12
+3234,6
@@
static void print_status_info(
char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
char since2[FORMAT_TIMESTAMP_MAX], *s2;
const char *path;
char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
char since2[FORMAT_TIMESTAMP_MAX], *s2;
const char *path;
- int flags =
- arg_all * OUTPUT_SHOW_ALL |
- (!on_tty() || pager_have()) * OUTPUT_FULL_WIDTH |
- on_tty() * OUTPUT_COLOR |
- !arg_quiet * OUTPUT_WARN_CUTOFF |
- arg_full * OUTPUT_FULL_WIDTH;
char **t, **t2;
assert(i);
char **t, **t2;
assert(i);
@@
-3499,21
+3503,23
@@
static void print_status_info(
if (i->control_pid > 0)
extra[k++] = i->control_pid;
if (i->control_pid > 0)
extra[k++] = i->control_pid;
- show_cgroup_and_extra(SYSTEMD_CGROUP_CONTROLLER, i->control_group, prefix, c, false, extra, k,
flags
);
+ show_cgroup_and_extra(SYSTEMD_CGROUP_CONTROLLER, i->control_group, prefix, c, false, extra, k,
get_output_flags()
);
}
}
if (i->id && arg_transport == BUS_TRANSPORT_LOCAL) {
}
}
if (i->id && arg_transport == BUS_TRANSPORT_LOCAL) {
- show_journal_by_unit(stdout,
- i->id,
- arg_output,
- 0,
- i->inactive_exit_timestamp_monotonic,
- arg_lines,
- getuid(),
- flags | OUTPUT_BEGIN_NEWLINE,
- arg_scope == UNIT_FILE_SYSTEM,
- ellipsized);
+ show_journal_by_unit(
+ stdout,
+ i->id,
+ arg_output,
+ 0,
+ i->inactive_exit_timestamp_monotonic,
+ arg_lines,
+ getuid(),
+ get_output_flags() | OUTPUT_BEGIN_NEWLINE,
+ SD_JOURNAL_LOCAL_ONLY,
+ arg_scope == UNIT_FILE_SYSTEM,
+ ellipsized);
}
if (i->need_daemon_reload)
}
if (i->need_daemon_reload)
@@
-4377,13
+4383,6
@@
static int show_system_status(sd_bus *bus) {
printf(" CGroup: %s\n", mi.control_group ?: "/");
if (arg_transport == BUS_TRANSPORT_LOCAL || arg_transport == BUS_TRANSPORT_MACHINE) {
printf(" CGroup: %s\n", mi.control_group ?: "/");
if (arg_transport == BUS_TRANSPORT_LOCAL || arg_transport == BUS_TRANSPORT_MACHINE) {
- int flags =
- arg_all * OUTPUT_SHOW_ALL |
- (!on_tty() || pager_have()) * OUTPUT_FULL_WIDTH |
- on_tty() * OUTPUT_COLOR |
- !arg_quiet * OUTPUT_WARN_CUTOFF |
- arg_full * OUTPUT_FULL_WIDTH;
-
static const char prefix[] = " ";
unsigned c;
static const char prefix[] = " ";
unsigned c;
@@
-4393,7
+4392,7
@@
static int show_system_status(sd_bus *bus) {
else
c = 0;
else
c = 0;
- show_cgroup(SYSTEMD_CGROUP_CONTROLLER, strempty(mi.control_group), prefix, c, false,
flags
);
+ show_cgroup(SYSTEMD_CGROUP_CONTROLLER, strempty(mi.control_group), prefix, c, false,
get_output_flags()
);
}
free(mi.state);
}
free(mi.state);
@@
-4515,11
+4514,7
@@
static int init_home_and_lookup_paths(char **user_home, char **user_runtime, Loo
return log_error_errno(ENOTDIR, "Cannot find units: $XDG_RUNTIME_DIR is not set.");
}
return log_error_errno(ENOTDIR, "Cannot find units: $XDG_RUNTIME_DIR is not set.");
}
- r = lookup_paths_init(lp,
- arg_scope == UNIT_FILE_SYSTEM ? SYSTEMD_SYSTEM : SYSTEMD_USER,
- arg_scope == UNIT_FILE_USER,
- arg_root,
- NULL, NULL, NULL);
+ r = lookup_paths_init_from_scope(lp, arg_scope, arg_root);
if (r < 0)
return log_error_errno(r, "Failed to lookup unit lookup paths: %m");
if (r < 0)
return log_error_errno(r, "Failed to lookup unit lookup paths: %m");
@@
-4607,6
+4602,8
@@
static int set_property(sd_bus *bus, char **args) {
char **i;
int r;
char **i;
int r;
+ polkit_agent_open_if_enabled();
+
r = sd_bus_message_new_method_call(
bus,
&m,
r = sd_bus_message_new_method_call(
bus,
&m,
@@
-4667,6
+4664,8
@@
static int snapshot(sd_bus *bus, char **args) {
const char *path;
int r;
const char *path;
int r;
+ polkit_agent_open_if_enabled();
+
if (strv_length(args) > 1)
n = unit_name_mangle_with_suffix(args[1], MANGLE_NOGLOB, ".snapshot");
else
if (strv_length(args) > 1)
n = unit_name_mangle_with_suffix(args[1], MANGLE_NOGLOB, ".snapshot");
else
@@
-4729,6
+4728,8
@@
static int delete_snapshot(sd_bus *bus, char **args) {
assert(args);
assert(args);
+ polkit_agent_open_if_enabled();
+
r = expand_names(bus, args + 1, ".snapshot", &names);
if (r < 0)
log_error_errno(r, "Failed to expand names: %m");
r = expand_names(bus, args + 1, ".snapshot", &names);
if (r < 0)
log_error_errno(r, "Failed to expand names: %m");
@@
-4772,6
+4773,8
@@
static int daemon_reload(sd_bus *bus, char **args) {
const char *method;
int r;
const char *method;
int r;
+ polkit_agent_open_if_enabled();
+
if (arg_action == ACTION_RELOAD)
method = "Reload";
else if (arg_action == ACTION_REEXEC)
if (arg_action == ACTION_RELOAD)
method = "Reload";
else if (arg_action == ACTION_REEXEC)
@@
-4830,6
+4833,8
@@
static int reset_failed(sd_bus *bus, char **args) {
if (strv_length(args) <= 1)
return daemon_reload(bus, args);
if (strv_length(args) <= 1)
return daemon_reload(bus, args);
+ polkit_agent_open_if_enabled();
+
r = expand_names(bus, args + 1, NULL, &names);
if (r < 0)
log_error_errno(r, "Failed to expand names: %m");
r = expand_names(bus, args + 1, NULL, &names);
if (r < 0)
log_error_errno(r, "Failed to expand names: %m");
@@
-5291,6
+5296,8
@@
static int enable_unit(sd_bus *bus, char **args) {
bool send_force = true, send_preset_mode = false;
const char *method;
bool send_force = true, send_preset_mode = false;
const char *method;
+ polkit_agent_open_if_enabled();
+
if (streq(verb, "enable")) {
method = "EnableUnitFiles";
expect_carries_install_info = true;
if (streq(verb, "enable")) {
method = "EnableUnitFiles";
expect_carries_install_info = true;
@@
-5436,6
+5443,8
@@
static int add_dependency(sd_bus *bus, char **args) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL, *m = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL, *m = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
+ polkit_agent_open_if_enabled();
+
r = sd_bus_message_new_method_call(
bus,
&m,
r = sd_bus_message_new_method_call(
bus,
&m,
@@
-5499,6
+5508,8
@@
static int preset_all(sd_bus *bus, char **args) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
+ polkit_agent_open_if_enabled();
+
r = sd_bus_message_new_method_call(
bus,
&m,
r = sd_bus_message_new_method_call(
bus,
&m,
@@
-6064,7
+6075,7
@@
static void systemctl_help(void) {
" based on preset configuration\n"
" preset-all Enable/disable all unit files based on\n"
" preset configuration\n"
" based on preset configuration\n"
" preset-all Enable/disable all unit files based on\n"
" preset configuration\n"
- " is-enabled NAME... Check whether unit files are enabled\n
\n
"
+ " is-enabled NAME... Check whether unit files are enabled\n"
" mask NAME... Mask one or more units\n"
" unmask NAME... Unmask one or more units\n"
" link PATH... Link one or more units files into\n"
" mask NAME... Mask one or more units\n"
" unmask NAME... Unmask one or more units\n"
" link PATH... Link one or more units files into\n"
@@
-6073,10
+6084,9
@@
static void systemctl_help(void) {
" on specified one or more units\n"
" add-requires TARGET NAME... Add 'Requires' dependency for the target\n"
" on specified one or more units\n"
" on specified one or more units\n"
" add-requires TARGET NAME... Add 'Requires' dependency for the target\n"
" on specified one or more units\n"
- " get-default Get the name of the default target\n"
- " set-default NAME Set the default target\n"
" edit NAME... Edit one or more unit files\n"
" edit NAME... Edit one or more unit files\n"
- "\n"
+ " get-default Get the name of the default target\n"
+ " set-default NAME Set the default target\n\n"
"Machine Commands:\n"
" list-machines [PATTERN...] List local containers and host\n\n"
"Job Commands:\n"
"Machine Commands:\n"
" list-machines [PATTERN...] List local containers and host\n\n"
"Job Commands:\n"
@@
-7413,6
+7423,11
@@
int main(int argc, char*argv[]) {
goto finish;
}
goto finish;
}
+ /* Increase max number of open files to 16K if we can, we
+ * might needs this when browsing journal files, which might
+ * be split up into many files. */
+ setrlimit_closest(RLIMIT_NOFILE, &RLIMIT_MAKE_CONST(16384));
+
if (!avoid_bus())
r = bus_open_transport_systemd(arg_transport, arg_host, arg_scope != UNIT_FILE_SYSTEM, &bus);
if (!avoid_bus())
r = bus_open_transport_systemd(arg_transport, arg_host, arg_scope != UNIT_FILE_SYSTEM, &bus);