Paul Eggert [Tue, 27 Dec 2005 08:00:12 +0000 (08:00 +0000)]
(wipename): Use similar open flags to other places we open directories.
Don't bother trying to open dir for writing, since POSIX prohibits it.
Paul Eggert [Tue, 27 Dec 2005 07:59:27 +0000 (07:59 +0000)]
(fd_to_subdirp): Open with O_DIRECTORY | O_NOCTTY
| O_NOFOLLOW too, for consistency with other dir-openers.
Use POSIX-preferred O_NONBLOCK rather than O_NDELAY.
(is_empty_dir): Likewise.
Paul Eggert [Tue, 27 Dec 2005 07:59:00 +0000 (07:59 +0000)]
(restricted_chown):
Don't try O_WRONLY unless O_RDONLY failed wth EACCES.
Paul Eggert [Tue, 27 Dec 2005 07:57:14 +0000 (07:57 +0000)]
(save_cwd): Don't bother trying to open directory
for write access: POSIX says that must fail.
Paul Eggert [Tue, 27 Dec 2005 07:56:33 +0000 (07:56 +0000)]
(rpl_chown) [CHOWN_MODIFIES_SYMLINK]:
Don't try O_WRONLY unless O_RDONLY failed wth EACCES.
Fall back on chown if open failed with EACCES.
Paul Eggert [Tue, 27 Dec 2005 07:55:50 +0000 (07:55 +0000)]
(defined_S_IFMT): New macro.
Include stat-macros.h.
Include stdlib.h, for abort().
Don't include stdio.h or assert.h; no longer needed.
(same_file_type): Don't assume S_IFMT is defined, as POSIX
does not require this. Don't assume S_IFCHR and S_IFBLK have
their usual sort of bit pattern.
(fchmod_new): Open with O_NOCTTY for as well, for minor
improvement on hosts where that matters. Don't bother to assert,
since the caller (in this source file) checks the same thing.
Discard any errno from a close failure, for consistency with other
code.
Paul Eggert [Tue, 27 Dec 2005 07:55:03 +0000 (07:55 +0000)]
(diropen): Don't bother trying to open directory for write access:
POSIX says that must fail.
Paul Eggert [Tue, 27 Dec 2005 07:54:37 +0000 (07:54 +0000)]
(chdir_no_follow): Don't bother trying to open directory for write
access: POSIX says that must fail.
Paul Eggert [Tue, 27 Dec 2005 07:53:50 +0000 (07:53 +0000)]
(cdb_free): Don't bother trying to open directory
for write access: POSIX says that must fail.
(cdb_free): Open with O_NOCTTY | O_NONBLOCK as
well, for minor improvements on hosts that lack O_DIRECTORY.
Jim Meyering [Mon, 26 Dec 2005 18:53:58 +0000 (18:53 +0000)]
(chdir_no_follow): Move declaration of local,
sb2, `down' into the scope where it is used.
Note that on some systems this function also fails when DIR
is a writable-yet-unreadable directory.
Jim Meyering [Mon, 26 Dec 2005 18:53:46 +0000 (18:53 +0000)]
*** empty log message ***
Paul Eggert [Sun, 25 Dec 2005 21:40:01 +0000 (21:40 +0000)]
chdir-safer.c still needs unistd.h
Paul Eggert [Sun, 25 Dec 2005 21:38:43 +0000 (21:38 +0000)]
Whoops; don't remove the include for unistd.h, since it defines fchdir.
Paul Eggert [Sun, 25 Dec 2005 21:35:51 +0000 (21:35 +0000)]
chdir-safer cleanup
Paul Eggert [Sun, 25 Dec 2005 21:35:38 +0000 (21:35 +0000)]
(chdir_no_follow): Don't include stdio.h, assert.h,
unistd.h, fcntl--.h; not needed.
(O_DIRECTORY): Define if not already defined.
(chdir_no_follow): Revamp describing comment to match code more
closely. Redo use of internal vars to avoid lint complaints.
Work even if directory is writeable but not readable.
Open with O_DIRECTORY | O_NOCTTY, for benefit of hosts that
don't have O_NOFOLLOW. Use O_NONBLOCK (POSIX spelling) rather
than O_NDELAY. Don't bother invoking fstat if open does not
dereference symlink, since the result isn't used then.
Don't assume file descriptor is positive; it might be zero
now that we no longer include fcntl--.h (we don't need fcntl--.h
since we immediately close the descriptor).
Paul Eggert [Sun, 25 Dec 2005 21:35:21 +0000 (21:35 +0000)]
(FCHMOD_SAFER_H): Remove: it was misnamed, and wasn't needed anyay.
Jim Meyering [Sun, 25 Dec 2005 17:34:04 +0000 (17:34 +0000)]
*** empty log message ***
Jim Meyering [Sun, 25 Dec 2005 17:33:57 +0000 (17:33 +0000)]
(chdir_no_follow): Remove unnecessary test of S_ISDIR (sb_init.st_mode).
Jim Meyering [Fri, 23 Dec 2005 18:17:39 +0000 (18:17 +0000)]
(TESTS): Add p-thru-slink
Jim Meyering [Fri, 23 Dec 2005 18:16:40 +0000 (18:16 +0000)]
New file. Test for today's mkdir-p.c fix.
Jim Meyering [Fri, 23 Dec 2005 18:15:38 +0000 (18:15 +0000)]
*** empty log message ***
Jim Meyering [Fri, 23 Dec 2005 18:15:33 +0000 (18:15 +0000)]
(make_dir_parents): Use chdir_no_follow only
if we've just created the directory.
Jim Meyering [Fri, 23 Dec 2005 17:14:37 +0000 (17:14 +0000)]
*** empty log message ***
Jim Meyering [Fri, 23 Dec 2005 12:00:37 +0000 (12:00 +0000)]
*** empty log message ***
Jim Meyering [Fri, 23 Dec 2005 12:00:26 +0000 (12:00 +0000)]
(chdir_no_follow): Rewrite to use fchdir even
when O_NOFOLLOW is not defined. Suggested by Eric Blake.
Jim Meyering [Fri, 23 Dec 2005 08:28:19 +0000 (08:28 +0000)]
*** empty log message ***
Jim Meyering [Fri, 23 Dec 2005 08:28:14 +0000 (08:28 +0000)]
(O_NOFOLLOW): Define, if necessary.
Jim Meyering [Fri, 23 Dec 2005 08:27:44 +0000 (08:27 +0000)]
(O_NOFOLLOW): Define.
Jim Meyering [Thu, 22 Dec 2005 15:43:25 +0000 (15:43 +0000)]
*** empty log message ***
Jim Meyering [Thu, 22 Dec 2005 15:42:17 +0000 (15:42 +0000)]
*** empty log message ***
Jim Meyering [Thu, 22 Dec 2005 15:40:00 +0000 (15:40 +0000)]
redirect stderr to /dev/full, too (to suppress write error diagnostic)
Jim Meyering [Thu, 22 Dec 2005 14:36:22 +0000 (14:36 +0000)]
*** empty log message ***
Jim Meyering [Thu, 22 Dec 2005 14:34:20 +0000 (14:34 +0000)]
Include "fcntl--.h" and "unistd--.h", to map open
and dup to open_safer and dup_safer, respectively.
(openat_permissive): Fix typo in comment.
Jim Meyering [Wed, 21 Dec 2005 10:23:51 +0000 (10:23 +0000)]
.
Jim Meyering [Wed, 21 Dec 2005 10:21:20 +0000 (10:21 +0000)]
*** empty log message ***
Jim Meyering [Wed, 21 Dec 2005 10:21:04 +0000 (10:21 +0000)]
Require gl_CHDIR_SAFER.
Jim Meyering [Wed, 21 Dec 2005 09:48:41 +0000 (09:48 +0000)]
.
Jim Meyering [Wed, 21 Dec 2005 09:43:44 +0000 (09:43 +0000)]
*** empty log message ***
Jim Meyering [Wed, 21 Dec 2005 09:42:36 +0000 (09:42 +0000)]
like chdir(2), but safer, if possible
Jim Meyering [Tue, 20 Dec 2005 14:23:25 +0000 (14:23 +0000)]
*** empty log message ***
Jim Meyering [Tue, 20 Dec 2005 14:23:20 +0000 (14:23 +0000)]
(RW_USR): Remove definition.
(make_dir_parents): Use S_IRWXU, now that read access is also required.
Avoid a race condition, on systems where open honors O_NOFOLLOW.
(make_dir_parents): Include chdir-safer.h.
Use chdir_no_follow in place of chdir.
Jim Meyering [Tue, 20 Dec 2005 10:28:58 +0000 (10:28 +0000)]
*** empty log message ***
Jim Meyering [Tue, 20 Dec 2005 10:28:53 +0000 (10:28 +0000)]
(make_dir_parents): Remove unnecessary casts of alloca,
since now it's guaranteed to be (void *).
Jim Meyering [Tue, 20 Dec 2005 10:24:43 +0000 (10:24 +0000)]
*** empty log message ***
Jim Meyering [Tue, 20 Dec 2005 10:24:37 +0000 (10:24 +0000)]
(fchmod_new): Don't try to close fd if it's < 0.
Jim Meyering [Mon, 19 Dec 2005 18:21:11 +0000 (18:21 +0000)]
.
Jim Meyering [Mon, 19 Dec 2005 18:19:38 +0000 (18:19 +0000)]
.
Jim Meyering [Mon, 19 Dec 2005 18:18:57 +0000 (18:18 +0000)]
(TESTS): Add mknod.
Jim Meyering [Mon, 19 Dec 2005 18:18:03 +0000 (18:18 +0000)]
(main) Avoid a minor race condition when `-m MODE' is specified, by using
open, fchown, and close rather than just chown. To do that reliably
(even with an overly restrictive umask), ensure that each
mknod call uses a mode including at least owner-read access.
(main): When `-m MODE' is specified, exit nonzero if
the subsequent chown (or equivalent open,fchown,close) fails.
Jim Meyering [Mon, 19 Dec 2005 18:17:16 +0000 (18:17 +0000)]
(main) Avoid a minor race condition when `-m MODE' is specified, by using
open, fchown, and close rather than just chown. To do that reliably
(even with an overly restrictive umask), ensure that each
mkdir call uses a mode including at least owner-read access.
Jim Meyering [Mon, 19 Dec 2005 18:16:07 +0000 (18:16 +0000)]
(main) Avoid a minor race condition when `-m MODE' is specified, by using
open, fchown, and close rather than just chown. To do that reliably
(even with an overly restrictive umask), ensure that each mknod/mkfifo
call uses a mode including at least owner-read access.
Jim Meyering [Mon, 19 Dec 2005 18:13:00 +0000 (18:13 +0000)]
.
Jim Meyering [Mon, 19 Dec 2005 18:12:30 +0000 (18:12 +0000)]
.
Jim Meyering [Mon, 19 Dec 2005 18:05:55 +0000 (18:05 +0000)]
.
Jim Meyering [Mon, 19 Dec 2005 18:05:11 +0000 (18:05 +0000)]
Require gl_CHMOD_SAFER.
Jim Meyering [Sat, 17 Dec 2005 13:46:34 +0000 (13:46 +0000)]
*** empty log message ***
Jim Meyering [Sat, 17 Dec 2005 13:46:27 +0000 (13:46 +0000)]
(is_empty_dir): Open with O_NDELAY, so we don't hang, e.g., on a named pipe.
(OPEN_NO_FOLLOW_SYMLINK): Remove definition. Use O_NOFOLLOW in
place of all uses, since it is guaranteed (system.h) to be defined.
Jim Meyering [Sat, 17 Dec 2005 10:56:25 +0000 (10:56 +0000)]
*** empty log message ***
Jim Meyering [Sat, 17 Dec 2005 10:56:22 +0000 (10:56 +0000)]
Add lib/acl.c.
Jim Meyering [Sat, 17 Dec 2005 10:50:04 +0000 (10:50 +0000)]
*** empty log message ***
Jim Meyering [Sat, 17 Dec 2005 10:50:00 +0000 (10:50 +0000)]
(stat invocation) [--printf]: Describe new option.
[--format]: Add example. Distinguish from --printf.
Sort option descriptions.
Jim Meyering [Sat, 17 Dec 2005 10:48:30 +0000 (10:48 +0000)]
.
Jim Meyering [Sat, 17 Dec 2005 10:48:12 +0000 (10:48 +0000)]
*** empty log message ***
Jim Meyering [Sat, 17 Dec 2005 10:47:37 +0000 (10:47 +0000)]
*** empty log message ***
Jim Meyering [Sat, 17 Dec 2005 10:46:57 +0000 (10:46 +0000)]
(ls): Clarify the Alternate Access Method description.
(cp): Clarify that --preserve=mode also preserves acls.
Jim Meyering [Sat, 17 Dec 2005 10:46:23 +0000 (10:46 +0000)]
(cp_option_init): Don't set umask_kill member.
Jim Meyering [Sat, 17 Dec 2005 10:45:54 +0000 (10:45 +0000)]
(cp_option_init): Don't set umask_kill member.
Jim Meyering [Sat, 17 Dec 2005 10:43:12 +0000 (10:43 +0000)]
(cp_option_init) [umask_kill]: Remove member.
Jim Meyering [Sat, 17 Dec 2005 10:40:10 +0000 (10:40 +0000)]
(umask_kill): With default acls, the umask is not to be applied.
Remove umask_kill, don't change the process umask, and let the kernel
apply the umask where appropriate.
(make_dir_parents_private): Fix logic for POSIX ACLs.
Jim Meyering [Sat, 17 Dec 2005 10:37:47 +0000 (10:37 +0000)]
(dir_LDADD, ls_LDADD, vdir_LDADD, cp_LDADD, mv_LDADD, ginstall_LDADD):
On systems with an ACL library, arrange
to link with it via $(LIB_ACL), for the utilities that need it.
Jim Meyering [Sat, 17 Dec 2005 10:33:33 +0000 (10:33 +0000)]
(get_dest_mode): Remove; it is obsolete after removing umask_kill.
(copy_reg, copy_internal): Use copy_acl and set_acl
instead of fchown/chown. Fix the logic for POSIX ACLs.
(chown_succeded): Remove; we now always copy acls and
preserve S_ISUID, S_ISGID, and S_ISVTX when needed, no matter if we
did a chown before or not.
Jim Meyering [Sat, 17 Dec 2005 10:33:08 +0000 (10:33 +0000)]
Switch back from HAVE_ACL to USE_ACL: The acl() syscall
is no requirement for ACL support; particularly, it does not exist
on systems that have POSIX ACLs.
Jim Meyering [Sat, 17 Dec 2005 10:31:37 +0000 (10:31 +0000)]
*** empty log message ***
Jim Meyering [Sat, 17 Dec 2005 10:31:33 +0000 (10:31 +0000)]
(acl_entries): Add fallback implementation for POSIX ACL
systems other than Linux.
(chmod_or_fchmod): New function: use fchmod when possible,
and chmod otherwise.
(file_has_acl): Add a POSIX ACL implementation, with a
Linux-specific subcase.
(copy_acl): Add: copy an acl and S_ISUID, S_ISGID, and
S_ISVTX from one file to another. Fall back to fchmod/chmod when
acls are unsupported.
(set_acl): Add: set a file's acl and S_ISUID, S_ISGID, and
S_ISVTX to a defined value. Fall back to fchmod/chmod when acls
are unsupported.
Jim Meyering [Sat, 17 Dec 2005 10:31:15 +0000 (10:31 +0000)]
(copy_acl, set_acl): Add declarations.
Jim Meyering [Sat, 17 Dec 2005 10:30:13 +0000 (10:30 +0000)]
*** empty log message ***
Jim Meyering [Sat, 17 Dec 2005 10:30:09 +0000 (10:30 +0000)]
(AC_FUNC_ACL): Add POSIX ACL and Linux-specific acl tests.
Paul Eggert [Sat, 17 Dec 2005 06:56:19 +0000 (06:56 +0000)]
remove/openat cleanup
Paul Eggert [Sat, 17 Dec 2005 06:55:54 +0000 (06:55 +0000)]
(OPENAT_CWD_RESTORE__REQUIRE): Remove.
(OPENAT_CWD_RESTORE__ALLOW_FAILURE): Likewise.
(fd_to_subdirp): Remove openat_cwd_restore_allow_failure arg; its
value is now signified by whether cwd_errno is null.
(fd_to_subdirp, remove_dir, rm_1); Change cwd failure indicator from
pointer-to-bool to pointer-to-errno-value. All callers changed.
(rm_1): Don't bother setting a local cwd failure flag and then
ORing it into the caller's. Just set the caller's.
(rm): Use cwd failure errno value to print a slightly-better
diagnostic.
Paul Eggert [Sat, 17 Dec 2005 06:55:32 +0000 (06:55 +0000)]
Don't include <stdlib.h>, <unistd.h>, <fcntl.h>,
"gettext.h"; either no longer needed or are guaranteed by openat.h.
(_): Remove; no longer needed.
(openat): Renamed from rpl_openat; no need for rpl_openat
since openat.h renames openat for us.
Replace most of the body with a call to openat_permissive,
to avoid duplicate code.
Port to (probably hypothetical) environments were mode_t is
wider than int.
(openat_permissive): Require mode arg, so that we can check
types better. Put it just after flags. Change cwd failure
indicator from pointer-to-bool to pointer-to-errno-value.
All callers changed.
Invoke openat_save_fail and/or openat_restore_fail if
cwd_errno is null, so that openat can call us.
(openat_permissive, fdopendir, fstatat, unlinkat):
Simplify errno handling to avoid some duplicate code,
as it's OK to set errno on success.
Paul Eggert [Sat, 17 Dec 2005 06:55:01 +0000 (06:55 +0000)]
Revamp code so that function macros depend on
__OPENAT_PREFIX only, not also on AT_FDCWD.
(openat_ro): Remove. Caller changed to use openat_permissive.
(openat_permissive): Now a macro, if not a function.
(openat_restore_fail, openat_save_fail): Now always functions,
since mkdirat needs them even if __OPENAT_PREFIX is defined.
Jim Meyering [Thu, 15 Dec 2005 20:16:03 +0000 (20:16 +0000)]
*** empty log message ***
Jim Meyering [Thu, 15 Dec 2005 20:15:20 +0000 (20:15 +0000)]
(print_it): Properly handle a backslash at the
end of a --printf format string. Reported by Paul Eggert.
Jim Meyering [Thu, 15 Dec 2005 20:15:05 +0000 (20:15 +0000)]
(print_it): Properly handle a backslash at the
end of a --printf format string. Reported by Paul Eggert.
(end-bs): Add a test for the above.
Paul Eggert [Thu, 15 Dec 2005 19:01:00 +0000 (19:01 +0000)]
Fix typo in previous change
Paul Eggert [Thu, 15 Dec 2005 18:58:47 +0000 (18:58 +0000)]
tests/acl porting fixes
Paul Eggert [Thu, 15 Dec 2005 18:58:20 +0000 (18:58 +0000)]
Port to pre-POSIX shells like Solaris 8 /bin/sh.
Don't assume /etc/passwd contains user names; use 'id' instead.
Paul Eggert [Thu, 15 Dec 2005 18:24:35 +0000 (18:24 +0000)]
Regenerate.
Jim Meyering [Thu, 15 Dec 2005 14:49:00 +0000 (14:49 +0000)]
Add Kinyarwanda (rw).
Add Croatian (hr).
Jim Meyering [Thu, 15 Dec 2005 14:48:48 +0000 (14:48 +0000)]
.
Jim Meyering [Thu, 15 Dec 2005 14:47:36 +0000 (14:47 +0000)]
.
Jim Meyering [Thu, 15 Dec 2005 12:25:04 +0000 (12:25 +0000)]
*** empty log message ***
Jim Meyering [Thu, 15 Dec 2005 12:24:54 +0000 (12:24 +0000)]
stat: revert behavior of --format=FMT (-c)
stat: add new option: --printf=FMT
Jim Meyering [Thu, 15 Dec 2005 12:24:30 +0000 (12:24 +0000)]
revert behavior of --format=FMT (-c)
add new option: --printf=FMT
(isodigit, octtobin, hextobin): Define.
(PRINTF_OPTION): Define.
(interpret_backslash_escapes, trailing_delim): New globals.
(usage): Document them. Alphabetize on long option names.
(print_esc_char): New function.
(print_it): Rewrite, in order to handle backslash escapes.
(main): Handle new option. Set globals for --format, too.
Jim Meyering [Thu, 15 Dec 2005 12:23:57 +0000 (12:23 +0000)]
(TESTS): Add stat-printf.
Jim Meyering [Thu, 15 Dec 2005 12:23:36 +0000 (12:23 +0000)]
Test --printf and --format.
Jim Meyering [Thu, 15 Dec 2005 08:37:14 +0000 (08:37 +0000)]
*** empty log message ***
Paul Eggert [Thu, 15 Dec 2005 00:00:02 +0000 (00:00 +0000)]
Diagnose "sort -c -o FILE".
Paul Eggert [Wed, 14 Dec 2005 23:59:23 +0000 (23:59 +0000)]
(incompatible_options): New function.
(check_ordering_compatibility, main): Use it.
(main): Check for -c and -o.
Don't bother with a usage message for
"sort -c a b", for consistency with other error diagnostics.
Paul Eggert [Wed, 14 Dec 2005 23:58:20 +0000 (23:58 +0000)]
(incompat4): New test.