Merge pull request #48 from t8m/fedora

Four simple patches from the Fedora package to merge
This commit is contained in:
Serge Hallyn 2016-12-02 16:14:24 -06:00 committed by GitHub
commit d886cf40ef
4 changed files with 23 additions and 6 deletions

View File

@ -301,15 +301,12 @@ static int create_backup (const char *backup, FILE * fp)
struct utimbuf ub; struct utimbuf ub;
FILE *bkfp; FILE *bkfp;
int c; int c;
mode_t mask;
if (fstat (fileno (fp), &sb) != 0) { if (fstat (fileno (fp), &sb) != 0) {
return -1; return -1;
} }
mask = umask (077); bkfp = fopen_set_perms (backup, "w", &sb);
bkfp = fopen (backup, "w");
(void) umask (mask);
if (NULL == bkfp) { if (NULL == bkfp) {
return -1; return -1;
} }

View File

@ -338,8 +338,7 @@ static /*@null@*/struct commonio_entry *merge_group_entries (
errno = ENOMEM; errno = ENOMEM;
return NULL; return NULL;
} }
snprintf(new_line, new_line_len, "%s\n%s", gr1->line, gr2->line); snprintf(new_line, new_line_len + 1, "%s\n%s", gr1->line, gr2->line);
new_line[new_line_len] = '\0';
/* Concatenate the 2 list of members */ /* Concatenate the 2 list of members */
for (i=0; NULL != gptr1->gr_mem[i]; i++); for (i=0; NULL != gptr1->gr_mem[i]; i++);

View File

@ -1896,6 +1896,9 @@ static void create_home (void)
if (access (user_home, F_OK) != 0) { if (access (user_home, F_OK) != 0) {
#ifdef WITH_SELINUX #ifdef WITH_SELINUX
if (set_selinux_file_context (user_home) != 0) { if (set_selinux_file_context (user_home) != 0) {
fprintf (stderr,
_("%s: cannot set SELinux context for home directory %s\n"),
Prog, user_home);
fail_exit (E_HOMEDIR); fail_exit (E_HOMEDIR);
} }
#endif #endif
@ -1925,6 +1928,9 @@ static void create_home (void)
#ifdef WITH_SELINUX #ifdef WITH_SELINUX
/* Reset SELinux to create files with default contexts */ /* Reset SELinux to create files with default contexts */
if (reset_selinux_file_context () != 0) { if (reset_selinux_file_context () != 0) {
fprintf (stderr,
_("%s: cannot reset SELinux file creation context\n"),
Prog);
fail_exit (E_HOMEDIR); fail_exit (E_HOMEDIR);
} }
#endif #endif

View File

@ -1756,6 +1756,14 @@ static void move_home (void)
fail_exit (E_HOMEDIR); fail_exit (E_HOMEDIR);
} }
#ifdef WITH_AUDIT
if (uflg || gflg) {
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"changing home directory owner",
user_newname, (unsigned int) user_newid, 1);
}
#endif
if (rename (user_home, user_newhome) == 0) { if (rename (user_home, user_newhome) == 0) {
/* FIXME: rename above may have broken symlinks /* FIXME: rename above may have broken symlinks
* pointing to the user's home directory * pointing to the user's home directory
@ -2252,6 +2260,13 @@ int main (int argc, char **argv)
* ownership. * ownership.
* *
*/ */
#ifdef WITH_AUDIT
if (uflg || gflg) {
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"changing home directory owner",
user_newname, (unsigned int) user_newid, 1);
}
#endif
if (chown_tree (dflg ? user_newhome : user_home, if (chown_tree (dflg ? user_newhome : user_home,
user_id, user_id,
uflg ? user_newid : (uid_t)-1, uflg ? user_newid : (uid_t)-1,