security fixes for partially created files
2009-06-25 Paolo Bonzini <bonzini@gnu.org> * execute.c: Do not copy ACLs until the file is copied. * utils.c (ck_mkstemp): Set a restrictive umask on temporary files.
This commit is contained in:
1 parent
3817efe1dd
commit
730fc21dd1
3 files changed
+21
-5
No files matched your search
@@ -1,3 +1,8 @@
|
||||
2009-06-25 Paolo Bonzini <bonzini@gnu.org>
|
||||
|
||||
* execute.c: Do not copy ACLs until the file is copied.
|
||||
* utils.c (ck_mkstemp): Set a restrictive umask on temporary files.
|
||||
|
||||
2009-06-25 Paolo Bonzini <bonzini@gnu.org>
|
||||
|
||||
* autoboot.conf: Add selinux-h.
|
||||
|
||||
+11
-5
@@ -769,9 +769,6 @@ open_next_file(name, input)
|
||||
if (fchown (output_fd, st.st_uid, st.st_gid) == -1)
|
||||
fchown (output_fd, -1, st.st_gid);
|
||||
#endif
|
||||
copy_acl (input->in_file_name, input_fd,
|
||||
input->out_file_name, output_fd,
|
||||
st.st_mode);
|
||||
}
|
||||
else
|
||||
output_file.fp = stdout;
|
||||
@@ -791,9 +788,17 @@ closedown(input)
|
||||
if (in_place_extension && output_file.fp != NULL)
|
||||
{
|
||||
const char *target_name;
|
||||
ck_fclose (output_file.fp);
|
||||
int input_fd, output_fd;
|
||||
|
||||
target_name = input->in_file_name;
|
||||
input_fd = fileno (input->fp);
|
||||
output_fd = fileno (output_file.fp);
|
||||
copy_acl (input->in_file_name, input_fd,
|
||||
input->out_file_name, output_fd,
|
||||
st.st_mode);
|
||||
|
||||
ck_fclose (input->fp);
|
||||
ck_fclose (output_file.fp);
|
||||
if (strcmp(in_place_extension, "*") != 0)
|
||||
{
|
||||
char *backup_file_name = get_backup_file_name(target_name);
|
||||
@@ -804,8 +809,9 @@ closedown(input)
|
||||
ck_rename (input->out_file_name, target_name, input->out_file_name);
|
||||
free (input->out_file_name);
|
||||
}
|
||||
else
|
||||
ck_fclose (input->fp);
|
||||
|
||||
ck_fclose (input->fp);
|
||||
input->fp = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -200,6 +200,7 @@ ck_mkstemp (p_filename, tmpdir, base)
|
||||
char *template;
|
||||
FILE *fp;
|
||||
int fd;
|
||||
int save_umask;
|
||||
|
||||
if (tmpdir == NULL)
|
||||
tmpdir = getenv("TMPDIR");
|
||||
@@ -217,7 +218,11 @@ ck_mkstemp (p_filename, tmpdir, base)
|
||||
template = xmalloc (strlen (tmpdir) + strlen (base) + 8);
|
||||
sprintf (template, "%s/%sXXXXXX", tmpdir, base);
|
||||
|
||||
/* The ownership might change, so omit some permissions at first
|
||||
so unauthorized users cannot nip in before the file is ready. */
|
||||
save_umask = umask (8r700);
|
||||
fd = mkstemp (template);
|
||||
umask (save_umask);
|
||||
if (fd == -1)
|
||||
panic(_("couldn't open temporary file %s: %s"), template, strerror(errno));
|
||||
|
||||
|
||||
Reference in new issue
Block a user