summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2014-07-13 13:35:33 -0700
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-13 21:10:56 -0400
commita334cbba7222d3d7d886c17c828fa4227c656535 (patch)
tree7bd2e9fec41269687707b208fdb57d4c50712766
parent3864c28549d742427fdf33026e522e9f10a7e4ec (diff)
sysusers: preserve label of /etc/{passwd, group}
These files are specially labeled on SELinux systems, and we need to preserve that label.
-rw-r--r--src/sysusers/sysusers.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
index 68c552d24a..e086c72682 100644
--- a/src/sysusers/sysusers.c
+++ b/src/sysusers/sysusers.c
@@ -312,7 +312,11 @@ static int write_files(void) {
_cleanup_fclose_ FILE *original = NULL;
group_path = fix_root("/etc/group");
+ r = label_context_set("/etc/group", S_IFREG);
+ if (r < 0)
+ goto finish;
r = fopen_temporary(group_path, &group, &group_tmp);
+ label_context_clear();
if (r < 0)
goto finish;
@@ -388,9 +392,14 @@ static int write_files(void) {
_cleanup_fclose_ FILE *original = NULL;
passwd_path = fix_root("/etc/passwd");
- r = fopen_temporary(passwd_path, &passwd, &passwd_tmp);
+ r = label_context_set("/etc/passwd", S_IFREG);
if (r < 0)
goto finish;
+ r = fopen_temporary(passwd_path, &passwd, &passwd_tmp);
+ label_context_clear();
+ if (r < 0) {
+ goto finish;
+ }
if (fchmod(fileno(passwd), 0644) < 0) {
r = -errno;
@@ -1491,6 +1500,8 @@ int main(int argc, char *argv[]) {
umask(0022);
+ label_init(NULL);
+
r = 0;
if (optind < argc) {