summaryrefslogtreecommitdiff
path: root/sed/execute.c
diff options
context:
space:
mode:
authorPaolo Bonzini <bonzini@gnu.org>2006-09-24 16:16:59 +0000
committerPaolo Bonzini <bonzini@gnu.org>2008-01-09 16:12:13 +0100
commitac9a20b3fb800e002fea2a16ce4679777fddcbff (patch)
treebd3397ae23902506df02f260300e5ae8777c8d1e /sed/execute.c
parent0177318fa612307ce2e7eb7557e54d335ffd08f3 (diff)
downloadsed-ac9a20b3fb800e002fea2a16ce4679777fddcbff.tar.gz
gnulibify and add ACL support
2006-09-24 Paolo Bonzini <bonzini@gnu.org> * sed/execute.c: Support ACLs. * lib/utils.c: Move... * sed/utils.c: ... here, and remove xmalloc. git-archimport-id: bonzini@gnu.org--2004b/sed--stable--4.1--patch-74
Diffstat (limited to 'sed/execute.c')
-rw-r--r--sed/execute.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/sed/execute.c b/sed/execute.c
index 582ceb0..0ca2ca5 100644
--- a/sed/execute.c
+++ b/sed/execute.c
@@ -70,6 +70,7 @@ extern int errno;
#endif
#include <sys/stat.h>
+#include "stat-macros.h"
/* Sed operates a line at a time. */
@@ -706,7 +707,7 @@ open_next_file(name, input)
if (in_place_extension)
{
- int output_fd;
+ int input_fd, output_fd;
char *tmpdir = ck_strdup(name), *p;
struct stat st;
@@ -721,7 +722,8 @@ open_next_file(name, input)
if (isatty (fileno (input->fp)))
panic(_("couldn't edit %s: is a terminal"), input->in_file_name);
- fstat (fileno (input->fp), &st);
+ input_fd = fileno (input->fp);
+ fstat (input_fd, &st);
if (!S_ISREG (st.st_mode))
panic(_("couldn't edit %s: not a regular file"), input->in_file_name);
@@ -733,13 +735,13 @@ open_next_file(name, input)
panic(_("couldn't open temporary file %s: %s"), input->out_file_name, strerror(errno));
output_fd = fileno (output_file.fp);
-#ifdef HAVE_FCHMOD
- fchmod (output_fd, st.st_mode);
-#endif
#ifdef HAVE_FCHOWN
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;