chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
networkd: link - set mac addresses when starting clients
[elogind.git]
/
src
/
systemctl
/
systemctl.c
diff --git
a/src/systemctl/systemctl.c
b/src/systemctl/systemctl.c
index 8fd7bc9608476381dbe826f0fd3b79f10ae6e88a..1b381f7a90680d6a661fcff02c2916601b4b5e7c 100644
(file)
--- a/
src/systemctl/systemctl.c
+++ b/
src/systemctl/systemctl.c
@@
-740,6
+740,7
@@
static int get_listening(
}
struct socket_info {
}
struct socket_info {
+ const char *machine;
const char* id;
char* type;
const char* id;
char* type;
@@
-760,6
+761,16
@@
static int socket_info_compare(const struct socket_info *a, const struct socket_
assert(a);
assert(b);
assert(a);
assert(b);
+ if (!a->machine && b->machine)
+ return -1;
+ if (a->machine && !b->machine)
+ return 1;
+ if (a->machine && b->machine) {
+ o = strcasecmp(a->machine, b->machine);
+ if (o != 0)
+ return o;
+ }
+
o = strcmp(a->path, b->path);
if (o == 0)
o = strcmp(a->type, b->type);
o = strcmp(a->path, b->path);
if (o == 0)
o = strcmp(a->type, b->type);
@@
-782,7
+793,7
@@
static int output_sockets_list(struct socket_info *socket_infos, unsigned cs) {
socklen = MAX(socklen, strlen(s->id));
if (arg_show_types)
typelen = MAX(typelen, strlen(s->type));
socklen = MAX(socklen, strlen(s->id));
if (arg_show_types)
typelen = MAX(typelen, strlen(s->type));
- pathlen = MAX(pathlen, strlen(s->path));
+ pathlen = MAX(pathlen, strlen(s->path)
+ (s->machine ? strlen(s->machine)+1 : 0)
);
STRV_FOREACH(a, s->triggered)
tmp += strlen(*a) + 2*(a != s->triggered);
STRV_FOREACH(a, s->triggered)
tmp += strlen(*a) + 2*(a != s->triggered);
@@
-798,14
+809,24
@@
static int output_sockets_list(struct socket_info *socket_infos, unsigned cs) {
"ACTIVATES");
for (s = socket_infos; s < socket_infos + cs; s++) {
"ACTIVATES");
for (s = socket_infos; s < socket_infos + cs; s++) {
+ _cleanup_free_ char *j = NULL;
+ const char *path;
char **a;
char **a;
+ if (s->machine) {
+ j = strjoin(s->machine, ":", s->path, NULL);
+ if (!j)
+ return log_oom();
+ path = j;
+ } else
+ path = s->path;
+
if (arg_show_types)
printf("%-*s %-*s %-*s",
if (arg_show_types)
printf("%-*s %-*s %-*s",
- pathlen,
s->
path, typelen, s->type, socklen, s->id);
+ pathlen, path, typelen, s->type, socklen, s->id);
else
printf("%-*s %-*s",
else
printf("%-*s %-*s",
- pathlen,
s->
path, socklen, s->id);
+ pathlen, path, socklen, s->id);
STRV_FOREACH(a, s->triggered)
printf("%s %s",
a == s->triggered ? "" : ",", *a);
STRV_FOREACH(a, s->triggered)
printf("%s %s",
a == s->triggered ? "" : ",", *a);
@@
-831,7
+852,8
@@
static int output_sockets_list(struct socket_info *socket_infos, unsigned cs) {
}
static int list_sockets(sd_bus *bus, char **args) {
}
static int list_sockets(sd_bus *bus, char **args) {
- _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
+ _cleanup_(message_set_freep) Set *replies = NULL;
+ _cleanup_strv_free_ char **machines = NULL;
_cleanup_free_ UnitInfo *unit_infos = NULL;
_cleanup_free_ struct socket_info *socket_infos = NULL;
const UnitInfo *u;
_cleanup_free_ UnitInfo *unit_infos = NULL;
_cleanup_free_ struct socket_info *socket_infos = NULL;
const UnitInfo *u;
@@
-842,7
+864,7
@@
static int list_sockets(sd_bus *bus, char **args) {
pager_open_if_enabled();
pager_open_if_enabled();
- n = get_unit_list
(bus, NULL, strv_skip_first(args), &unit_infos, 0, &reply
);
+ n = get_unit_list
_recursive(bus, strv_skip_first(args), &unit_infos, &replies, &machines
);
if (n < 0)
return n;
if (n < 0)
return n;
@@
-870,6
+892,7
@@
static int list_sockets(sd_bus *bus, char **args) {
for (i = 0; i < c; i++)
socket_infos[cs + i] = (struct socket_info) {
for (i = 0; i < c; i++)
socket_infos[cs + i] = (struct socket_info) {
+ .machine = u->machine,
.id = u->id,
.type = listening[i*2],
.path = listening[i*2 + 1],
.id = u->id,
.type = listening[i*2],
.path = listening[i*2 + 1],
@@
-975,6
+998,7
@@
static int get_last_trigger(
}
struct timer_info {
}
struct timer_info {
+ const char* machine;
const char* id;
usec_t next_elapse;
usec_t last_trigger;
const char* id;
usec_t next_elapse;
usec_t last_trigger;
@@
-982,9
+1006,21
@@
struct timer_info {
};
static int timer_info_compare(const struct timer_info *a, const struct timer_info *b) {
};
static int timer_info_compare(const struct timer_info *a, const struct timer_info *b) {
+ int o;
+
assert(a);
assert(b);
assert(a);
assert(b);
+ if (!a->machine && b->machine)
+ return -1;
+ if (a->machine && !b->machine)
+ return 1;
+ if (a->machine && b->machine) {
+ o = strcasecmp(a->machine, b->machine);
+ if (o != 0)
+ return o;
+ }
+
if (a->next_elapse < b->next_elapse)
return -1;
if (a->next_elapse > b->next_elapse)
if (a->next_elapse < b->next_elapse)
return -1;
if (a->next_elapse > b->next_elapse)
@@
-1031,7
+1067,7
@@
static int output_timers_list(struct timer_info *timer_infos, unsigned n) {
passedlen = MAX(passedlen, strlen(trel));
}
passedlen = MAX(passedlen, strlen(trel));
}
- unitlen = MAX(unitlen, strlen(t->id));
+ unitlen = MAX(unitlen, strlen(t->id)
+ (t->machine ? strlen(t->machine)+1 : 0)
);
STRV_FOREACH(a, t->triggered)
ul += strlen(*a) + 2*(a != t->triggered);
STRV_FOREACH(a, t->triggered)
ul += strlen(*a) + 2*(a != t->triggered);
@@
-1050,6
+1086,8
@@
static int output_timers_list(struct timer_info *timer_infos, unsigned n) {
"ACTIVATES");
for (t = timer_infos; t < timer_infos + n; t++) {
"ACTIVATES");
for (t = timer_infos; t < timer_infos + n; t++) {
+ _cleanup_free_ char *j = NULL;
+ const char *unit;
char tstamp1[FORMAT_TIMESTAMP_MAX] = "n/a", trel1[FORMAT_TIMESTAMP_RELATIVE_MAX] = "n/a";
char tstamp2[FORMAT_TIMESTAMP_MAX] = "n/a", trel2[FORMAT_TIMESTAMP_RELATIVE_MAX] = "n/a";
char **a;
char tstamp1[FORMAT_TIMESTAMP_MAX] = "n/a", trel1[FORMAT_TIMESTAMP_RELATIVE_MAX] = "n/a";
char tstamp2[FORMAT_TIMESTAMP_MAX] = "n/a", trel2[FORMAT_TIMESTAMP_RELATIVE_MAX] = "n/a";
char **a;
@@
-1060,8
+1098,16
@@
static int output_timers_list(struct timer_info *timer_infos, unsigned n) {
format_timestamp(tstamp2, sizeof(tstamp2), t->last_trigger);
format_timestamp_relative(trel2, sizeof(trel2), t->last_trigger);
format_timestamp(tstamp2, sizeof(tstamp2), t->last_trigger);
format_timestamp_relative(trel2, sizeof(trel2), t->last_trigger);
+ if (t->machine) {
+ j = strjoin(t->machine, ":", t->id, NULL);
+ if (!j)
+ return log_oom();
+ unit = j;
+ } else
+ unit = t->id;
+
printf("%-*s %-*s %-*s %-*s %-*s",
printf("%-*s %-*s %-*s %-*s %-*s",
- nextlen, tstamp1, leftlen, trel1, lastlen, tstamp2, passedlen, trel2, unitlen,
t->id
);
+ nextlen, tstamp1, leftlen, trel1, lastlen, tstamp2, passedlen, trel2, unitlen,
unit
);
STRV_FOREACH(a, t->triggered)
printf("%s %s",
STRV_FOREACH(a, t->triggered)
printf("%s %s",
@@
-1113,8
+1159,8
@@
static usec_t calc_next_elapse(dual_timestamp *nw, dual_timestamp *next) {
}
static int list_timers(sd_bus *bus, char **args) {
}
static int list_timers(sd_bus *bus, char **args) {
-
- _cleanup_
bus_message_unref_ sd_bus_message *reply
= NULL;
+ _cleanup_(message_set_freep) Set *replies = NULL;
+ _cleanup_
strv_free_ char **machines
= NULL;
_cleanup_free_ struct timer_info *timer_infos = NULL;
_cleanup_free_ UnitInfo *unit_infos = NULL;
struct timer_info *t;
_cleanup_free_ struct timer_info *timer_infos = NULL;
_cleanup_free_ UnitInfo *unit_infos = NULL;
struct timer_info *t;
@@
-1126,7
+1172,7
@@
static int list_timers(sd_bus *bus, char **args) {
pager_open_if_enabled();
pager_open_if_enabled();
- n = get_unit_list
(bus, NULL, strv_skip_first(args), &unit_infos, 0, &reply
);
+ n = get_unit_list
_recursive(bus, strv_skip_first(args), &unit_infos, &replies, &machines
);
if (n < 0)
return n;
if (n < 0)
return n;
@@
-1158,6
+1204,7
@@
static int list_timers(sd_bus *bus, char **args) {
m = calc_next_elapse(&nw, &next);
timer_infos[c++] = (struct timer_info) {
m = calc_next_elapse(&nw, &next);
timer_infos[c++] = (struct timer_info) {
+ .machine = u->machine,
.id = u->id,
.next_elapse = m,
.last_trigger = last,
.id = u->id,
.next_elapse = m,
.last_trigger = last,
@@
-1921,7
+1968,7
@@
static int set_default(sd_bus *bus, char **args) {
return log_oom();
if (!bus || avoid_bus()) {
return log_oom();
if (!bus || avoid_bus()) {
- r = unit_file_set_default(arg_scope, arg_root, unit,
arg_forc
e, &changes, &n_changes);
+ r = unit_file_set_default(arg_scope, arg_root, unit,
tru
e, &changes, &n_changes);
if (r < 0) {
log_error("Failed to set default target: %s", strerror(-r));
return r;
if (r < 0) {
log_error("Failed to set default target: %s", strerror(-r));
return r;
@@
-1943,7
+1990,7
@@
static int set_default(sd_bus *bus, char **args) {
"SetDefaultTarget",
&error,
&reply,
"SetDefaultTarget",
&error,
&reply,
- "sb", unit,
arg_forc
e);
+ "sb", unit,
tru
e);
if (r < 0) {
log_error("Failed to set default target: %s", bus_error_message(&error, -r));
return r;
if (r < 0) {
log_error("Failed to set default target: %s", bus_error_message(&error, -r));
return r;