[systemd-commits] 7 commits - TODO src/core src/login src/machine units/user at .service.in
Lennart Poettering
lennart at kemper.freedesktop.org
Wed Jul 10 16:58:17 PDT 2013
TODO | 52 +++++++++---------
src/core/execute.c | 17 +++++
src/core/main.c | 8 +-
src/core/shutdown.c | 8 --
src/login/loginctl.c | 135 +++++++++++++++++++++++++++--------------------
src/machine/machinectl.c | 105 ++++++++++++++++++++++++++----------
units/user at .service.in | 3 -
7 files changed, 201 insertions(+), 127 deletions(-)
New commits:
commit 4c5420a0c1429de866c4dfbe2f973cfa241bdbe4
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Jul 11 01:57:09 2013 +0200
units: since we auto-spawn user at .service instances now we don need an [Install] section in it
diff --git a/units/user at .service.in b/units/user at .service.in
index d2d24f1..8f9a3b3 100644
--- a/units/user at .service.in
+++ b/units/user at .service.in
@@ -16,6 +16,3 @@ Type=notify
ExecStart=- at rootlibexecdir@/systemd --user
Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%I/dbus/user_bus_socket
Slice=user-%i.slice
-
-[Install]
-Alias=user@%i.service
commit 049b4474b35d0b854f87b0795a5113665413f6a4
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Jul 11 01:56:45 2013 +0200
update TODO
diff --git a/TODO b/TODO
index 27d5df6..8645161 100644
--- a/TODO
+++ b/TODO
@@ -36,8 +36,6 @@ Fedora 19:
CGroup Rework Completion:
-* user at .service and session-*.scope should get posession of their own cgroups
-
* introduce "mainpid" for scopes
* implement system-wide DefaultCPUAccounting=1 switch (and similar for blockio, memory?)
@@ -56,12 +54,14 @@ CGroup Rework Completion:
* split up BlockIOWeight= and BlockIODeviceWeight=
-* introduce high-level settings for RT budget, swapiness
+* introduce high-level settings for RT budget, swappiness
* man: document new bus apis
Features:
+* do we really need both hasprefix() and startswith()?
+
* when a kernel driver logs in a tight loop we should ratelimit that too.
* journald: when we drop syslog messages because the syslog socket is
commit 8aa75193662d0e18d7c21ee9d546b7f3c8b8bc14
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Jul 11 01:56:12 2013 +0200
core: grant user at .service instances write access to their own cgroup
diff --git a/src/core/execute.c b/src/core/execute.c
index cbeb0ca..50d2d49 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -1258,6 +1258,23 @@ int exec_spawn(ExecCommand *command,
}
}
+#ifdef HAVE_PAM
+ if (cgroup_path && context->user && context->pam_name) {
+ err = cg_set_task_access(SYSTEMD_CGROUP_CONTROLLER, cgroup_path, 0644, uid, gid);
+ if (err < 0) {
+ r = EXIT_CGROUP;
+ goto fail_child;
+ }
+
+
+ err = cg_set_group_access(SYSTEMD_CGROUP_CONTROLLER, cgroup_path, 0755, uid, gid);
+ if (err < 0) {
+ r = EXIT_CGROUP;
+ goto fail_child;
+ }
+ }
+#endif
+
if (apply_permissions) {
err = enforce_groups(context, username, gid);
if (err < 0) {
commit befb5b6a71c175d523644edbddd01b4b722fe956
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Jul 11 00:48:52 2013 +0200
core: rearrange if blocks a bit
diff --git a/src/core/main.c b/src/core/main.c
index 0ba1d15..7493975 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1515,12 +1515,7 @@ int main(int argc, char *argv[]) {
/* All other variables are left as is, so that clients
* can still read them via /proc/1/environ */
- }
-
- /* Move out of the way, so that we won't block unmounts */
- assert_se(chdir("/") == 0);
- if (arg_running_as == SYSTEMD_SYSTEM) {
/* Become a session leader if we aren't one yet. */
setsid();
@@ -1528,6 +1523,9 @@ int main(int argc, char *argv[]) {
umask(0);
}
+ /* Move out of the way, so that we won't block unmounts */
+ assert_se(chdir("/") == 0);
+
/* Make sure D-Bus doesn't fiddle with the SIGPIPE handlers */
dbus_connection_set_change_sigpipe(FALSE);
commit f6940be7825755d77ade4cd42231aab9e3580623
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Jul 11 00:35:01 2013 +0200
shutdown: avoid malloc() if we can
diff --git a/src/core/shutdown.c b/src/core/shutdown.c
index fe7a073..10a52bd 100644
--- a/src/core/shutdown.c
+++ b/src/core/shutdown.c
@@ -145,13 +145,7 @@ int main(int argc, char *argv[]) {
size_t l;
FOREACH_WORD_QUOTED(w, l, line, state) {
- _cleanup_free_ char *word;
-
- word = strndup(w, l);
- if (!word)
- break;
-
- if (streq(word, "quiet")) {
+ if (l == 5 && memcmp(w, "quiet", 5) == 0) {
log_set_max_level(LOG_WARNING);
break;
}
commit bafb15bab99887d1b6b8a35136531bac6c3876a6
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Jul 11 00:28:35 2013 +0200
update TODO
diff --git a/TODO b/TODO
index 420f0cc..27d5df6 100644
--- a/TODO
+++ b/TODO
@@ -34,6 +34,32 @@ Fedora 19:
* when installing fedora with yum --installroot /var/run is a directory, not a symlink
+CGroup Rework Completion:
+
+* user at .service and session-*.scope should get posession of their own cgroups
+
+* introduce "mainpid" for scopes
+
+* implement system-wide DefaultCPUAccounting=1 switch (and similar for blockio, memory?)
+
+* implement per-slice CPUFairScheduling=1 switch
+
+* handle jointly mounted controllers correctly
+
+* logind: implement session kill exceptions
+
+* fix machine regstration to forward property array
+
+* add implicit slice for instantiated services
+
+* make BlockIODeviceWeight=, BlockIODeviceBandwidth= runtime settable
+
+* split up BlockIOWeight= and BlockIODeviceWeight=
+
+* introduce high-level settings for RT budget, swapiness
+
+* man: document new bus apis
+
Features:
* when a kernel driver logs in a tight loop we should ratelimit that too.
@@ -48,46 +74,20 @@ Features:
* load .d/*.conf dropins for device units
-* user at .service and session-*.scope should get posession of their own cgroups
-
* move systemctl set-log-level to systemd-analyze?
-* fix killing spree logic in systemd-user-sessions
-
-* logind: implement session kill exceptions
-
-* fix machine regstration to forward property array
-
-* fix loginctl cgroup enumeration
-
* move "systemctl dump" to systemd-analyze
-* introduce "mainpid" for scopes
-
* add a fixed dbus path for "my own unit", "my own session", ... to PID1, logind, ...
-* add implicit slice for instantiated services
-
* service_coldplug() appears to reinstall the wrong stop timeout watch?
* transient units: allow creating auxiliary units with the same call
-* make BlockIODeviceWeight=, BlockIODeviceBandwidth= runtime settable
-
-* split up BlockIOWeight= and BlockIODeviceWeight=
-
-* introduce high-level settings for RT budget, swapiness
-
* how to reset dynamically changed attributes sanely?
* when reloading configuration, apply new cgroup configuration
-* implement system-wide DefaultCPUAccounting=1 switch (and similar for blockio, memory?)
-
-* implement per-slice CPUFairScheduling=1 switch
-
-* handle jointly mounted controllers correctly
-
* journald: make sure ratelimit is actually really per-service with the new cgroup changes
* libsystemd-logind: sd_session_is_active() and friends: verify
commit aa1936ea1a89c2bb968ba33e3274898a4eeae771
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Jul 11 00:27:54 2013 +0200
loginctl: restore cgroup display for status output
Same for machinectl.
diff --git a/src/login/loginctl.c b/src/login/loginctl.c
index e118def..93f4bee 100644
--- a/src/login/loginctl.c
+++ b/src/login/loginctl.c
@@ -34,6 +34,7 @@
#include "dbus-common.h"
#include "build.h"
#include "strv.h"
+#include "unit-name.h"
#include "cgroup-show.h"
#include "sysfs-show.h"
#include "spawn-polkit-agent.h"
@@ -261,12 +262,76 @@ static int list_seats(DBusConnection *bus, char **args, unsigned n) {
return 0;
}
+static int show_unit_cgroup(DBusConnection *bus, const char *interface, const char *unit) {
+ const char *property = "ControlGroup";
+ _cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
+ _cleanup_free_ char *path = NULL;
+ DBusMessageIter iter, sub;
+ const char *cgroup;
+ DBusError error;
+ int r, output_flags;
+ unsigned c;
+
+ assert(bus);
+ assert(unit);
+
+ if (arg_transport == TRANSPORT_SSH)
+ return 0;
+
+ path = unit_dbus_path_from_name(unit);
+ if (!path)
+ return log_oom();
+
+ r = bus_method_call_with_reply(
+ bus,
+ "org.freedesktop.systemd1",
+ path,
+ "org.freedesktop.DBus.Properties",
+ "Get",
+ &reply,
+ &error,
+ DBUS_TYPE_STRING, &interface,
+ DBUS_TYPE_STRING, &property,
+ DBUS_TYPE_INVALID);
+ if (r < 0) {
+ log_error("Failed to query ControlGroup: %s", bus_error(&error, r));
+ dbus_error_free(&error);
+ return r;
+ }
+
+ if (!dbus_message_iter_init(reply, &iter) ||
+ dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT) {
+ log_error("Failed to parse reply.");
+ return -EINVAL;
+ }
+
+ dbus_message_iter_recurse(&iter, &sub);
+ if (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_STRING) {
+ log_error("Failed to parse reply.");
+ return -EINVAL;
+ }
+
+ dbus_message_iter_get_basic(&sub, &cgroup);
+
+ output_flags =
+ arg_all * OUTPUT_SHOW_ALL |
+ arg_full * OUTPUT_FULL_WIDTH;
+
+ c = columns();
+ if (c > 18)
+ c -= 18;
+ else
+ c = 0;
+
+ show_cgroup_by_path(cgroup, "\t\t ", c, false, output_flags);
+ return 0;
+}
+
typedef struct SessionStatusInfo {
const char *id;
uid_t uid;
const char *name;
usec_t timestamp;
- const char *default_control_group;
int vtnr;
const char *seat;
const char *tty;
@@ -279,14 +344,13 @@ typedef struct SessionStatusInfo {
const char *type;
const char *class;
const char *state;
- const char *slice;
+ const char *scope;
} SessionStatusInfo;
typedef struct UserStatusInfo {
uid_t uid;
const char *name;
usec_t timestamp;
- const char *default_control_group;
const char *state;
char **sessions;
const char *display;
@@ -299,7 +363,7 @@ typedef struct SeatStatusInfo {
char **sessions;
} SeatStatusInfo;
-static void print_session_status_info(SessionStatusInfo *i) {
+static void print_session_status_info(DBusConnection *bus, SessionStatusInfo *i) {
char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
char since2[FORMAT_TIMESTAMP_MAX], *s2;
assert(i);
@@ -375,33 +439,13 @@ static void print_session_status_info(SessionStatusInfo *i) {
if (i->state)
printf("\t State: %s\n", i->state);
- if (i->slice)
- printf("\t Slice: %s\n", i->slice);
-
- if (i->default_control_group) {
- unsigned c;
- int output_flags =
- arg_all * OUTPUT_SHOW_ALL |
- arg_full * OUTPUT_FULL_WIDTH;
-
- printf("\t CGroup: %s\n", i->default_control_group);
-
- if (arg_transport != TRANSPORT_SSH) {
- c = columns();
- if (c > 18)
- c -= 18;
- else
- c = 0;
-
- show_cgroup_and_extra_by_spec(i->default_control_group,
- "\t\t ", c, false, &i->leader,
- i->leader > 0 ? 1 : 0,
- output_flags);
- }
+ if (i->scope) {
+ printf("\t Unit: %s\n", i->scope);
+ show_unit_cgroup(bus, "org.freedesktop.systemd1.Scope", i->scope);
}
}
-static void print_user_status_info(UserStatusInfo *i) {
+static void print_user_status_info(DBusConnection *bus, UserStatusInfo *i) {
char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
char since2[FORMAT_TIMESTAMP_MAX], *s2;
assert(i);
@@ -422,8 +466,6 @@ static void print_user_status_info(UserStatusInfo *i) {
if (!isempty(i->state))
printf("\t State: %s\n", i->state);
- if (i->slice)
- printf("\t Slice: %s\n", i->slice);
if (!strv_isempty(i->sessions)) {
char **l;
@@ -439,24 +481,9 @@ static void print_user_status_info(UserStatusInfo *i) {
printf("\n");
}
- if (i->default_control_group) {
- unsigned c;
- int output_flags =
- arg_all * OUTPUT_SHOW_ALL |
- arg_full * OUTPUT_FULL_WIDTH;
-
- printf("\t CGroup: %s\n", i->default_control_group);
-
- if (arg_transport != TRANSPORT_SSH) {
- c = columns();
- if (c > 18)
- c -= 18;
- else
- c = 0;
-
- show_cgroup_by_path(i->default_control_group, "\t\t ",
- c, false, output_flags);
- }
+ if (i->slice) {
+ printf("\t Unit: %s\n", i->slice);
+ show_unit_cgroup(bus, "org.freedesktop.systemd1.Slice", i->slice);
}
}
@@ -511,8 +538,6 @@ static int status_property_session(const char *name, DBusMessageIter *iter, Sess
i->id = s;
else if (streq(name, "Name"))
i->name = s;
- else if (streq(name, "DefaultControlGroup"))
- i->default_control_group = s;
else if (streq(name, "TTY"))
i->tty = s;
else if (streq(name, "Display"))
@@ -527,8 +552,8 @@ static int status_property_session(const char *name, DBusMessageIter *iter, Sess
i->type = s;
else if (streq(name, "Class"))
i->class = s;
- else if (streq(name, "Slice"))
- i->slice = s;
+ else if (streq(name, "Scope"))
+ i->scope = s;
else if (streq(name, "State"))
i->state = s;
}
@@ -612,8 +637,6 @@ static int status_property_user(const char *name, DBusMessageIter *iter, UserSta
if (!isempty(s)) {
if (streq(name, "Name"))
i->name = s;
- else if (streq(name, "DefaultControlGroup"))
- i->default_control_group = s;
else if (streq(name, "Slice"))
i->slice = s;
else if (streq(name, "State"))
@@ -924,9 +947,9 @@ static int show_one(const char *verb, DBusConnection *bus, const char *path, boo
if (!show_properties) {
if (strstr(verb, "session"))
- print_session_status_info(&session_info);
+ print_session_status_info(bus, &session_info);
else if (strstr(verb, "user"))
- print_user_status_info(&user_info);
+ print_user_status_info(bus, &user_info);
else
print_seat_status_info(&seat_info);
}
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index 34bbe36..cd640e7 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -34,6 +34,7 @@
#include "dbus-common.h"
#include "build.h"
#include "strv.h"
+#include "unit-name.h"
#include "cgroup-show.h"
#include "spawn-polkit-agent.h"
@@ -124,19 +125,84 @@ static int list_machines(DBusConnection *bus, char **args, unsigned n) {
return 0;
}
+static int show_scope_cgroup(DBusConnection *bus, const char *unit) {
+ const char *interface = "org.freedesktop.systemd1.Scope";
+ const char *property = "ControlGroup";
+ _cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
+ _cleanup_free_ char *path = NULL;
+ DBusMessageIter iter, sub;
+ const char *cgroup;
+ DBusError error;
+ int r, output_flags;
+ unsigned c;
+
+ assert(bus);
+ assert(unit);
+
+ if (arg_transport == TRANSPORT_SSH)
+ return 0;
+
+ path = unit_dbus_path_from_name(unit);
+ if (!path)
+ return log_oom();
+
+ r = bus_method_call_with_reply(
+ bus,
+ "org.freedesktop.systemd1",
+ path,
+ "org.freedesktop.DBus.Properties",
+ "Get",
+ &reply,
+ &error,
+ DBUS_TYPE_STRING, &interface,
+ DBUS_TYPE_STRING, &property,
+ DBUS_TYPE_INVALID);
+ if (r < 0) {
+ log_error("Failed to query ControlGroup: %s", bus_error(&error, r));
+ dbus_error_free(&error);
+ return r;
+ }
+
+ if (!dbus_message_iter_init(reply, &iter) ||
+ dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT) {
+ log_error("Failed to parse reply.");
+ return -EINVAL;
+ }
+
+ dbus_message_iter_recurse(&iter, &sub);
+ if (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_STRING) {
+ log_error("Failed to parse reply.");
+ return -EINVAL;
+ }
+
+ dbus_message_iter_get_basic(&sub, &cgroup);
+
+ output_flags =
+ arg_all * OUTPUT_SHOW_ALL |
+ arg_full * OUTPUT_FULL_WIDTH;
+
+ c = columns();
+ if (c > 18)
+ c -= 18;
+ else
+ c = 0;
+
+ show_cgroup_by_path(cgroup, "\t\t ", c, false, output_flags);
+ return 0;
+}
+
typedef struct MachineStatusInfo {
const char *name;
sd_id128_t id;
- const char *default_control_group;
const char *class;
const char *service;
- const char *slice;
+ const char *scope;
const char *root_directory;
pid_t leader;
usec_t timestamp;
} MachineStatusInfo;
-static void print_machine_status_info(MachineStatusInfo *i) {
+static void print_machine_status_info(DBusConnection *bus, MachineStatusInfo *i) {
char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
char since2[FORMAT_TIMESTAMP_MAX], *s2;
assert(i);
@@ -178,31 +244,12 @@ static void print_machine_status_info(MachineStatusInfo *i) {
} else if (i->class)
printf("\t Class: %s\n", i->class);
- if (i->slice)
- printf("\t Slice: %s\n", i->slice);
if (i->root_directory)
printf("\t Root: %s\n", i->root_directory);
- if (i->default_control_group) {
- unsigned c;
- int output_flags =
- arg_all * OUTPUT_SHOW_ALL |
- arg_full * OUTPUT_FULL_WIDTH;
-
- printf("\t CGroup: %s\n", i->default_control_group);
-
- if (arg_transport != TRANSPORT_SSH) {
- c = columns();
- if (c > 18)
- c -= 18;
- else
- c = 0;
-
- show_cgroup_and_extra_by_spec(i->default_control_group,
- "\t\t ", c, false, &i->leader,
- i->leader > 0 ? 1 : 0,
- output_flags);
- }
+ if (i->scope) {
+ printf("\t Unit: %s\n", i->scope);
+ show_scope_cgroup(bus, i->scope);
}
}
@@ -221,14 +268,12 @@ static int status_property_machine(const char *name, DBusMessageIter *iter, Mach
if (!isempty(s)) {
if (streq(name, "Name"))
i->name = s;
- else if (streq(name, "DefaultControlGroup"))
- i->default_control_group = s;
else if (streq(name, "Class"))
i->class = s;
else if (streq(name, "Service"))
i->service = s;
- else if (streq(name, "Slice"))
- i->slice = s;
+ else if (streq(name, "Scope"))
+ i->scope = s;
else if (streq(name, "RootDirectory"))
i->root_directory = s;
}
@@ -373,7 +418,7 @@ static int show_one(const char *verb, DBusConnection *bus, const char *path, boo
}
if (!show_properties)
- print_machine_status_info(&machine_info);
+ print_machine_status_info(bus, &machine_info);
r = 0;
More information about the systemd-commits
mailing list