diff options
author | Paolo Bonzini <bonzini@gnu.org> | 2009-10-15 20:13:26 +0200 |
---|---|---|
committer | Paolo Bonzini <bonzini@gnu.org> | 2009-10-15 20:13:26 +0200 |
commit | 70172377a7f4b0c175763c51d8191771e5818404 (patch) | |
tree | 056008cb070d27c61cdd4ef0255caf47bb7b6c6c | |
parent | d5af5096d9c7e0914179037cc4e5bba84903179d (diff) | |
download | sed-70172377a7f4b0c175763c51d8191771e5818404.tar.gz |
merge 5156c19b correctly
2009-10-15 Paolo Bonzini <bonzini@gnu.org>
* sed/execute.c (closedown, open_next_file): Merge 5156c19b correctly.
* sed/utils.c: Likewise.
-rw-r--r-- | ChangeLog | 5 | ||||
m--------- | gnulib | 0 | ||||
-rw-r--r-- | sed/execute.c | 22 | ||||
-rw-r--r-- | sed/utils.c | 2 |
4 files changed, 17 insertions, 12 deletions
@@ -1,4 +1,9 @@ 2009-10-15 Paolo Bonzini <bonzini@gnu.org> + + * sed/execute.c (closedown, open_next_file): Merge 5156c19b correctly. + * sed/utils.c: Likewise. + +2009-10-15 Paolo Bonzini <bonzini@gnu.org> WANG Yunfeng <uhuruh@gmail.com> * sed/execute.c (str_append, str_append_modified): Handle incomplete diff --git a/gnulib b/gnulib -Subproject 3ad7edd60e7fbc0f21ebda351fed502376135cf +Subproject b653eda3ac4864de205419d9f41eec267cb89ee diff --git a/sed/execute.c b/sed/execute.c index 06dbeda..b707a6b 100644 --- a/sed/execute.c +++ b/sed/execute.c @@ -138,6 +138,9 @@ struct input { const char *in_file_name; + /* Owner and mode to be set just before closing the file. */ + struct stat st; + /* if NULL, none of the following are valid */ FILE *fp; @@ -713,9 +716,8 @@ open_next_file(name, input) if (in_place_extension) { - int input_fd, output_fd; + int input_fd; char *tmpdir, *p; - struct stat st; if (follow_symlinks) input->in_file_name = follow_symlink (name); @@ -733,8 +735,8 @@ open_next_file(name, input) panic(_("couldn't edit %s: is a terminal"), input->in_file_name); input_fd = fileno (input->fp); - fstat (input_fd, &st); - if (!S_ISREG (st.st_mode)) + fstat (input_fd, &input->st); + if (!S_ISREG (input->st.st_mode)) panic(_("couldn't edit %s: not a regular file"), input->in_file_name); #ifndef BOOTSTRAP @@ -763,12 +765,6 @@ open_next_file(name, input) if (!output_file.fp) panic(_("couldn't open temporary file %s: %s"), input->out_file_name, strerror(errno)); - - output_fd = fileno (output_file.fp); -#ifdef HAVE_FCHOWN - if (fchown (output_fd, st.st_uid, st.st_gid) == -1) - fchown (output_fd, -1, st.st_gid); -#endif } else { @@ -797,9 +793,13 @@ closedown(input) target_name = input->in_file_name; input_fd = fileno (input->fp); output_fd = fileno (output_file.fp); +#ifdef HAVE_FCHOWN + if (fchown (output_fd, input->st.st_uid, input->st.st_gid) == -1) + fchown (output_fd, -1, input->st.st_gid); +#endif copy_acl (input->in_file_name, input_fd, input->out_file_name, output_fd, - st.st_mode); + input->st.st_mode); ck_fclose (input->fp); ck_fclose (output_file.fp); diff --git a/sed/utils.c b/sed/utils.c index abb72f9..241ef1d 100644 --- a/sed/utils.c +++ b/sed/utils.c @@ -212,7 +212,7 @@ ck_mkstemp (p_filename, 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); + save_umask = umask (0700); fd = mkstemp (template); umask (save_umask); if (fd == -1) |