[systemd-commits] 4 commits - src/service.c src/systemctl.c src/util.c

Lennart Poettering lennart at kemper.freedesktop.org
Thu Aug 5 10:50:38 PDT 2010


 src/service.c   |   10 +++++++++-
 src/systemctl.c |    3 ++-
 src/util.c      |   16 +++++++++-------
 3 files changed, 20 insertions(+), 9 deletions(-)

New commits:
commit 95978cf8a66b0d03271f7da2399a3b588db0c71d
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Aug 5 19:47:41 2010 +0200

    selinux: minor error handling fix

diff --git a/src/util.c b/src/util.c
index ec5c7ca..ee7749b 100644
--- a/src/util.c
+++ b/src/util.c
@@ -62,11 +62,11 @@
 
 static struct selabel_handle *label_hnd = NULL;
 
-static inline int use_selinux(void) {
+static inline bool use_selinux(void) {
         static int use_selinux_ind = -1;
 
-        if (use_selinux_ind == -1)
-                use_selinux_ind = (is_selinux_enabled() == 1);
+        if (use_selinux_ind < 0)
+                use_selinux_ind = is_selinux_enabled() > 0;
 
         return use_selinux_ind;
 }
@@ -84,6 +84,8 @@ static int label_get_file_label_from_path(
         r = getfilecon(path, &dir_con);
         if (r >= 0) {
                 r = -1;
+                errno = EINVAL;
+
                 if ((sclass = string_to_security_class(class)) != 0)
                         r = security_compute_create((security_context_t) label, dir_con, sclass, fcon);
         }
commit eeaafddcb5ce492f2b3d53678820d41a04ab66b2
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Aug 5 19:46:31 2010 +0200

    service: always sort services from suse B runlevel before services from normal runlevels

diff --git a/src/service.c b/src/service.c
index 7fb3db3..b2e0f86 100644
--- a/src/service.c
+++ b/src/service.c
@@ -292,6 +292,7 @@ static int sysv_fix_order(Service *s) {
         LIST_FOREACH(units_per_type, other, s->meta.manager->units_per_type[UNIT_SERVICE]) {
                 Service *t;
                 UnitDependency d;
+                bool special_s, special_t;
 
                 t = (Service*) other;
 
@@ -307,7 +308,14 @@ static int sysv_fix_order(Service *s) {
                     (!t->sysv_path || t->sysv_has_lsb))
                         continue;
 
-                if (t->sysv_start_priority < s->sysv_start_priority)
+                special_s = s->sysv_runlevels && !chars_intersect(RUNLEVELS_UP, s->sysv_runlevels);
+                special_t = t->sysv_runlevels && !chars_intersect(RUNLEVELS_UP, t->sysv_runlevels);
+
+                if (special_t && !special_s)
+                        d = UNIT_AFTER;
+                else if (special_s && !special_t)
+                        d = UNIT_BEFORE;
+                else if (t->sysv_start_priority < s->sysv_start_priority)
                         d = UNIT_AFTER;
                 else if (t->sysv_start_priority > s->sysv_start_priority)
                         d = UNIT_BEFORE;
commit a042efad57741e90ee78b69c57310858295bf3fc
Author: Michal Schmidt <mschmidt at redhat.com>
Date:   Thu Aug 5 14:00:00 2010 +0200

    reboot: handle -p switch properly
    
    https://bugzilla.redhat.com/show_bug.cgi?id=618678

diff --git a/src/systemctl.c b/src/systemctl.c
index 1640a60..3ca1464 100644
--- a/src/systemctl.c
+++ b/src/systemctl.c
@@ -3933,7 +3933,8 @@ static int halt_parse_argv(int argc, char *argv[]) {
                         break;
 
                 case 'p':
-                        arg_action = ACTION_POWEROFF;
+                        if (arg_action != ACTION_REBOOT)
+                                arg_action = ACTION_POWEROFF;
                         break;
 
                 case ARG_REBOOT:
commit 6319292f15478f763777738c9a98faa99ae819c1
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Aug 5 13:40:16 2010 +0200

    selinux: fix labels only when configured for it

diff --git a/src/util.c b/src/util.c
index 39dca0d..ec5c7ca 100644
--- a/src/util.c
+++ b/src/util.c
@@ -122,7 +122,7 @@ int label_fix(const char *path) {
         struct stat st;
         security_context_t fcon;
 
-        if (!use_selinux())
+        if (!use_selinux() || !label_hnd)
                 return 0;
 
         r = lstat(path, &st);
@@ -147,7 +147,7 @@ int label_fix(const char *path) {
 void label_finish(void) {
 
 #ifdef HAVE_SELINUX
-        if (use_selinux())
+        if (use_selinux() && label_hnd)
                 selabel_close(label_hnd);
 #endif
 }
@@ -270,7 +270,7 @@ static int label_mkdir(
         int r;
         security_context_t fcon = NULL;
 
-        if (use_selinux()) {
+        if (use_selinux() && label_hnd) {
                 if (path[0] == '/') {
                         r = selabel_lookup_raw(label_hnd, &fcon, path, mode);
                 }
@@ -300,7 +300,7 @@ static int label_mkdir(
         r = mkdir(path, mode);
 
 finish:
-        if (use_selinux()) {
+        if (use_selinux() && label_hnd) {
                 setfscreatecon(NULL);
                 freecon(fcon);
         }


More information about the systemd-commits mailing list