]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/selinux-utils: tiny cleanup
authorKarel Zak <kzak@redhat.com>
Wed, 13 Jan 2021 14:04:02 +0000 (15:04 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 13 Jan 2021 14:04:02 +0000 (15:04 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/selinux-utils.c
login-utils/chfn.c

index 79425b1cfbb94aa5b0117bc94614e9d8a17faf90..c0df8912046a754d7dd17cf46247f9cf8ca6643e 100644 (file)
 
 #include "selinux-utils.h"
 
+/* set the SELinux security context used for _creating_ a new file system object
+ *
+ * returns 0 on success,
+ *     or <0 on error
+ */
 int ul_setfscreatecon_from_file(char *orig_file)
 {
        if (is_selinux_enabled() > 0) {
                char *scontext = NULL;
 
                if (getfilecon(orig_file, &scontext) < 0)
-                       return 1;
+                       return -1;
                if (setfscreatecon(scontext) < 0) {
                        freecon(scontext);
-                       return 1;
+                       return -1;
                }
                freecon(scontext);
        }
@@ -54,8 +59,10 @@ int ul_selinux_has_access(const char *classstr, const char *perm, char **user_cx
        return rc == 0 ? 1 : 0;
 }
 
-/* return 0 on success, 0 on error; @cxt returns the default context for @path
- * and @st_mode (stat())
+/* Gets the default context for @path and @st_mode.
+ *
+ * returns 0 on success,
+ *     or <0 on error
  */
 int ul_selinux_get_default_context(const char *path, int st_mode, char **cxt)
 {
index 80ee7f9eb9218152b5c10047ed1c390411352f6c..2508e14c9db84b25635f1a04adb775db9c834ee4 100644 (file)
@@ -447,7 +447,7 @@ int main(int argc, char **argv)
                             user_cxt ? : _("Unknown user context"),
                             ctl.username);
 
-               if (ul_setfscreatecon_from_file(_PATH_PASSWD))
+               if (ul_setfscreatecon_from_file(_PATH_PASSWD) != 0)
                        errx(EXIT_FAILURE,
                             _("can't set default context for %s"), _PATH_PASSWD);
        }