Date: Tue, 24 Aug 1999 22:42:16 -0400 (EDT) From: James Howard <howardjp@wam.umd.edu> To: FreeBSD-gnats-submit@freebsd.org Subject: bin/13365: Patch to mkfifo(1) for Unix 98 compliance Message-ID: <199908250242.WAA07674@rac9.wam.umd.edu>
next in thread | raw e-mail | index | archive | help
>Number: 13365 >Category: bin >Synopsis: Patch to mkfifo(1) for Unix 98 compliance >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Aug 24 19:50:01 PDT 1999 >Closed-Date: >Last-Modified: >Originator: James Howard >Release: FreeBSD 3.2-STABLE i386 >Organization: University of Maryland >Environment: FreeBSD byzantine 3.2-STABLE FreeBSD 3.2-STABLE #5: Sat Aug 7 23:43:54 GMT 1999 root@byzantine:/usr/src/sys/compile/BYZANTINE i386 >Description: Unix 98 requires that mkfifo(1) take an argument -m. If this argument is given, it is followed by a string which specifies the mode which the FIFO will be set to. The behaviour is identical to the -m argument to mkdir(1). Consquently, the changes to mkfifo were derived from mkdir. Apply the diff below to /usr/src/usr.bin/mkfifo to update mkfifo.c and mkfifo.1. >How-To-Repeat: mkfifo -m gives an illegal option error >Fix: diff -c /usr/src/usr.bin/mkfifo/mkfifo.1 /usr/local/src/mkfifo/mkfifo.1 *** /usr/src/usr.bin/mkfifo/mkfifo.1 Sun Apr 27 08:45:45 1997 --- /usr/local/src/mkfifo/mkfifo.1 Tue Aug 24 18:53:24 1999 *************** *** 43,48 **** --- 43,49 ---- .Nd make fifos .Sh SYNOPSIS .Nm + .Op Fl m Ar mode .Ar fifo_name ... .Sh DESCRIPTION The *************** *** 54,59 **** --- 55,77 ---- The .Nm command requires write permission in the parent directory. + .Pp + The options are as follows + .Pp + .Bl -tag -width indent + .It Fl m + Set the file permission bits of the final created directory to + the specified mode. + The mode argument can be in any of the formats specified to the + .Xr chmod 1 + command. + If a symbolic mode is specified, the operation characters + .Dq + + and + .Dq - + are interpreted relative to an initial mode of + .Dq a=rwx . + .El .Pp The .Nm diff -c /usr/src/usr.bin/mkfifo/mkfifo.c /usr/local/src/mkfifo/mkfifo.c *** /usr/src/usr.bin/mkfifo/mkfifo.c Thu Jul 24 07:02:55 1997 --- /usr/local/src/mkfifo/mkfifo.c Tue Aug 24 19:11:30 1999 *************** *** 50,55 **** --- 50,56 ---- #include <err.h> #include <stdio.h> + #include <stdlib.h> #include <string.h> #include <unistd.h> *************** *** 61,70 **** char *argv[]; { extern int optind; ! int ch, exitval; ! while ((ch = getopt(argc, argv, "")) != -1) switch(ch) { case '?': default: usage(); --- 62,77 ---- char *argv[]; { extern int optind; ! int ch, exitval, omode, success; ! mode_t *set = (mode_t *)NULL; ! char *mode; ! mode = NULL; ! while ((ch = getopt(argc, argv, "m:")) != -1) switch(ch) { + case 'm': + mode = optarg; + break; case '?': default: usage(); *************** *** 74,84 **** if (argv[0] == NULL) usage(); ! for (exitval = 0; *argv != NULL; ++argv) ! if (mkfifo(*argv, S_IRWXU | S_IRWXG | S_IRWXO) < 0) { warn("%s", *argv); ! exitval = 1; } exit(exitval); } --- 81,116 ---- if (argv[0] == NULL) usage(); ! if (mode == NULL) { ! omode = S_IRWXU | S_IRWXG | S_IRWXO; ! } else { ! if ((set = setmode(mode)) == NULL) ! errx(1, "invalid file mode: %s", mode); ! omode = getmode(set, S_IRWXU | S_IRWXG | S_IRWXO); ! free(set); ! } ! ! for (exitval = 0; *argv != NULL; ++argv) { ! success = 1; ! if (mkfifo(*argv, omode) < 0) { warn("%s", *argv); ! success = 0; } + if (!success) + exitval = 1; + /* + * The mkdir() and umask() calls both honor only the low + * nine bits, so if you try to set a mode including the + * sticky, setuid, setgid bits you lose them. Don't do + * this unless the user has specifically requested a mode, + * as chmod will (obviously) ignore the umask. + */ + if (success && mode != NULL && chmod(*argv, omode) == -1) { + warn("%s", *argv); + exitval = 1; + } + } + exit(exitval); } >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199908250242.WAA07674>