diff --git a/lib/selinux-utils.c b/lib/selinux-utils.c index 79425b1cf..c0df89120 100644 --- a/lib/selinux-utils.c +++ b/lib/selinux-utils.c @@ -14,16 +14,21 @@ #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) { diff --git a/login-utils/chfn.c b/login-utils/chfn.c index 80ee7f9eb..2508e14c9 100644 --- a/login-utils/chfn.c +++ b/login-utils/chfn.c @@ -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); }