set_selinux_file_context(): prepare context for actual file type
Search the SELinux selabel database for the file type to be created. Not specifying the file mode can cause an incorrect file context to be returned. Also prepare contexts in commonio_close() for the generic database filename, not with the backup suffix appended, to ensure the desired file context after the final rename. Closes: #322 Signed-off-by: Christian Göttsche <cgzones@googlemail.com> Acked-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
@@ -2177,7 +2177,7 @@ static void create_home (void)
|
||||
++bhome;
|
||||
|
||||
#ifdef WITH_SELINUX
|
||||
if (set_selinux_file_context (prefix_user_home) != 0) {
|
||||
if (set_selinux_file_context (prefix_user_home, S_IFDIR) != 0) {
|
||||
fprintf (stderr,
|
||||
_("%s: cannot set SELinux context for home directory %s\n"),
|
||||
Prog, user_home);
|
||||
@@ -2305,7 +2305,7 @@ static void create_mail (void)
|
||||
sprintf (file, "%s/%s", spool, user_name);
|
||||
|
||||
#ifdef WITH_SELINUX
|
||||
if (set_selinux_file_context (file) != 0) {
|
||||
if (set_selinux_file_context (file, S_IFREG) != 0) {
|
||||
fprintf (stderr,
|
||||
_("%s: cannot set SELinux context for mailbox file %s\n"),
|
||||
Prog, file);
|
||||
|
||||
Reference in New Issue
Block a user