[systemd-commits] 3 commits - TODO src/core src/sysv-generator

Lennart Poettering lennart at kemper.freedesktop.org
Tue Jan 27 17:22:25 PST 2015


 TODO                                |    4 ++++
 src/core/manager.c                  |   16 +++++++++++++++-
 src/core/manager.h                  |   10 +++++++---
 src/core/unit-printf.c              |    2 +-
 src/sysv-generator/sysv-generator.c |   14 ++++++--------
 5 files changed, 33 insertions(+), 13 deletions(-)

New commits:
commit 4b42934665bf14055c82e9ea73b0cb450b3bc467
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jan 28 02:22:19 2015 +0100

    update TODO

diff --git a/TODO b/TODO
index 7f5db20..d3b4b1d 100644
--- a/TODO
+++ b/TODO
@@ -31,6 +31,10 @@ External:
 
 Features:
 
+* add test targets to Makefile that runs all our tools with "--help"
+  and checks if the output is identical to the output when passed
+  through "fold -w 79".
+
 * nspawn: emulate /dev/kmsg using CUSE and turn off the syslog syscall
   with seccomp. That should provide us with a useful log buffer that
   systemd can log to during early boot, and disconnect container logs

commit 2e5c94b9aaefce46835b623e800cfc168995ea3f
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jan 28 02:18:59 2015 +0100

    core: when the user hits Ctrl-Alt-Del more than 7x per 2s, reboot immediately
    
    This should be useful for cases where clean rebooting doesn't work, and
    the user wants to hurry up the reboot.

diff --git a/src/core/manager.c b/src/core/manager.c
index e2df911..336ec1e 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -549,6 +549,9 @@ int manager_new(SystemdRunningAs running_as, bool test_run, Manager **_m) {
 
         m->test_run = test_run;
 
+        /* Reboot immediately if the user hits C-A-D more often than 7x per 2s */
+        RATELIMIT_INIT(m->ctrl_alt_del_ratelimit, 2 * USEC_PER_SEC, 7);
+
         r = manager_default_environment(m);
         if (r < 0)
                 goto fail;
@@ -1721,7 +1724,18 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
 
                 case SIGINT:
                         if (m->running_as == SYSTEMD_SYSTEM) {
-                                manager_start_target(m, SPECIAL_CTRL_ALT_DEL_TARGET, JOB_REPLACE_IRREVERSIBLY);
+
+                                /* If the user presses C-A-D too more
+                                 * than 7 times within 2s, we reboot
+                                 * immediately. */
+
+                                if (ratelimit_test(&m->ctrl_alt_del_ratelimit))
+                                        manager_start_target(m, SPECIAL_CTRL_ALT_DEL_TARGET, JOB_REPLACE_IRREVERSIBLY);
+                                else {
+                                        log_notice("Ctrl-Alt-Del was pressed more than 7 times within 2s, rebooting immediately.");
+                                        m->exit_code = MANAGER_REBOOT;
+                                }
+
                                 break;
                         }
 
diff --git a/src/core/manager.h b/src/core/manager.h
index 19fb0a9..d3971f1 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -29,6 +29,10 @@
 #include "sd-event.h"
 #include "fdset.h"
 #include "cgroup-util.h"
+#include "hashmap.h"
+#include "list.h"
+#include "set.h"
+#include "ratelimit.h"
 
 /* Enforce upper limit how many names we allow */
 #define MANAGER_MAX_NAMES 131072 /* 128K */
@@ -68,9 +72,6 @@ typedef enum StatusType {
 
 #include "unit.h"
 #include "job.h"
-#include "hashmap.h"
-#include "list.h"
-#include "set.h"
 #include "path-lookup.h"
 #include "execute.h"
 #include "unit-name.h"
@@ -295,6 +296,9 @@ struct Manager {
 
         /* Used for processing polkit authorization responses */
         Hashmap *polkit_registry;
+
+        /* When the user hits C-A-D more than 7 times per 2s, reboot immediately... */
+        RateLimit ctrl_alt_del_ratelimit;
 };
 
 int manager_new(SystemdRunningAs running_as, bool test_run, Manager **m);
diff --git a/src/core/unit-printf.c b/src/core/unit-printf.c
index 62599d0..97135db 100644
--- a/src/core/unit-printf.c
+++ b/src/core/unit-printf.c
@@ -19,7 +19,7 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include "systemd/sd-id128.h"
+#include "sd-id128.h"
 #include "unit.h"
 #include "specifier.h"
 #include "path-util.h"

commit a986501b9059b72e8deced262554fbdd1ab9da17
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jan 28 01:36:40 2015 +0100

    sysv-generator: there's really no need to invoke fstatat() multiple times on the same sysv script
    
    It's sufficient to check once if something is a regular file, hence,
    let's do that.

diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
index 984beab..09ade0d 100644
--- a/src/sysv-generator/sysv-generator.c
+++ b/src/sysv-generator/sysv-generator.c
@@ -749,12 +749,10 @@ static int enumerate_sysv(LookupPaths lp, Hashmap *all_services) {
                         struct stat st;
                         int r;
 
-                        dirent_ensure_type(d, de);
-
-                        if (!dirent_is_file(de))
-                            continue;
+                        if (hidden_file(de->d_name))
+                                continue;
 
-                        if (fstatat(dirfd(d), de->d_name, &st, 0) < 0) {
+                        if (fstatat(dirfd(d), de->d_name, &st, AT_SYMLINK_NOFOLLOW) < 0) {
                                 log_warning_errno(errno, "stat() failed on %s/%s: %m", *path, de->d_name);
                                 continue;
                         }
@@ -769,13 +767,13 @@ static int enumerate_sysv(LookupPaths lp, Hashmap *all_services) {
                         if (!name)
                                 return log_oom();
 
+                        if (hashmap_contains(all_services, name))
+                                continue;
+
                         fpath = strjoin(*path, "/", de->d_name, NULL);
                         if (!fpath)
                                 return log_oom();
 
-                        if (hashmap_contains(all_services, name))
-                                continue;
-
                         service = new0(SysvStub, 1);
                         if (!service)
                                 return log_oom();



More information about the systemd-commits mailing list