[systemd-commits] 6 commits - man/pam_systemd.xml src/device.c src/job.c src/list.h src/manager.c src/pam-module.c src/swap.c src/unit.c src/unit.h src/util.c TODO units/getty at .service.m4 units/serial-getty at .service.m4

Lennart Poettering lennart at kemper.freedesktop.org
Sun Nov 14 14:48:32 PST 2010


 TODO                           |    8 ++-
 man/pam_systemd.xml            |    6 +-
 src/device.c                   |   34 ++++++++++++++++
 src/job.c                      |    8 +++
 src/list.h                     |    3 +
 src/manager.c                  |   87 +++++++++++++++++++++++++++++++++--------
 src/pam-module.c               |   18 ++++----
 src/swap.c                     |   34 ++++++++++++++++
 src/unit.c                     |   43 ++++++++++++++++----
 src/unit.h                     |    5 ++
 src/util.c                     |    2 
 units/getty at .service.m4        |    9 ----
 units/serial-getty at .service.m4 |    9 ----
 13 files changed, 211 insertions(+), 55 deletions(-)

New commits:
commit 6210e7fc31e14159627144f7409eadd3ce0d72b9
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Nov 14 23:47:53 2010 +0100

    manager: always pull 'following' units into transaction

diff --git a/TODO b/TODO
index d02dbd7..645b075 100644
--- a/TODO
+++ b/TODO
@@ -78,12 +78,14 @@
 
 * in the PAM module rely on loginuid to figure out XDG_RUNTIME_DIR
 
+* automatically determine TERM= based on tty name. (TERM=linux vs. TERM=vt100-nav)
+
+* declare /etc/system-release cross-distro standard
+
 Pre v12:
 
 * fsck-root.service/start gets queued twice
 
-* pull in 'following' units in transactions
-
 * fix hotplug transactions
 
 * plymouth agent start loop
diff --git a/src/device.c b/src/device.c
index 7b73110..7cb4ff6 100644
--- a/src/device.c
+++ b/src/device.c
@@ -401,6 +401,39 @@ static Unit *device_following(Unit *u) {
         return UNIT(first);
 }
 
+static int device_following_set(Unit *u, Set **_s) {
+        Device *d = DEVICE(u);
+        Device *other;
+        Set *s;
+        int r;
+
+        assert(d);
+        assert(_s);
+
+        if (!d->same_sysfs_prev && !d->same_sysfs_next) {
+                *_s = NULL;
+                return 0;
+        }
+
+        if (!(s = set_new(NULL, NULL)))
+                return -ENOMEM;
+
+        for (other = d->same_sysfs_next; other; other = other->same_sysfs_next)
+                if ((r = set_put(s, other)) < 0)
+                        goto fail;
+
+        for (other = d->same_sysfs_prev; other; other = other->same_sysfs_prev)
+                if ((r = set_put(s, other)) < 0)
+                        goto fail;
+
+        *_s = s;
+        return 1;
+
+fail:
+        set_free(s);
+        return r;
+}
+
 static void device_shutdown(Manager *m) {
         assert(m);
 
@@ -550,6 +583,7 @@ const UnitVTable device_vtable = {
         .bus_invalidating_properties =  bus_device_invalidating_properties,
 
         .following = device_following,
+        .following_set = device_following_set,
 
         .enumerate = device_enumerate,
         .shutdown = device_shutdown
diff --git a/src/list.h b/src/list.h
index 3cf18f1..2bec8c9 100644
--- a/src/list.h
+++ b/src/list.h
@@ -110,6 +110,9 @@
                 }                                                       \
         } while(false)
 
+#define LIST_JUST_US(name,item)                                         \
+        (!(item)->name##_prev && !(item)->name##_next)                  \
+
 #define LIST_FOREACH(name,i,head)                                       \
         for ((i) = (head); (i); (i) = (i)->name##_next)
 
diff --git a/src/manager.c b/src/manager.c
index 932441c..32cd642 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -1445,6 +1445,22 @@ static int transaction_add_job_and_dependencies(
                 return -ENOMEM;
 
         if (is_new) {
+                Set *following;
+
+                /* If we are following some other unit, make sure we
+                 * add all dependencies of everybody following. */
+                if (unit_following_set(ret->unit, &following) > 0) {
+                        SET_FOREACH(dep, following, i)
+                                if ((r = transaction_add_job_and_dependencies(m, type, dep, ret, false, override, false, e, NULL)) < 0) {
+                                        log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->meta.id, bus_error(e, r));
+
+                                        if (e)
+                                                dbus_error_free(e);
+                                }
+
+                        set_free(following);
+                }
+
                 /* Finally, recursively add in all dependencies. */
                 if (type == JOB_START || type == JOB_RELOAD_OR_START) {
                         SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_REQUIRES], i)
diff --git a/src/swap.c b/src/swap.c
index ddda9e1..6de7928 100644
--- a/src/swap.c
+++ b/src/swap.c
@@ -1162,6 +1162,39 @@ static Unit *swap_following(Unit *u) {
         return UNIT(first);
 }
 
+static int swap_following_set(Unit *u, Set **_set) {
+        Swap *s = SWAP(u);
+        Swap *other;
+        Set *set;
+        int r;
+
+        assert(s);
+        assert(_set);
+
+        if (LIST_JUST_US(same_proc_swaps, s)) {
+                *_set = NULL;
+                return 0;
+        }
+
+        if (!(set = set_new(NULL, NULL)))
+                return -ENOMEM;
+
+        LIST_FOREACH_AFTER(same_proc_swaps, other, s)
+                if ((r = set_put(set, other)) < 0)
+                        goto fail;
+
+        LIST_FOREACH_BEFORE(same_proc_swaps, other, s)
+                if ((r = set_put(set, other)) < 0)
+                        goto fail;
+
+        *_set = set;
+        return 1;
+
+fail:
+        set_free(set);
+        return r;
+}
+
 static void swap_shutdown(Manager *m) {
         assert(m);
 
@@ -1319,6 +1352,7 @@ const UnitVTable swap_vtable = {
         .bus_invalidating_properties =  bus_swap_invalidating_properties,
 
         .following = swap_following,
+        .following_set = swap_following_set,
 
         .enumerate = swap_enumerate,
         .shutdown = swap_shutdown
diff --git a/src/unit.c b/src/unit.c
index ee1dc85..b3a8210 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -2319,6 +2319,18 @@ int unit_kill(Unit *u, KillWho w, KillMode m, int signo, DBusError *error) {
         return UNIT_VTABLE(u)->kill(u, w, m, signo, error);
 }
 
+
+int unit_following_set(Unit *u, Set **s) {
+        assert(u);
+        assert(s);
+
+        if (UNIT_VTABLE(u)->following_set)
+                return UNIT_VTABLE(u)->following_set(u, s);
+
+        *s = NULL;
+        return 0;
+}
+
 static const char* const unit_load_state_table[_UNIT_LOAD_STATE_MAX] = {
         [UNIT_STUB] = "stub",
         [UNIT_LOADED] = "loaded",
diff --git a/src/unit.h b/src/unit.h
index 796aee5..b260dd5 100644
--- a/src/unit.h
+++ b/src/unit.h
@@ -329,6 +329,9 @@ struct UnitVTable {
         /* Return the unit this unit is following */
         Unit *(*following)(Unit *u);
 
+        /* Return the set of units that are following each other */
+        int (*following_set)(Unit *u, Set **s);
+
         /* This is called for each unit type and should be used to
          * enumerate existing devices and load them. However,
          * everything that is loaded here should still stay in
@@ -508,6 +511,8 @@ bool unit_pending_active(Unit *u);
 
 int unit_add_default_target_dependency(Unit *u, Unit *target);
 
+int unit_following_set(Unit *u, Set **s);
+
 UnitType unit_name_to_type(const char *n);
 bool unit_name_is_valid(const char *n, bool template_ok);
 

commit 9381a72403f622f66294ab10315240a4c4fd71cd
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Nov 14 23:27:27 2010 +0100

    util: always highlight distro name

diff --git a/src/util.c b/src/util.c
index f762f97..7f9f2b3 100644
--- a/src/util.c
+++ b/src/util.c
@@ -2996,7 +2996,7 @@ void status_welcome(void) {
         else if (startswith(r, "Fedora"))
                 status_printf("Welcome to \x1B[0;34m%s\x1B[0m!\n", r); /* Blue for Fedora */
         else
-                status_printf("Welcome to %s!\n", r);
+                status_printf("Welcome to \x1B[1m%s\x1B[0m!\n", r); /* Highlight for everything else */
 
         free(r);
 

commit 92ab323c824300683efb11fd43c9d834cea9b9e6
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Nov 14 23:26:53 2010 +0100

    units: make use of agetty mandatory

diff --git a/src/unit.c b/src/unit.c
index a619727..ee1dc85 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -826,6 +826,7 @@ fail:
  */
 int unit_start(Unit *u) {
         UnitActiveState state;
+        Unit *following;
 
         assert(u);
 
@@ -840,16 +841,22 @@ int unit_start(Unit *u) {
         if (UNIT_IS_ACTIVE_OR_RELOADING(state))
                 return -EALREADY;
 
-        /* If it is stopped, but we cannot start it, then fail */
-        if (!UNIT_VTABLE(u)->start)
-                return -EBADR;
-
         /* If the conditions failed, don't do anything at all */
         if (!condition_test_list(u->meta.conditions)) {
                 log_debug("Starting of %s requested but condition failed. Ignoring.", u->meta.id);
                 return -EALREADY;
         }
 
+        /* Forward to the main object, if we aren't it. */
+        if ((following = unit_following(u))) {
+                log_debug("Redirecting start request from %s to %s.", u->meta.id, following->meta.id);
+                return unit_start(following);
+        }
+
+        /* If it is stopped, but we cannot start it, then fail */
+        if (!UNIT_VTABLE(u)->start)
+                return -EBADR;
+
         /* We don't suppress calls to ->start() here when we are
          * already starting, to allow this request to be used as a
          * "hurry up" call, for example when the unit is in some "auto
@@ -859,7 +866,6 @@ int unit_start(Unit *u) {
         unit_add_to_dbus_queue(u);
 
         unit_status_printf(u, "Starting %s...\n", unit_description(u));
-
         return UNIT_VTABLE(u)->start(u);
 }
 
@@ -883,6 +889,7 @@ bool unit_can_isolate(Unit *u) {
  */
 int unit_stop(Unit *u) {
         UnitActiveState state;
+        Unit *following;
 
         assert(u);
 
@@ -890,13 +897,17 @@ int unit_stop(Unit *u) {
         if (UNIT_IS_INACTIVE_OR_FAILED(state))
                 return -EALREADY;
 
+        if ((following = unit_following(u))) {
+                log_debug("Redirecting stop request from %s to %s.", u->meta.id, following->meta.id);
+                return unit_stop(following);
+        }
+
         if (!UNIT_VTABLE(u)->stop)
                 return -EBADR;
 
         unit_add_to_dbus_queue(u);
 
         unit_status_printf(u, "Stopping %s...\n", unit_description(u));
-
         return UNIT_VTABLE(u)->stop(u);
 }
 
@@ -907,6 +918,7 @@ int unit_stop(Unit *u) {
  */
 int unit_reload(Unit *u) {
         UnitActiveState state;
+        Unit *following;
 
         assert(u);
 
@@ -923,6 +935,11 @@ int unit_reload(Unit *u) {
         if (state != UNIT_ACTIVE)
                 return -ENOEXEC;
 
+        if ((following = unit_following(u))) {
+                log_debug("Redirecting reload request from %s to %s.", u->meta.id, following->meta.id);
+                return unit_reload(following);
+        }
+
         unit_add_to_dbus_queue(u);
         return UNIT_VTABLE(u)->reload(u);
 }
diff --git a/units/getty at .service.m4 b/units/getty at .service.m4
index 24247be..11a71d7 100644
--- a/units/getty at .service.m4
+++ b/units/getty at .service.m4
@@ -5,13 +5,6 @@
 #  the Free Software Foundation; either version 2 of the License, or
 #  (at your option) any later version.
 
-m4_ifdef(`TARGET_FEDORA', `m4_define(`GETTY', `/sbin/agetty')')m4_dnl
-m4_ifdef(`TARGET_SUSE', `m4_define(`GETTY', `/sbin/agetty')')m4_dnl
-m4_ifdef(`TARGET_GENTOO', `m4_define(`GETTY', `/sbin/agetty')')m4_dnl
-m4_ifdef(`TARGET_ARCH', `m4_define(`GETTY', `/sbin/agetty')')m4_dnl
-m4_ifdef(`TARGET_DEBIAN', `m4_define(`GETTY', `/sbin/getty')')m4_dnl
-m4_ifdef(`TARGET_UBUNTU', `m4_define(`GETTY', `/sbin/getty')')m4_dnl
-m4_dnl
 [Unit]
 Description=Getty on %I
 BindTo=dev-%i.device
@@ -30,7 +23,7 @@ Before=getty.target
 
 [Service]
 Environment=TERM=linux
-ExecStart=-GETTY %I 38400
+ExecStart=-/sbin/agetty %I 38400
 Restart=always
 RestartSec=0
 UtmpIdentifier=%I
diff --git a/units/serial-getty at .service.m4 b/units/serial-getty at .service.m4
index a8610c8..da9bd19 100644
--- a/units/serial-getty at .service.m4
+++ b/units/serial-getty at .service.m4
@@ -5,13 +5,6 @@
 #  the Free Software Foundation; either version 2 of the License, or
 #  (at your option) any later version.
 
-m4_ifdef(`TARGET_FEDORA', `m4_define(`GETTY', `/sbin/agetty')')m4_dnl
-m4_ifdef(`TARGET_SUSE', `m4_define(`GETTY', `/sbin/agetty')')m4_dnl
-m4_ifdef(`TARGET_GENTOO', `m4_define(`GETTY', `/sbin/agetty')')m4_dnl
-m4_ifdef(`TARGET_ARCH', `m4_define(`GETTY', `/sbin/agetty')')m4_dnl
-m4_ifdef(`TARGET_DEBIAN', `m4_define(`GETTY', `/sbin/getty')')m4_dnl
-m4_ifdef(`TARGET_UBUNTU', `m4_define(`GETTY', `/sbin/getty')')m4_dnl
-m4_dnl
 [Unit]
 Description=Serial Getty on %I
 BindTo=dev-%i.device
@@ -33,7 +26,7 @@ Environment=TERM=vt100-nav
 m4_ifdef(`TARGET_FEDORA',
 ExecStartPre=-/sbin/securetty %I
 )m4_dnl
-ExecStart=-GETTY -s %I 115200,38400,9600
+ExecStart=-/sbin/agetty -s %I 115200,38400,9600
 Restart=always
 RestartSec=0
 UtmpIdentifier=%I

commit 41242c42bfe9b11865a8ceacc021d6a452e671c0
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Nov 14 22:09:57 2010 +0100

    manager: don't fail transaction if adding CONFLICTED_BY job fails

diff --git a/src/manager.c b/src/manager.c
index b1eac57..932441c 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -1448,15 +1448,26 @@ static int transaction_add_job_and_dependencies(
                 /* Finally, recursively add in all dependencies. */
                 if (type == JOB_START || type == JOB_RELOAD_OR_START) {
                         SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_REQUIRES], i)
-                                if ((r = transaction_add_job_and_dependencies(m, JOB_START, dep, ret, true, override, false, e, NULL)) < 0 && r != -EBADR)
-                                        goto fail;
+                                if ((r = transaction_add_job_and_dependencies(m, JOB_START, dep, ret, true, override, false, e, NULL)) < 0) {
+                                        if (r != -EBADR)
+                                                goto fail;
+
+                                        if (e)
+                                                dbus_error_free(e);
+                                }
 
                         SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_BIND_TO], i)
-                                if ((r = transaction_add_job_and_dependencies(m, JOB_START, dep, ret, true, override, false, e, NULL)) < 0 && r != -EBADR)
-                                        goto fail;
+                                if ((r = transaction_add_job_and_dependencies(m, JOB_START, dep, ret, true, override, false, e, NULL)) < 0) {
+
+                                        if (r != -EBADR)
+                                                goto fail;
+
+                                        if (e)
+                                                dbus_error_free(e);
+                                }
 
                         SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_REQUIRES_OVERRIDABLE], i)
-                                if ((r = transaction_add_job_and_dependencies(m, JOB_START, dep, ret, !override, override, false, e, NULL)) < 0 && r != -EBADR) {
+                                if ((r = transaction_add_job_and_dependencies(m, JOB_START, dep, ret, !override, override, false, e, NULL)) < 0) {
                                         log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->meta.id, bus_error(e, r));
 
                                         if (e)
@@ -1472,11 +1483,17 @@ static int transaction_add_job_and_dependencies(
                                 }
 
                         SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_REQUISITE], i)
-                                if ((r = transaction_add_job_and_dependencies(m, JOB_VERIFY_ACTIVE, dep, ret, true, override, false, e, NULL)) < 0 && r != -EBADR)
-                                        goto fail;
+                                if ((r = transaction_add_job_and_dependencies(m, JOB_VERIFY_ACTIVE, dep, ret, true, override, false, e, NULL)) < 0) {
+
+                                        if (r != -EBADR)
+                                                goto fail;
+
+                                        if (e)
+                                                dbus_error_free(e);
+                                }
 
                         SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_REQUISITE_OVERRIDABLE], i)
-                                if ((r = transaction_add_job_and_dependencies(m, JOB_VERIFY_ACTIVE, dep, ret, !override, override, false, e, NULL)) < 0 && r != -EBADR) {
+                                if ((r = transaction_add_job_and_dependencies(m, JOB_VERIFY_ACTIVE, dep, ret, !override, override, false, e, NULL)) < 0) {
                                         log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->meta.id, bus_error(e, r));
 
                                         if (e)
@@ -1484,22 +1501,44 @@ static int transaction_add_job_and_dependencies(
                                 }
 
                         SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_CONFLICTS], i)
-                                if ((r = transaction_add_job_and_dependencies(m, JOB_STOP, dep, ret, true, override, true, e, NULL)) < 0 && r != -EBADR)
-                                        goto fail;
+                                if ((r = transaction_add_job_and_dependencies(m, JOB_STOP, dep, ret, true, override, true, e, NULL)) < 0) {
+
+                                        if (r != -EBADR)
+                                                goto fail;
+
+                                        if (e)
+                                                dbus_error_free(e);
+                                }
 
                         SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_CONFLICTED_BY], i)
-                                if ((r = transaction_add_job_and_dependencies(m, JOB_STOP, dep, ret, false, override, false, e, NULL)) < 0 && r != -EBADR)
-                                        goto fail;
+                                if ((r = transaction_add_job_and_dependencies(m, JOB_STOP, dep, ret, false, override, false, e, NULL)) < 0) {
+                                        log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->meta.id, bus_error(e, r));
+
+                                        if (e)
+                                                dbus_error_free(e);
+                                }
 
                 } else if (type == JOB_STOP || type == JOB_RESTART || type == JOB_TRY_RESTART) {
 
                         SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_REQUIRED_BY], i)
-                                if ((r = transaction_add_job_and_dependencies(m, type, dep, ret, true, override, false, e, NULL)) < 0 && r != -EBADR)
-                                        goto fail;
+                                if ((r = transaction_add_job_and_dependencies(m, type, dep, ret, true, override, false, e, NULL)) < 0) {
+
+                                        if (r != -EBADR)
+                                                goto fail;
+
+                                        if (e)
+                                                dbus_error_free(e);
+                                }
 
                         SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_BOUND_BY], i)
-                                if ((r = transaction_add_job_and_dependencies(m, type, dep, ret, true, override, false, e, NULL)) < 0 && r != -EBADR)
-                                        goto fail;
+                                if ((r = transaction_add_job_and_dependencies(m, type, dep, ret, true, override, false, e, NULL)) < 0) {
+
+                                        if (r != -EBADR)
+                                                goto fail;
+
+                                        if (e)
+                                                dbus_error_free(e);
+                                }
                 }
 
                 /* JOB_VERIFY_STARTED, JOB_RELOAD require no dependency handling */

commit 824a1d590a0ec4d83baa51264a9913a702793230
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Nov 14 21:59:25 2010 +0100

    pam: rename 'no-session' to 'user' cgroup

diff --git a/man/pam_systemd.xml b/man/pam_systemd.xml
index bfcc684..3dc3714 100644
--- a/man/pam_systemd.xml
+++ b/man/pam_systemd.xml
@@ -92,7 +92,7 @@
                         <listitem><para>If
                         <option>create-session=0</option> is set, a new
                         control group
-                        <filename>/user/$USER/no-session</filename>
+                        <filename>/user/$USER/user</filename>
                         is created and the login process moved into
                         it.</para></listitem>
 
@@ -115,7 +115,7 @@
                         remaining processes in the
                         <filename>/user/$USER/$XDG_SESSION_ID</filename>
                         control group are migrated to
-                        <filename>/user/$USER/no-session</filename> and
+                        <filename>/user/$USER/user</filename> and
                         the original control group is
                         removed.</para></listitem>
 
@@ -123,7 +123,7 @@
                         <option>kill-user=1</option> is specified, and
                         no other user session control group remains,
                         except
-                        <filename>/user/$USER/no-session</filename>,
+                        <filename>/user/$USER/user</filename>,
                         all remaining processes in the
                         <filename>/user/$USER</filename> hierarchy
                         are killed and the control group is removed.</para></listitem>
diff --git a/src/pam-module.c b/src/pam-module.c
index 387b77e..5f2df4b 100644
--- a/src/pam-module.c
+++ b/src/pam-module.c
@@ -335,7 +335,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
 
                 r = asprintf(&buf, "/user/%s/%s", username, id);
         } else
-                r = asprintf(&buf, "/user/%s/no-session", username);
+                r = asprintf(&buf, "/user/%s/user", username);
 
         if (r < 0) {
                 r = PAM_BUF_ERR;
@@ -369,7 +369,7 @@ static int session_remains(pam_handle_t *handle, const char *user_path) {
 
         while ((r = cg_read_subgroup(d, &subgroup)) > 0) {
 
-                remains = !streq(subgroup, "no-session");
+                remains = !streq(subgroup, "user");
                 free(subgroup);
 
                 if (remains)
@@ -416,7 +416,7 @@ _public_ PAM_EXTERN int pam_sm_close_session(
                 goto finish;
         }
 
-        /* We are probably still in some session/no-session dir. Move ourselves out of the way as first step */
+        /* We are probably still in some session/user dir. Move ourselves out of the way as first step */
         if ((r = cg_attach(SYSTEMD_CGROUP_CONTROLLER, "/user", 0)) < 0)
                 pam_syslog(handle, LOG_ERR, "Failed to move us away: %s", strerror(-r));
 
@@ -430,7 +430,7 @@ _public_ PAM_EXTERN int pam_sm_close_session(
         if ((id = pam_getenv(handle, "XDG_SESSION_ID")) && created) {
 
                 if (asprintf(&session_path, "/user/%s/%s", username, id) < 0 ||
-                    asprintf(&nosession_path, "/user/%s/no-session", username) < 0) {
+                    asprintf(&nosession_path, "/user/%s/user", username) < 0) {
                         r = PAM_BUF_ERR;
                         goto finish;
                 }
@@ -444,10 +444,10 @@ _public_ PAM_EXTERN int pam_sm_close_session(
                 } else {
                         pam_syslog(handle, LOG_INFO, "Moving remaining processes of user session %s of %s into control group %s.", id, username, nosession_path);
 
-                        /* Migrate processes from session to
-                         * no-session cgroup. First, try to create the
-                         * no-session group in case it doesn't exist
-                         * yet. Also, delete the session group. */
+                        /* Migrate processes from session to user
+                         * cgroup. First, try to create the user group
+                         * in case it doesn't exist yet. Also, delete
+                         * the session group. */
                         create_user_group(handle, nosession_path, pw, false, false);
 
                         if ((r = cg_migrate_recursive(SYSTEMD_CGROUP_CONTROLLER, session_path, nosession_path, false, true)) < 0)
@@ -464,7 +464,7 @@ _public_ PAM_EXTERN int pam_sm_close_session(
         /* Kill user processes not attached to any session */
         if (kill_user && r == 0) {
 
-                /* Kill no-session cgroup */
+                /* Kill user cgroup */
                 if ((r = cg_kill_recursive_and_wait(SYSTEMD_CGROUP_CONTROLLER, user_path, true)) < 0)
                         pam_syslog(handle, LOG_ERR, "Failed to kill user cgroup: %s", strerror(-r));
         } else {

commit 57339f47f17b0268f2d05b5e8adde1b1d842fa48
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Nov 14 21:57:10 2010 +0100

    job: make it possible to wait for devices to be unplugged

diff --git a/TODO b/TODO
index ca39210..d02dbd7 100644
--- a/TODO
+++ b/TODO
@@ -86,7 +86,7 @@ Pre v12:
 
 * fix hotplug transactions
 
-* make it possible to wait for device unplug, i.e. issue "stop" on devices
+* plymouth agent start loop
 
 External:
 
diff --git a/src/job.c b/src/job.c
index 8ab12cd..79189f0 100644
--- a/src/job.c
+++ b/src/job.c
@@ -385,6 +385,9 @@ int job_run_and_invalidate(Job *j) {
 
                 case JOB_START:
                         r = unit_start(j->unit);
+
+                        /* If this unit cannot be started, then simply
+                         * wait */
                         if (r == -EBADR)
                                 r = 0;
                         break;
@@ -402,6 +405,11 @@ int job_run_and_invalidate(Job *j) {
 
                 case JOB_STOP:
                         r = unit_stop(j->unit);
+
+                        /* If this unit cannot stopped, then simply
+                         * wait. */
+                        if (r == -EBADR)
+                                r = 0;
                         break;
 
                 case JOB_RELOAD:
diff --git a/src/unit.c b/src/unit.c
index 410ff9f..a619727 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -1386,9 +1386,9 @@ bool unit_job_is_applicable(Unit *u, JobType j) {
 
         case JOB_VERIFY_ACTIVE:
         case JOB_START:
+        case JOB_STOP:
                 return true;
 
-        case JOB_STOP:
         case JOB_RESTART:
         case JOB_TRY_RESTART:
                 return unit_can_start(u);



More information about the systemd-commits mailing list