diff options
| author | Robert Watson <rwatson@FreeBSD.org> | 2002-10-23 03:17:22 +0000 |
|---|---|---|
| committer | Robert Watson <rwatson@FreeBSD.org> | 2002-10-23 03:17:22 +0000 |
| commit | 84333872d83f830bd84559cf2e16dfc6bdde15df (patch) | |
| tree | 1567e6a109bf117650371bf67a377dd3995f0716 | |
| parent | 5b38a427c0c19994a726e7591032b18c9e3cdb48 (diff) | |
Notes
| -rw-r--r-- | lib/libutil/login_class.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/libutil/login_class.c b/lib/libutil/login_class.c index 3930c03032da..219db5881856 100644 --- a/lib/libutil/login_class.c +++ b/lib/libutil/login_class.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include <login_cap.h> #include <paths.h> #include <sys/rtprio.h> +#include <sys/mac.h> static struct login_res { @@ -317,6 +318,7 @@ setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid, unsigned in #ifndef __NETBSD_SYSCALLS struct rtprio rtp; #endif + int error; if (lc == NULL) { if (pwd != NULL && (lc = login_getpwclass(pwd)) != NULL) @@ -374,6 +376,31 @@ setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid, unsigned in } } + /* Set up the user's MAC label. */ + if ((flags & LOGIN_SETMAC) && mac_is_present(NULL) == 1) { + const char *label_string; + mac_t label; + + label_string = login_getcapstr(lc, "label", NULL, NULL); + if (label_string != NULL) { + if (mac_from_text(&label, label_string) == -1) { + syslog(LOG_ERR, "mac_from_text('%s') for %s: %m", + pwd->pw_name, label_string); + return -1; + } + if (mac_set_proc(label) == -1) + error = errno; + else + error = 0; + mac_free(label); + if (error != 0) { + syslog(LOG_ERR, "mac_set_proc('%s') for %s: %s", + label_string, pwd->pw_name, strerror(error)); + return -1; + } + } + } + /* Set the sessions login */ if ((flags & LOGIN_SETLOGIN) && setlogin(pwd->pw_name) != 0) { syslog(LOG_ERR, "setlogin(%s): %m", pwd->pw_name); |
