aboutsummaryrefslogtreecommitdiff
path: root/bin/chmod
diff options
context:
space:
mode:
authorAnton Berezin <tobez@FreeBSD.org>2003-10-31 13:20:09 +0000
committerAnton Berezin <tobez@FreeBSD.org>2003-10-31 13:20:09 +0000
commitad6a34de1d02dbaf137bbbe5c33570c28d288931 (patch)
tree8cc3a1454eb2357f1d8297e196dfb309feafbb92 /bin/chmod
parent875ec8bdcf0c92a8e767d95f145ad4ee188669fe (diff)
downloadsrc-ad6a34de1d02dbaf137bbbe5c33570c28d288931.tar.gz
src-ad6a34de1d02dbaf137bbbe5c33570c28d288931.zip
Remove the code for parsing octal modes, since setmode(3) already
handles them. Reviewed by: audit MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=121794
Diffstat (limited to 'bin/chmod')
-rw-r--r--bin/chmod/chmod.c27
1 files changed, 5 insertions, 22 deletions
diff --git a/bin/chmod/chmod.c b/bin/chmod/chmod.c
index 507a62621e50..0f97f6973bb2 100644
--- a/bin/chmod/chmod.c
+++ b/bin/chmod/chmod.c
@@ -65,16 +65,13 @@ main(int argc, char *argv[])
FTS *ftsp;
FTSENT *p;
mode_t *set;
- long val;
- int oct;
int Hflag, Lflag, Rflag, ch, fflag, fts_options, hflag, rval;
int vflag;
- char *ep, *mode;
- mode_t newmode, omode;
+ char *mode;
+ mode_t newmode;
int (*change_mode)(const char *, mode_t);
set = NULL;
- omode = 0;
Hflag = Lflag = Rflag = fflag = hflag = vflag = 0;
while ((ch = getopt(argc, argv, "HLPRXfghorstuvwx")) != -1)
switch (ch) {
@@ -152,22 +149,8 @@ done: argv += optind;
change_mode = chmod;
mode = *argv;
- if (*mode >= '0' && *mode <= '7') {
- errno = 0;
- val = strtol(mode, &ep, 8);
- if (val > USHRT_MAX || val < 0)
- errno = ERANGE;
- if (errno)
- err(1, "invalid file mode: %s", mode);
- if (*ep)
- errx(1, "invalid file mode: %s", mode);
- omode = (mode_t)val;
- oct = 1;
- } else {
- if ((set = setmode(mode)) == NULL)
- errx(1, "invalid file mode: %s", mode);
- oct = 0;
- }
+ if ((set = setmode(mode)) == NULL)
+ errx(1, "invalid file mode: %s", mode);
if ((ftsp = fts_open(++argv, fts_options, 0)) == NULL)
err(1, "fts_open");
@@ -200,7 +183,7 @@ done: argv += optind;
default:
break;
}
- newmode = oct ? omode : getmode(set, p->fts_statp->st_mode);
+ newmode = getmode(set, p->fts_statp->st_mode);
if ((newmode & ALLPERMS) == (p->fts_statp->st_mode & ALLPERMS))
continue;
if ((*change_mode)(p->fts_accpath, newmode) && !fflag) {