summaryrefslogtreecommitdiff
path: root/bin/chmod/chmod.c
Commit message (Collapse)AuthorAgeFilesLines
* fts_read: Handle error from a NULL return better.Bryan Drewery2020-12-081-1/+1
| | | | | | | | | | | | | | | | | | | | This is addressing cases such as fts_read(3) encountering an [EIO] from fchdir(2) when FTS_NOCHDIR is not set. That would otherwise be seen as a successful traversal in some of these cases while silently discarding expected work. As noted in r264201, fts_read() does not set errno to 0 on a successful EOF so it needs to be set before calling it. Otherwise we might see a random error from one of the iterations. gzip is ignoring most errors and could be improved separately. Reviewed by: vangyzen Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D27184 Notes: svn path=/head/; revision=368467
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-0/+2
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326025
* Renumber copyright clause 4Warner Losh2017-02-281-1/+1
| | | | | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96 Notes: svn path=/head/; revision=314436
* chmod: Add SIGINFO handlerConrad Meyer2017-01-081-2/+15
| | | | | | | | | PR: 191884 Submitted by: Dan McGregor <dan.mcgregor at usask.ca> Reviewed by: mjg@ (earlier version) Notes: svn path=/head/; revision=311668
* "POSIX doesn't specify -h." - r1.27 from NetBSDSevan Janiyan2016-10-021-6/+5
| | | | | | | | | | | | | http://man.openbsd.org/?query=chmod&apropos=0&sec=0&arch=default&manpath=POSIX-2013 PR: 212337 Approved by: bcr (mentor) Obtained from: NetBSD MFC after: 5 days Differential Revision: https://reviews.freebsd.org/D8118 Notes: svn path=/head/; revision=306582
* Change directory permissions in pre-order.Sergey Kandaurov2015-06-041-2/+4
| | | | | | | | | | | In this order, it won't try to recurse into a directory for which it doesn't have permission, before changing that permission. This follows an existing behavior in other BSDs, linux, OS X. Obtained from: NetBSD Notes: svn path=/head/; revision=283997
* Standardise chmod, chflags, chown and chgrp recursive symlink processingSteven Hartland2015-04-291-46/+44
| | | | | | | | | | | | | | chmod, chflags, chgrp, chmod and chown now affect symlinks in -R mode as defined in symlink(7); previously symlinks were silently ignored. Differential Revision: https://reviews.freebsd.org/D2316 Reviewed by: jilles MFC after: 1 month Relnotes: yes Sponsored by: Multiplay Notes: svn path=/head/; revision=282208
* - Don't include both <sys/types.h> and <sys/param.h>Edward Tomasz Napierala2009-09-021-9/+6
| | | | | | | | | | | | | | | | | - Keep variables sorted - Fix logic error with -f and -v options - don't print the usual -v output if there was an error, whether or not we were passed -f - Don't call free(3) just before exit(2) - Whitespace fixes Submitted by: bde Notes: svn path=/head/; revision=196753
* Make the code more readable and fix chmod(1) on symlinks withEdward Tomasz Napierala2009-08-311-13/+15
| | | | | | | NFSv4 enabled. Notes: svn path=/head/; revision=196711
* With NFSv4 ACLs, it is possible that applying a mode to an ACL whichEdward Tomasz Napierala2009-07-011-2/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | is identical to the mode computed from that ACL will modify the ACL. For example, mode computed from the following ACL is 0600: user:kamila:rwx--------C--:------:allow owner@:--x-----------:------:deny owner@:rw-p---A-W-Co-:------:allow group@:rwxp----------:------:deny group@:--------------:------:allow everyone@:rwxp---A-W-Co-:------:deny everyone@:------a-R-c--s:------:allow However, applying that mode (chmod 0600) changes the ACL into this: user:kamila:rwx-----------:------:deny user:kamila:rwx--------C--:------:allow owner@:--x-----------:------:deny owner@:rw-p---A-W-Co-:------:allow group@:rwxp----------:------:deny group@:--------------:------:allow everyone@:rwxp---A-W-Co-:------:deny everyone@:------a-R-c--s:------:allow In chmod(1) utility, there is an optimisation, which makes it not call chmod(2) if the mode of the file is the same as the new mode. Disable that optimisation for files which may have NFSv4 ACLs. Reviewed by: rwatson Approved by: re (kib) Notes: svn path=/head/; revision=195243
* Staticify internal routines.Xin LI2009-06-231-2/+2
| | | | Notes: svn path=/head/; revision=194795
* /*- or .\"- or #- to begin license clauses.Warner Losh2005-01-101-1/+1
| | | | Notes: svn path=/head/; revision=139969
* Remove clause 3 from the UCB licenses.Mark Murray2004-04-061-4/+0
| | | | | | | OK'ed by: imp, core Notes: svn path=/head/; revision=127958
* Print unambiguous paths with -R -v.Ruslan Ermilov2003-12-161-1/+1
| | | | Notes: svn path=/head/; revision=123565
* Remove the code for parsing octal modes, since setmode(3) alreadyAnton Berezin2003-10-311-22/+5
| | | | | | | | | | handles them. Reviewed by: audit MFC after: 2 weeks Notes: svn path=/head/; revision=121794
* Quiet warnings about copyright[].David E. O'Brien2003-05-011-2/+2
| | | | Notes: svn path=/head/; revision=114433
* Remove now unnecessary main() prototype.Maxime Henrion2003-01-291-1/+0
| | | | Notes: svn path=/head/; revision=110057
* Allow "-v -v" to mean very verbose.David E. O'Brien2002-08-041-3/+19
| | | | | | | | | Reviewed by: freebsd-standards PR: 40709 Submitted by: Edward Brocklesby <nighthawk@unrealircd.com>, johan Notes: svn path=/head/; revision=101297
* err() is documented as allowing NULL for the format string but GCC isn'tMatthew Dillon2002-07-101-1/+1
| | | | | | | happy about it any more so change the useage so buildworld works again. Notes: svn path=/head/; revision=99743
* Consistently use __FBSDIDDavid E. O'Brien2002-06-301-2/+2
| | | | Notes: svn path=/head/; revision=99109
* Fix warnings inspired by lint, a commercial lint and WARNS=4Mark Murray2002-02-221-9/+8
| | | | Notes: svn path=/head/; revision=91078
* Modernization effort for bin/c*:Warner Losh2002-02-021-7/+5
| | | | | | | | | | | | | | | o __P has been reoved o Old-style K&R declarations have been converted to new C89 style o register has been removed o prototype for main() has been removed (gcc3 makes it an error) o int main(int argc, char *argv[]) is the preferred main definition. o Attempt to not break style(9) conformance for declarations more than they already are. Approved by: arch@, new style(9) Notes: svn path=/head/; revision=90107
* Fixed the bug from the previous revision.Ruslan Ermilov2001-05-311-1/+1
| | | | | | | | | | | | | | | | | | ``chown -h owner symlink'' did not set the symlink's owner if the file the symlink points to already had that owner: # ls -l alink afile -rw-r--r-- 1 nobody ru 0 May 31 14:14 afile lrwxr-xr-x 1 root ru 5 May 31 14:14 alink -> afile # ./chown -h -v nobody alink # ls -l alink afile -rw-r--r-- 1 nobody ru 0 May 31 14:14 afile lrwxr-xr-x 1 root ru 5 May 31 14:14 alink -> afile Similarly for chgrp(1) and chmod(1). Notes: svn path=/head/; revision=77522
* Change noop option -h to do the real work. Now mode of symbolic linkRuslan Ermilov2001-05-281-7/+17
| | | | | | | | | | is changed if -h option is given. Requested by: bde Obtained from: NetBSD (code part) Notes: svn path=/head/; revision=77342
* Follow symbolic links named as command line arguments if run without -R.Ruslan Ermilov2001-05-281-2/+3
| | | | | | | | | | | | | | | | | This is required by symlink(7), ``Commands not traversing a file tree'' subsection, third paragraph: : It is important to realize that this rule includes commands which may : optionally traverse file trees, e.g. the command ``chown file'' is : included in this rule, while the command ``chown -R file'' is not. For chown(8) and chgrp(1), this is also is compliance with the latest POSIX 1003.1-200x draft. MFC after: 1 week Notes: svn path=/head/; revision=77333
* Make this compile with WARNS=2Kris Kennaway2001-05-201-0/+1
| | | | Notes: svn path=/head/; revision=76871
* Optimize out no-op chmod() syscalls.Peter Wemm2000-07-291-2/+5
| | | | Notes: svn path=/head/; revision=64013
* Don't call warn() with no format string. This is potentially exploitable, ↵Kris Kennaway2000-07-101-1/+1
| | | | | | | | | although it would be difficult both technically and in practise. Notes: svn path=/head/; revision=62887
* Default to not -v.David E. O'Brien1999-11-281-2/+2
| | | | | | | Fix usage() style bug spotted by BDE. Notes: svn path=/head/; revision=53824
* Add "-v".David E. O'Brien1999-11-271-2/+9
| | | | Notes: svn path=/head/; revision=53780
* $Id$ -> $FreeBSD$Peter Wemm1999-08-271-1/+1
| | | | Notes: svn path=/head/; revision=50471
* Document -f flag:Chris Costello1999-08-081-3/+3
| | | | | | | | -f Do not display a diagnostic message if chmod could not modify the mode for file. Notes: svn path=/head/; revision=49544
* Free memory obtained from setmode.Warner Losh1998-12-161-1/+2
| | | | | | | Obtained from: OpenBSD Notes: svn path=/head/; revision=41842
* Restore original Lite-2 sccsid. Restore include of sys/types.h.Philippe Charnier1998-05-131-2/+3
| | | | Notes: svn path=/head/; revision=36002
* Correct use of .Nm and other cosmetics. Add rcsid. Remove unused #inc.Philippe Charnier1998-05-061-3/+4
| | | | Notes: svn path=/head/; revision=35773
* compare return value from getopt against -1 rather than EOF, per the finalWarner Losh1997-03-281-2/+2
| | | | | | | posix standard on the topic. Notes: svn path=/head/; revision=24348
* Revert $FreeBSD$ to $Id$Peter Wemm1997-02-221-1/+1
| | | | Notes: svn path=/head/; revision=22988
* Make the long-awaited change from $Id$ to $FreeBSD$Jordan K. Hubbard1997-01-141-1/+1
| | | | | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise. Notes: svn path=/head/; revision=21673
* Cleanup man page and -Wall cleaning.Steve Price1996-12-141-3/+3
| | | | Notes: svn path=/head/; revision=20411
* chmod(2) directories once only (was twice)Adam David1996-08-101-6/+5
| | | | Notes: svn path=/head/; revision=17496
* You will find enclosed some changes to make gcc -Wall more happy inJoerg Wunsch1995-03-191-1/+3
| | | | | | | | | | | | /usr/src/bin. Note that some patches are still needed in that directory. I (Joerg) finished most of Philippe's cleanup. /bin/sh will still need *allot* of work, however. Submitted by: charnier@lirmm.fr (Philippe Charnier) Notes: svn path=/head/; revision=7165
* Include <limits.h> to get the definition of INT_MAX - don't depend onBruce Evans1995-02-031-1/+2
| | | | | | | namespace pollution in <time.h>. Notes: svn path=/head/; revision=6170
* Added $Id$David Greenman1994-09-241-0/+2
| | | | Notes: svn path=/head/; revision=3044
* BSD 4.4 Lite bin SourcesRodney W. Grimes1994-05-261-0/+201
Notes: svn path=/head/; revision=1556