1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-06-01 07:16:33 +02:00
Commit Graph

4657 Commits

Author SHA1 Message Date
Paul Eggert c0dac69808 New approach to safer chmod. 2006-01-02 07:30:27 +00:00
Paul Eggert bee93bd060 No longer used. 2006-01-02 07:18:30 +00:00
Paul Eggert e59703a1d6 New file. 2006-01-02 06:34:32 +00:00
Paul Eggert c225633528 Include lchmod.h, lchmod.c.
(make_dir_parents): Use lchown rather than chown, and
lchmod rather than chmod.
2006-01-02 06:33:12 +00:00
Paul Eggert eb330d2584 chdir-related fixes 2005-12-27 08:00:42 +00:00
Paul Eggert 97fe820f88 (save_cwd): Don't bother trying to open directory
for write access: POSIX says that must fail.
2005-12-27 07:57:14 +00:00
Paul Eggert ee7334652f (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.
2005-12-27 07:56:33 +00:00
Paul Eggert 0d7468cabd (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.
2005-12-27 07:55:50 +00:00
Paul Eggert cc4d59e9cd (diropen): Don't bother trying to open directory for write access:
POSIX says that must fail.
2005-12-27 07:55:03 +00:00
Paul Eggert 8846a6bfdd (chdir_no_follow): Don't bother trying to open directory for write
access: POSIX says that must fail.
2005-12-27 07:54:37 +00:00
Paul Eggert a2c8ec26a4 (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.
2005-12-27 07:53:50 +00:00
Jim Meyering edf69af317 (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.
2005-12-26 18:53:58 +00:00
Jim Meyering 078800a00b *** empty log message *** 2005-12-26 18:53:46 +00:00
Paul Eggert 7cffc5f20e chdir-safer.c still needs unistd.h 2005-12-25 21:40:01 +00:00
Paul Eggert f7a0d07623 Whoops; don't remove the include for unistd.h, since it defines fchdir. 2005-12-25 21:38:43 +00:00
Paul Eggert 11eedd84d3 chdir-safer cleanup 2005-12-25 21:35:51 +00:00
Paul Eggert 8b9f6b163a (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).
2005-12-25 21:35:38 +00:00
Paul Eggert 532cf2ac33 (FCHMOD_SAFER_H): Remove: it was misnamed, and wasn't needed anyay. 2005-12-25 21:35:21 +00:00
Jim Meyering 735fb62c0f *** empty log message *** 2005-12-25 17:34:04 +00:00
Jim Meyering d789e78a75 (chdir_no_follow): Remove unnecessary test of S_ISDIR (sb_init.st_mode). 2005-12-25 17:33:57 +00:00
Jim Meyering 7916560259 *** empty log message *** 2005-12-23 18:15:38 +00:00
Jim Meyering 5d3118175f (make_dir_parents): Use chdir_no_follow only
if we've just created the directory.
2005-12-23 18:15:33 +00:00
Jim Meyering bdf801ef29 *** empty log message *** 2005-12-23 17:14:37 +00:00
Jim Meyering 7616f9171a *** empty log message *** 2005-12-23 12:00:37 +00:00
Jim Meyering 2eab9d93fc (chdir_no_follow): Rewrite to use fchdir even
when O_NOFOLLOW is not defined.  Suggested by Eric Blake.
2005-12-23 12:00:26 +00:00
Jim Meyering 867dbd1591 *** empty log message *** 2005-12-23 08:28:19 +00:00
Jim Meyering bd80c2e5a7 (O_NOFOLLOW): Define, if necessary. 2005-12-23 08:28:14 +00:00
Jim Meyering 6ed15904b1 (O_NOFOLLOW): Define. 2005-12-23 08:27:44 +00:00
Jim Meyering 2bd65173c2 *** empty log message *** 2005-12-22 14:36:22 +00:00
Jim Meyering b6c621211b Include "fcntl--.h" and "unistd--.h", to map open
and dup to open_safer and dup_safer, respectively.
(openat_permissive): Fix typo in comment.
2005-12-22 14:34:20 +00:00
Jim Meyering 1e1938032b . 2005-12-21 10:23:51 +00:00
Jim Meyering 05eb4556c8 . 2005-12-21 09:48:41 +00:00
Jim Meyering a7c7b483f1 *** empty log message *** 2005-12-21 09:43:44 +00:00
Jim Meyering 2956eb272c like chdir(2), but safer, if possible 2005-12-21 09:42:36 +00:00
Jim Meyering 3108671902 *** empty log message *** 2005-12-20 14:23:25 +00:00
Jim Meyering d0344cfc55 (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.
2005-12-20 14:23:20 +00:00
Jim Meyering 0b7757fac4 *** empty log message *** 2005-12-20 10:28:58 +00:00
Jim Meyering cf02d3c6f6 (make_dir_parents): Remove unnecessary casts of alloca,
since now it's guaranteed to be (void *).
2005-12-20 10:28:53 +00:00
Jim Meyering ddb24aa9fb *** empty log message *** 2005-12-20 10:24:43 +00:00
Jim Meyering 7be64dd68f (fchmod_new): Don't try to close fd if it's < 0. 2005-12-20 10:24:37 +00:00
Jim Meyering e0029290b8 . 2005-12-19 18:13:00 +00:00
Jim Meyering 89276658f2 . 2005-12-19 18:12:30 +00:00
Jim Meyering c99e1d2cb6 . 2005-12-17 10:48:30 +00:00
Jim Meyering c4a1355047 *** empty log message *** 2005-12-17 10:48:12 +00:00
Jim Meyering 4a12f5ebcf (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.
2005-12-17 10:31:33 +00:00
Jim Meyering 9566c9c9d3 (copy_acl, set_acl): Add declarations. 2005-12-17 10:31:15 +00:00
Paul Eggert 1833362111 remove/openat cleanup 2005-12-17 06:56:19 +00:00
Paul Eggert 3f86aaadcf 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.
2005-12-17 06:55:32 +00:00
Paul Eggert 1c5cebe703 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.
2005-12-17 06:55:01 +00:00
Jim Meyering 049a807bc6 . 2005-12-15 14:47:36 +00:00