[systemd-commits] 9 commits - man/systemd.unit.xml src/detect-virt.c src/loginctl.c src/logind.c src/nspawn.c src/sd-login.c src/socket.c src/sysfs-show.c src/systemctl.c src/systemd-analyze src/umount.c src/unit.c src/util.c
Lennart Poettering
lennart at kemper.freedesktop.org
Fri Sep 23 07:28:38 PDT 2011
man/systemd.unit.xml | 19 ++++++++++-------
src/detect-virt.c | 3 +-
src/loginctl.c | 5 +---
src/logind.c | 7 ++++--
src/nspawn.c | 9 ++++----
src/sd-login.c | 41 ++++++++++++++++++++----------------
src/socket.c | 6 +++++
src/sysfs-show.c | 3 ++
src/systemctl.c | 2 -
src/systemd-analyze | 16 ++++++++++++--
src/umount.c | 7 ++++--
src/unit.c | 2 -
src/util.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++---
13 files changed, 132 insertions(+), 45 deletions(-)
New commits:
commit f2b33002cd5747ebf288d20a352655307f97aac5
Author: Koen Kooi <koen at dominion.thruhere.net>
Date: Thu Sep 22 15:24:18 2011 +0200
analyze: report startup time in plot mode as well
It now prints something like "Startup finished in 1507ms (kernel) + 850ms (userspace) = 2357ms" below the legend.
diff --git a/src/systemd-analyze b/src/systemd-analyze
index 649d0e1..ac64040 100755
--- a/src/systemd-analyze
+++ b/src/systemd-analyze
@@ -221,6 +221,18 @@ elif sys.argv[1] == 'plot':
draw_text(context, 0, height-border*2, "Legend: Red = Activating; Pink = Active; Dark Pink = Deactivating", hcenter = 0, vcenter = -1)
+ if initrd_time > 0:
+ draw_text(context, 0, height-border*2 + bar_height, "Startup finished in %lums (kernel) + %lums (initrd) + %lums (userspace) = %lums" % ( \
+ initrd_time/1000, \
+ (start_time - initrd_time)/1000, \
+ (finish_time - start_time)/1000, \
+ finish_time/1000), hcenter = 0, vcenter = -1)
+ else:
+ draw_text(context, 0, height-border*2 + bar_height, "Startup finished in %lums (kernel) + %lums (userspace) = %lums" % ( \
+ start_time/1000, \
+ (finish_time - start_time)/1000, \
+ finish_time/1000), hcenter = 0, vcenter = -1)
+
surface.finish()
elif sys.argv[1] in ("help", "--help", "-h"):
help()
commit 70daa623320835dbad111ca6e4c6f8ae31388904
Author: Koen Kooi <koen at dominion.thruhere.net>
Date: Thu Sep 22 11:30:04 2011 +0200
analyze: always draw 1s marker for scale
In situations like this:
root at omap4430-panda:~# systemd-analyze
Startup finished in 1499ms (kernel) + 916ms (userspace) = 2416ms
The svg plot will only have the 0s marker and no subsequent markers for scale. This patch forces the 1s marker to always be drawn.
diff --git a/src/systemd-analyze b/src/systemd-analyze
index ae7dcfb..649d0e1 100755
--- a/src/systemd-analyze
+++ b/src/systemd-analyze
@@ -147,7 +147,7 @@ elif sys.argv[1] == 'plot':
context.set_line_width(1)
context.set_source_rgb(0.7, 0.7, 0.7)
- for x in range(0, (finish_time - start_time)/10000, 100):
+ for x in range(0, max((finish_time - start_time)/10000,110), 100):
context.move_to(x, 0)
context.line_to(x, height-border*2)
@@ -163,7 +163,7 @@ elif sys.argv[1] == 'plot':
banner = "Running on %s (%s %s) %s" % (os.uname()[1], os.uname()[2], os.uname()[3], os.uname()[4])
draw_text(context, 0, -15, banner, hcenter = 0, vcenter = 1)
- for x in range(0, (finish_time - start_time)/10000, 100):
+ for x in range(0, max((finish_time - start_time)/10000,110), 100):
draw_text(context, x, -5, "%lus" % (x/100), vcenter = 0, hcenter = 0)
y = 0
commit a65cb51f29ee177f6f800c87232b68475216a418
Author: Michal Schmidt <mschmidt at redhat.com>
Date: Fri Sep 23 13:58:00 2011 +0200
unit: fix complementing of requirement deps with After deps for targets
'man systemd.target' says:
Unless DefaultDependencies= is set to false, target units will
implicitly complement all configured dependencies of type
Wants=, Requires=, RequiresOverridable= with dependencies of type
After= if the units in question also have DefaultDependencies=true.
It did not work because of a forgotten negation.
diff --git a/src/unit.c b/src/unit.c
index 0b435cb..903a8e4 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -774,7 +774,7 @@ int unit_add_default_target_dependency(Unit *u, Unit *target) {
/* If either side wants no automatic dependencies, then let's
* skip this */
if (!u->meta.default_dependencies ||
- target->meta.default_dependencies)
+ !target->meta.default_dependencies)
return 0;
/* Don't create loops */
commit 799f46d36f1c1f5ce8f638f453feeede3e6842fc
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Sep 23 05:33:33 2011 +0200
util: don't fail if no id was passed to detect_container()
diff --git a/src/util.c b/src/util.c
index 33b6fd4..ed3b8d4 100644
--- a/src/util.c
+++ b/src/util.c
@@ -4445,17 +4445,23 @@ int detect_container(const char **id) {
if (streq(line, "container=lxc")) {
fclose(f);
- *id = "lxc";
+
+ if (id)
+ *id = "lxc";
return 1;
} else if (streq(line, "container=systemd-nspawn")) {
fclose(f);
- *id = "systemd-nspawn";
+
+ if (id)
+ *id = "systemd-nspawn";
return 1;
} else if (startswith(line, "container=")) {
fclose(f);
- *id = "other-container";
+
+ if (id)
+ *id = "other-container";
return 1;
}
commit 65bc2c21140d20e757b0aed9bb23286939426abb
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Sep 23 04:38:39 2011 +0200
util: detect systemd-nspawn without relying on ns cgroup tree
diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml
index f4764f9..9066e66 100644
--- a/man/systemd.unit.xml
+++ b/man/systemd.unit.xml
@@ -746,18 +746,22 @@
whether it is a specific
implementation. Takes either boolean
value to check if being executed in
- any virtual environment or one of the
+ any virtual environment or one of
<varname>qemu</varname>,
<varname>kvm</varname>,
<varname>vmware</varname>,
<varname>microsoft</varname>,
<varname>oracle</varname>,
<varname>xen</varname>,
- <varname>pidns</varname>,
- <varname>openvz</varname> to test
- against a specific implementation. The
- test may be negated by prepending an
- exclamation mark.
+ <varname>openvz</varname>,
+ <varname>lxc</varname>,
+ <varname>systemd-nspawn</varname>,
+ <varname>pidns</varname> to test
+ against a specific implementation. If
+ multiple virtualization technologies
+ are nested only the innermost is
+ considered. The test may be negated by
+ prepending an exclamation mark.
<varname>ConditionSecurity=</varname>
may be used to check whether the given
security module is enabled on the
@@ -788,7 +792,8 @@
pipe symbol must be passed first, the
exclamation second. Except for
<varname>ConditionPathIsSymbolicLink=</varname>,
- all path checks follow symlinks.</para></listitem>
+ all path checks follow
+ symlinks.</para></listitem>
</varlistentry>
<varlistentry>
diff --git a/src/detect-virt.c b/src/detect-virt.c
index 57f0176..324f182 100644
--- a/src/detect-virt.c
+++ b/src/detect-virt.c
@@ -34,7 +34,8 @@ int main(int argc, char *argv[]) {
* to detect whether we are being run in a virtualized
* environment or not */
- if ((r = detect_virtualization(&id)) < 0) {
+ r = detect_virtualization(&id);
+ if (r < 0) {
log_error("Failed to check for virtualization: %s", strerror(-r));
return EXIT_FAILURE;
}
diff --git a/src/util.c b/src/util.c
index 36c8938..33b6fd4 100644
--- a/src/util.c
+++ b/src/util.c
@@ -4384,7 +4384,7 @@ int detect_vm(const char **id) {
if (hypervisor) {
if (id)
- *id = "other";
+ *id = "other-vm";
return 1;
}
@@ -4421,7 +4421,51 @@ int detect_container(const char **id) {
return 1;
}
- if ((f = fopen("/proc/self/cgroup", "re"))) {
+ f = fopen("/proc/1/environ", "re");
+ if (f) {
+ bool done = false;
+
+ do {
+ char line[LINE_MAX];
+ unsigned i;
+
+ for (i = 0; i < sizeof(line)-1; i++) {
+ int c;
+
+ c = getc(f);
+ if (_unlikely_(c == EOF)) {
+ done = true;
+ break;
+ } else if (c == 0)
+ break;
+
+ line[i] = c;
+ }
+ line[i] = 0;
+
+ if (streq(line, "container=lxc")) {
+ fclose(f);
+ *id = "lxc";
+ return 1;
+
+ } else if (streq(line, "container=systemd-nspawn")) {
+ fclose(f);
+ *id = "systemd-nspawn";
+ return 1;
+
+ } else if (startswith(line, "container=")) {
+ fclose(f);
+ *id = "other-container";
+ return 1;
+ }
+
+ } while (!done);
+
+ fclose(f);
+ }
+
+ f = fopen("/proc/self/cgroup", "re");
+ if (f) {
for (;;) {
char line[LINE_MAX], *p;
@@ -4429,7 +4473,8 @@ int detect_container(const char **id) {
if (!fgets(line, sizeof(line), f))
break;
- if (!(p = strchr(strstrip(line), ':')))
+ p = strchr(strstrip(line), ':');
+ if (!p)
continue;
if (strncmp(p, ":ns:", 4))
commit 3bb1c6b04f93841c10d2cb1c4e2945d5a0bb8ff1
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Sep 23 04:03:18 2011 +0200
nspawn: set env var container=systemd-nspawn, following the scheme lxc introduced
diff --git a/src/nspawn.c b/src/nspawn.c
index 6f484e7..8441c05 100644
--- a/src/nspawn.c
+++ b/src/nspawn.c
@@ -727,6 +727,7 @@ int main(int argc, char *argv[]) {
gid_t gid = (gid_t) -1;
const char *envp[] = {
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
+ "container=systemd-nspawn", /* LXC sets container=lxc, so follow the scheme here */
NULL, /* TERM */
NULL, /* HOME */
NULL, /* USER */
@@ -734,7 +735,7 @@ int main(int argc, char *argv[]) {
NULL
};
- envp[1] = strv_find_prefix(environ, "TERM=");
+ envp[2] = strv_find_prefix(environ, "TERM=");
close_nointr_nofail(master);
@@ -830,9 +831,9 @@ int main(int argc, char *argv[]) {
}
}
- if ((asprintf((char**)(envp + 2), "HOME=%s", home? home: "/root") < 0) ||
- (asprintf((char**)(envp + 3), "USER=%s", arg_user? arg_user : "root") < 0) ||
- (asprintf((char**)(envp + 4), "LOGNAME=%s", arg_user? arg_user : "root") < 0)) {
+ if ((asprintf((char**)(envp + 3), "HOME=%s", home? home: "/root") < 0) ||
+ (asprintf((char**)(envp + 4), "USER=%s", arg_user? arg_user : "root") < 0) ||
+ (asprintf((char**)(envp + 5), "LOGNAME=%s", arg_user? arg_user : "root") < 0)) {
log_error("Out of memory");
goto child_fail;
}
commit d77c31f8f39e7a58a8437628df146f4445d710b7
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Sep 23 02:53:55 2011 +0200
loginctl: fix typo
diff --git a/src/loginctl.c b/src/loginctl.c
index 811c3f1..89762b6 100644
--- a/src/loginctl.c
+++ b/src/loginctl.c
@@ -1064,7 +1064,7 @@ static int show(DBusConnection *bus, char **args, unsigned n) {
uint32_t u;
ret = get_user_creds((const char**) (args+i), &uid, NULL, NULL);
- if (r < 0) {
+ if (ret < 0) {
log_error("User %s unknown.", args[i]);
goto finish;
}
commit 3e085b6c59257ca57534afc5044256f2102f9c28
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Sep 23 02:39:54 2011 +0200
llvm-analyze: change a few things to make llvm-analyze show fewer false positives
diff --git a/src/logind.c b/src/logind.c
index 1aad48d..4633a5e 100644
--- a/src/logind.c
+++ b/src/logind.c
@@ -413,6 +413,7 @@ static int manager_enumerate_users_from_cgroup(Manager *m) {
int r = 0;
char *name;
DIR *d;
+ int k;
r = cg_enumerate_subgroups(SYSTEMD_CGROUP_CONTROLLER, m->cgroup_path, &d);
if (r < 0) {
@@ -423,9 +424,8 @@ static int manager_enumerate_users_from_cgroup(Manager *m) {
return r;
}
- while ((r = cg_read_subgroup(d, &name)) > 0) {
+ while ((k = cg_read_subgroup(d, &name)) > 0) {
User *user;
- int k;
k = manager_add_user_by_name(m, name, &user);
if (k < 0) {
@@ -446,6 +446,9 @@ static int manager_enumerate_users_from_cgroup(Manager *m) {
free(name);
}
+ if (r >= 0 && k < 0)
+ r = k;
+
closedir(d);
return r;
diff --git a/src/sysfs-show.c b/src/sysfs-show.c
index ab866a4..b8b356d 100644
--- a/src/sysfs-show.c
+++ b/src/sysfs-show.c
@@ -165,6 +165,9 @@ int show_sysfs(const char *seat, const char *prefix, unsigned n_columns) {
else
r = udev_enumerate_add_match_tag(e, "seat");
+ if (r < 0)
+ goto finish;
+
r = udev_enumerate_scan_devices(e);
if (r < 0)
goto finish;
diff --git a/src/systemctl.c b/src/systemctl.c
index fdff2d1..2bf2b69 100644
--- a/src/systemctl.c
+++ b/src/systemctl.c
@@ -2154,8 +2154,6 @@ static void print_status_info(UnitStatusInfo *i) {
printf(")%s\n", off);
- on = off = NULL;
-
if (i->main_pid == p->pid &&
i->start_timestamp == p->start_timestamp &&
i->exit_timestamp == p->start_timestamp)
diff --git a/src/umount.c b/src/umount.c
index 67be42e..4e036d8 100644
--- a/src/umount.c
+++ b/src/umount.c
@@ -565,10 +565,13 @@ int umount_all(bool *changed) {
/* retry umount, until nothing can be umounted anymore */
do {
umount_changed = false;
- r = mount_points_list_umount(&mp_list_head, &umount_changed, false);
+
+ mount_points_list_umount(&mp_list_head, &umount_changed, false);
if (umount_changed)
*changed = true;
- } while(umount_changed);
+
+ } while (umount_changed);
+
/* umount one more time with logging enabled */
r = mount_points_list_umount(&mp_list_head, &umount_changed, true);
if (r <= 0)
commit de3756ab9916551f3f4f1f360aee59aeed238b5b
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Sep 23 02:39:28 2011 +0200
llvm-analyze: fix some bugs found by llvm-analyze
diff --git a/src/loginctl.c b/src/loginctl.c
index ba8020d..811c3f1 100644
--- a/src/loginctl.c
+++ b/src/loginctl.c
@@ -1063,10 +1063,9 @@ static int show(DBusConnection *bus, char **args, unsigned n) {
uid_t uid;
uint32_t u;
- r = get_user_creds((const char**) (args+i), &uid, NULL, NULL);
+ ret = get_user_creds((const char**) (args+i), &uid, NULL, NULL);
if (r < 0) {
log_error("User %s unknown.", args[i]);
- r = -ENOENT;
goto finish;
}
diff --git a/src/sd-login.c b/src/sd-login.c
index b670d18..a0a56c4 100644
--- a/src/sd-login.c
+++ b/src/sd-login.c
@@ -481,34 +481,39 @@ _public_ int sd_seat_get_sessions(const char *seat, char ***sessions, uid_t **ui
if (uids && t) {
char *w, *state;
size_t l;
- unsigned i = 0;
FOREACH_WORD(w, l, t, state)
n++;
- b = new(uid_t, n);
- if (!b) {
- strv_free(a);
- return -ENOMEM;
- }
+ if (n == 0)
+ b = NULL;
+ else {
+ unsigned i = 0;
- FOREACH_WORD(w, l, t, state) {
- char *k;
-
- k = strndup(w, l);
- if (!k) {
- free(t);
- free(b);
+ b = new(uid_t, n);
+ if (!b) {
strv_free(a);
return -ENOMEM;
}
- r = parse_uid(k, b + i);
- free(k);
- if (r < 0)
- continue;
+ FOREACH_WORD(w, l, t, state) {
+ char *k;
- i++;
+ k = strndup(w, l);
+ if (!k) {
+ free(t);
+ free(b);
+ strv_free(a);
+ return -ENOMEM;
+ }
+
+ r = parse_uid(k, b + i);
+ free(k);
+ if (r < 0)
+ continue;
+
+ i++;
+ }
}
}
diff --git a/src/socket.c b/src/socket.c
index a1b451e..7ddf326 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -1962,6 +1962,12 @@ int socket_collect_fds(Socket *s, int **fds, unsigned *n_fds) {
if (p->fd >= 0)
rn_fds++;
+ if (rn_fds <= 0) {
+ *fds = NULL;
+ *n_fds = 0;
+ return 0;
+ }
+
if (!(rfds = new(int, rn_fds)))
return -ENOMEM;
More information about the systemd-commits
mailing list