]> granicus.if.org Git - shadow/commitdiff
selinux_checked, selinux_enabled, and set_orig are now booleans.
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sun, 25 May 2008 23:45:21 +0000 (23:45 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sun, 25 May 2008 23:45:21 +0000 (23:45 +0000)
ChangeLog
libmisc/copydir.c

index ad97a96e3c2606dfcafd106ae5d68add1e450fa9..231e7c9d62ca78947be13f4cc80ebf441b8f4051 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-05-26  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * libmisc/copydir.c: selinux_checked, selinux_enabled, and set_orig
+       are now booleans.
+
 2008-05-26  Nicolas François  <nicolas.francois@centraliens.net>
 
        * libmisc/setugid.c (setup_uid_gid): The is_console argument is now
index b30df3d27dd8903c300a09c9f8a4dd81ff3d6ef2..4d53a5be836c18160caf5325d2042c72d878e7d0 100644 (file)
@@ -43,7 +43,6 @@
 #include "defines.h"
 #ifdef WITH_SELINUX
 #include <selinux/selinux.h>
-static int selinux_enabled = -1;
 #endif
 static const char *src_orig;
 static const char *dst_orig;
@@ -87,11 +86,15 @@ static int copy_file (const char *src, const char *dst,
  */
 static int selinux_file_context (const char *dst_name)
 {
+       static bool selinux_checked = false;
+       static bool selinux_enabled;
        security_context_t scontext = NULL;
 
-       if (selinux_enabled < 0) {
+       if (!selinux_checked) {
                selinux_enabled = is_selinux_enabled () > 0;
+               selinux_checked = true;
        }
+
        if (selinux_enabled) {
                /* Get the default security context for this file */
                if (matchpathcon (dst_name, 0, &scontext) < 0) {
@@ -189,7 +192,7 @@ int copy_tree (const char *src_root, const char *dst_root,
        char src_name[1024];
        char dst_name[1024];
        int err = 0;
-       int set_orig = 0;
+       bool set_orig = false;
        struct DIRECT *ent;
        DIR *dir;
 
@@ -216,10 +219,10 @@ int copy_tree (const char *src_root, const char *dst_root,
                return -1;
        }
 
-       if (src_orig == 0) {
+       if (src_orig == NULL) {
                src_orig = src_root;
                dst_orig = dst_root;
-               set_orig++;
+               set_orig = true;
        }
        while ((0 == err) && (ent = readdir (dir)) != NULL) {
                /*
@@ -253,8 +256,8 @@ int copy_tree (const char *src_root, const char *dst_root,
        (void) closedir (dir);
 
        if (set_orig) {
-               src_orig = 0;
-               dst_orig = 0;
+               src_orig = NULL;
+               dst_orig = NULL;
        }
        return err;
 }