chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tmpfiles: always recreate the most basic directory structure in /var
[elogind.git]
/
src
/
systemctl
/
systemctl.c
diff --git
a/src/systemctl/systemctl.c
b/src/systemctl/systemctl.c
index 91d8032945fbe5899287a859f528f9d890a347ba..b11fee515cc67c4d8fcb3675d16369b563eea5a9 100644
(file)
--- a/
src/systemctl/systemctl.c
+++ b/
src/systemctl/systemctl.c
@@
-319,12
+319,6
@@
static int compare_unit_info(const void *a, const void *b) {
static bool output_show_unit(const UnitInfo *u, char **patterns) {
const char *dot;
static bool output_show_unit(const UnitInfo *u, char **patterns) {
const char *dot;
- if (!strv_isempty(arg_states))
- return
- strv_contains(arg_states, u->load_state) ||
- strv_contains(arg_states, u->sub_state) ||
- strv_contains(arg_states, u->active_state);
-
if (!strv_isempty(patterns)) {
char **pattern;
if (!strv_isempty(patterns)) {
char **pattern;
@@
-513,6
+507,7
@@
static int get_unit_list(
int c,
sd_bus_message **_reply) {
int c,
sd_bus_message **_reply) {
+ _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
size_t size = c;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
size_t size = c;
@@
-523,15
+518,22
@@
static int get_unit_list(
assert(unit_infos);
assert(_reply);
assert(unit_infos);
assert(_reply);
- r = sd_bus_
call_method
(
+ r = sd_bus_
message_new_method_call
(
bus,
bus,
+ &m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
- "ListUnits",
- &error,
- &reply,
- NULL);
+ "ListUnitsFiltered");
+
+ if (r < 0)
+ return bus_log_create_error(r);
+
+ r = sd_bus_message_append_strv(m, arg_states);
+ if (r < 0)
+ return bus_log_create_error(r);
+
+ r = sd_bus_call(bus, m, 0, &error, &reply);
if (r < 0) {
log_error("Failed to list units: %s", bus_error_message(&error, r));
return r;
if (r < 0) {
log_error("Failed to list units: %s", bus_error_message(&error, r));
return r;
@@
-2884,8
+2886,8
@@
static int check_inhibitors(sd_bus *bus, enum action a) {
get_process_comm(pid, &comm);
user = uid_to_name(uid);
get_process_comm(pid, &comm);
user = uid_to_name(uid);
- log_warning("Operation inhibited by \"%s\" (PID
%lu
\"%s\", user %s), reason is \"%s\".",
- who,
(unsigned long)
pid, strna(comm), strna(user), why);
+ log_warning("Operation inhibited by \"%s\" (PID
"PID_FMT"
\"%s\", user %s), reason is \"%s\".",
+ who, pid, strna(comm), strna(user), why);
c++;
}
c++;
}
@@
-4256,7
+4258,7
@@
static int get_unit_dbus_path_by_pid(
&reply,
"u", pid);
if (r < 0) {
&reply,
"u", pid);
if (r < 0) {
- log_error("Failed to get unit for PID
%lu: %s", (unsigned long)
pid, bus_error_message(&error, r));
+ log_error("Failed to get unit for PID
"PID_FMT": %s",
pid, bus_error_message(&error, r));
return r;
}
return r;
}
@@
-5002,18
+5004,18
@@
static int enable_sysv_units(const char *verb, char **args) {
/* Processes all SysV units, and reshuffles the array so that
* afterwards only the native units remain */
/* Processes all SysV units, and reshuffles the array so that
* afterwards only the native units remain */
- r = lookup_paths_init(&paths, SYSTEMD_SYSTEM, false, NULL, NULL, NULL);
+ r = lookup_paths_init(&paths, SYSTEMD_SYSTEM, false,
arg_root,
NULL, NULL, NULL);
if (r < 0)
return r;
r = 0;
for (f = 0; args[f]; f++) {
const char *name;
if (r < 0)
return r;
r = 0;
for (f = 0; args[f]; f++) {
const char *name;
- _cleanup_free_ char *p = NULL, *q = NULL;
+ _cleanup_free_ char *p = NULL, *q = NULL
, *l = NULL
;
bool found_native = false, found_sysv;
unsigned c = 1;
const char *argv[6] = { "/sbin/chkconfig", NULL, NULL, NULL, NULL };
bool found_native = false, found_sysv;
unsigned c = 1;
const char *argv[6] = { "/sbin/chkconfig", NULL, NULL, NULL, NULL };
- char **k
, *l
;
+ char **k;
int j;
pid_t pid;
siginfo_t status;
int j;
pid_t pid;
siginfo_t status;
@@
-5027,20
+5029,19
@@
static int enable_sysv_units(const char *verb, char **args) {
continue;
STRV_FOREACH(k, paths.unit_path) {
continue;
STRV_FOREACH(k, paths.unit_path) {
+ _cleanup_free_ char *path = NULL;
+
if (!isempty(arg_root))
if (!isempty(arg_root))
- asprintf(&p, "%s/%s/%s", arg_root, *k, name);
+ asprintf(&p
ath
, "%s/%s/%s", arg_root, *k, name);
else
else
- asprintf(&p, "%s/%s", *k, name);
+ asprintf(&p
ath
, "%s/%s", *k, name);
- if (!p) {
+ if (!p
ath
) {
r = log_oom();
goto finish;
}
r = log_oom();
goto finish;
}
- found_native = access(p, F_OK) >= 0;
- free(p);
- p = NULL;
-
+ found_native = access(path, F_OK) >= 0;
if (found_native)
break;
}
if (found_native)
break;
}
@@
-5057,9
+5058,8
@@
static int enable_sysv_units(const char *verb, char **args) {
goto finish;
}
goto finish;
}
- p[strlen(p) - s
izeof(".service") + 1
] = 0;
+ p[strlen(p) - s
trlen(".service")
] = 0;
found_sysv = access(p, F_OK) >= 0;
found_sysv = access(p, F_OK) >= 0;
-
if (!found_sysv)
continue;
if (!found_sysv)
continue;
@@
-5084,7
+5084,6
@@
static int enable_sysv_units(const char *verb, char **args) {
}
log_info("Executing %s", l);
}
log_info("Executing %s", l);
- free(l);
pid = fork();
if (pid < 0) {
pid = fork();
if (pid < 0) {
@@
-5926,7
+5925,7
@@
static int systemctl_parse_argv(int argc, char *argv[]) {
case 'r':
if (geteuid() != 0) {
case 'r':
if (geteuid() != 0) {
- log_error("--recursive requires root privil
i
ges.");
+ log_error("--recursive requires root privil
e
ges.");
return -EPERM;
}
return -EPERM;
}