diff options
author | Karel Zak | 2006-12-07 00:26:14 +0100 |
---|---|---|
committer | Karel Zak | 2006-12-07 00:26:14 +0100 |
commit | d03dd60840f0a08464d5266539ad356aefe24b03 (patch) | |
tree | 0a9ad240a7a88eb6b11b152974a7a51a0df79b75 /login-utils/vipw.c | |
parent | Imported from util-linux-2.12pre tarball. (diff) | |
download | kernel-qcow2-util-linux-d03dd60840f0a08464d5266539ad356aefe24b03.tar.gz kernel-qcow2-util-linux-d03dd60840f0a08464d5266539ad356aefe24b03.tar.xz kernel-qcow2-util-linux-d03dd60840f0a08464d5266539ad356aefe24b03.zip |
Imported from util-linux-2.12a tarball.
Diffstat (limited to 'login-utils/vipw.c')
-rw-r--r-- | login-utils/vipw.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/login-utils/vipw.c b/login-utils/vipw.c index cb4048070..22f87428e 100644 --- a/login-utils/vipw.c +++ b/login-utils/vipw.c @@ -67,6 +67,10 @@ static char version_string[] = "vipw 1.4"; #include "xstrncpy.h" #include "nls.h" +#ifdef WITH_SELINUX +#include <selinux/selinux.h> +#endif + #define FILENAMELEN 67 char *progname; @@ -189,6 +193,24 @@ pw_unlock(void) { sprintf(tmp, "%s%s", orig_file, ".OLD"); unlink(tmp); link(orig_file, tmp); + +#ifdef WITH_SELINUX + if (is_selinux_enabled()) { + security_context_t passwd_context=NULL; + int ret=0; + if (getfilecon(orig_file,&passwd_context) < 0) { + (void) fprintf(stderr,_("%s: Can't get context for %s"),progname,orig_file); + pw_error(orig_file, 1, 1); + } + ret=setfilecon(tmp_file,passwd_context); + freecon(passwd_context); + if (ret!=0) { + (void) fprintf(stderr,_("%s: Can't set context for %s"),progname,tmp_file); + pw_error(tmp_file, 1, 1); + } + } +#endif + if (rename(tmp_file, orig_file) == -1) { int errsv = errno; fprintf(stderr, @@ -266,7 +288,9 @@ edit_file(int is_shadow) if (stat(tmp_file, &begin)) pw_error(tmp_file, 1, 1); + pw_edit(0); + if (stat(tmp_file, &end)) pw_error(tmp_file, 1, 1); if (begin.st_mtime == end.st_mtime) { |