chmod: strnum
This commit is contained in:
parent
7c251bcd4f
commit
ba456787cb
6
chmod.c
6
chmod.c
|
@ -14,7 +14,7 @@ static mode_t mode = 0;
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char c, *end;
|
char c;
|
||||||
int octal;
|
int octal;
|
||||||
|
|
||||||
while((c = getopt(argc, argv, "Rr")) != -1)
|
while((c = getopt(argc, argv, "Rr")) != -1)
|
||||||
|
@ -28,9 +28,7 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
if(optind == argc)
|
if(optind == argc)
|
||||||
eprintf("usage: %s [-Rr] mode [file...]\n", argv[0]);
|
eprintf("usage: %s [-Rr] mode [file...]\n", argv[0]);
|
||||||
octal = strtol(argv[optind++], &end, 8);
|
octal = strnum(argv[optind++], 8);
|
||||||
if(*end != '\0')
|
|
||||||
eprintf("%s: not an octal number\n", argv[optind-1]);
|
|
||||||
|
|
||||||
/* posix doesn't specify modal bits */
|
/* posix doesn't specify modal bits */
|
||||||
if(octal & 04000) mode |= S_ISUID;
|
if(octal & 04000) mode |= S_ISUID;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user