[hackers] [sbase] mkfifo: Simplify -m handling || Michael Forney
commit 01b5105e0c7439a358d095fe4703e88c31095178
Author: Michael Forney <mforney_AT_mforney.org>
AuthorDate: Thu Jun 13 13:45:37 2019 -0700
Commit: Michael Forney <mforney_AT_mforney.org>
CommitDate: Thu Jun 13 13:45:37 2019 -0700
mkfifo: Simplify -m handling
Rather than create the FIFO with incorrect permissions at first, then
restore with chmod(2), just clear the umask when -m is specified, and
pass the parsed mode to mkfifo(2).
diff --git a/mkfifo.c b/mkfifo.c
index 390381b..2470a09 100644
--- a/mkfifo.c
+++ b/mkfifo.c
_AT_@ -14,14 +14,12 @@ usage(void)
int
main(int argc, char *argv[])
{
- mode_t mode = 0666, mask;
- int mflag = 0, ret = 0;
+ mode_t mode = 0666;
+ int ret = 0;
ARGBEGIN {
case 'm':
- mflag = 1;
- mask = getumask();
- mode = parsemode(EARGF(usage()), mode, mask);
+ mode = parsemode(EARGF(usage()), mode, umask(0));
break;
default:
usage();
_AT_@ -31,15 +29,9 @@ main(int argc, char *argv[])
usage();
for (; *argv; argc--, argv++) {
- if (mkfifo(*argv, S_IRUSR | S_IWUSR | S_IRGRP |
- S_IWGRP | S_IROTH | S_IWOTH) < 0) {
+ if (mkfifo(*argv, mode) < 0) {
weprintf("mkfifo %s:", *argv);
ret = 1;
- } else if (mflag) {
- if (chmod(*argv, mode) < 0) {
- weprintf("chmod %s:", *argv);
- ret = 1;
- }
}
}
Received on Fri Jun 14 2019 - 20:32:08 CEST
This archive was generated by hypermail 2.3.0
: Fri Jun 14 2019 - 20:36:24 CEST