GNU sed version 4.1, bug report
Terry Chan
tchan at dbguin.lunar-linux.org
Fri Jun 18 01:46:30 GMT 2004
sed-4.1 does NOT correctly perform chmod/chown when
using the "sed -i" (edit in-place) feature.
sed-4.0.9 does work.
Simple test case:
1. touch this_is_an_empty_testfile
2. chmod 755 this_is_an_empty_testfile
3. chown 1000:1000 this_is_an_empty_testfile
4. sed -i "s/XX/x/" this_is_an_empty_testfile
5. ls -al this_is_an_empty_testfile
And this will now show uid:gid of 0:0 and permissions of 600 for
this_is_an_empty_testfile
The problem is located in execute.c and the rewrite/changes in
4.1 vs 4.0.9.
Specifically 4.1 execute.c line 675 still uses:
fchmod (output_fd, st.st_mode);
which is how sed-4.0.9 invokes the chmod as well. The problem is
sed-4.1 does NOT use output_fd and now uses output_file.fp !!!!
Similarly fchown usage is incorrect too as it still uses output_fd,
but should be using output_file.fp.
This bug in sed-4.1 clearly breaks the chmod and chown functionality that
was working in sed-4.0.9.
Terry Chan
Lunar Linux Developer
More information about the Lunar
mailing list