From owner-freebsd-bugs Thu Aug 26 4:52:52 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from axl.noc.iafrica.com (axl.noc.iafrica.com [196.31.1.175]) by hub.freebsd.org (Postfix) with ESMTP id 9E69314DB8; Thu, 26 Aug 1999 04:52:17 -0700 (PDT) (envelope-from sheldonh@axl.noc.iafrica.com) Received: from sheldonh (helo=axl.noc.iafrica.com) by axl.noc.iafrica.com with local-esmtp (Exim 3.02 #1) id 11Jy2P-000Grz-00; Thu, 26 Aug 1999 13:49:49 +0200 From: Sheldon Hearn To: freebsd-gnats-submit@freebsd.org Cc: freebsd-bugs@freebsd.org Subject: Re: bin/13365: Patch to mkfifo(1) for Unix 98 compliance Date: Thu, 26 Aug 1999 13:49:49 +0200 Message-ID: <64850.935668189@axl.noc.iafrica.com> Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org This is the patch I intend to apply. I'm waiting for feedback from freebsd-hackers on whether executable/sticky bits on pipes mean anything special in FreeBSD. Ciao, Sheldon. Index: mkfifo.1 =================================================================== RCS file: /home/ncvs/src/usr.bin/mkfifo/mkfifo.1,v retrieving revision 1.4 diff -u -d -r1.4 mkfifo.1 --- mkfifo.1 1997/04/27 08:45:45 1.4 +++ mkfifo.1 1999/08/26 10:29:57 @@ -43,13 +43,33 @@ .Nd make fifos .Sh SYNOPSIS .Nm +.Op Fl m Ar mode .Ar fifo_name ... .Sh DESCRIPTION The .Nm command creates the fifos requested, in the order specified, -using mode -.Li \&0777 . +using a default mode +.Li \&0666 +modified by the current +.Xr umask 2 . +.Pp +The options are as follows: +.Bl -tag -width indent +.It Fl m +Set the file permission bits of the created fifos to the +specified mode. +The mode argument takes any format that can be specified to the +.Xr chmod 1 +command. +If a symbolic mode is specified, the op symbols +.Dq + +(plus) and +.Dq - +(hyphen) are interpreted relative to an assumed initial mode of +.Dq a=rw +(read and write permissions for all). +.El .Pp The .Nm Index: mkfifo.c =================================================================== RCS file: /home/ncvs/src/usr.bin/mkfifo/mkfifo.c,v retrieving revision 1.3 diff -u -d -r1.3 mkfifo.c --- mkfifo.c 1997/07/24 07:02:55 1.3 +++ mkfifo.c 1999/08/26 11:13:16 @@ -49,22 +49,33 @@ #include #include +#include #include #include #include static void usage __P((void)); +static int f_mode; +static const mode_t basemode = (S_IRWXU & ~S_IXUSR | S_IRWXG & ~S_IXGRP | + S_IRWXO & ~S_IXOTH); + int main(argc, argv) int argc; char *argv[]; { - extern int optind; int ch, exitval; + char *modestr; + void *mode; + mode_t creatmode; - while ((ch = getopt(argc, argv, "")) != -1) + while ((ch = getopt(argc, argv, "m:")) != -1) switch(ch) { + case 'm': + f_mode = 1; + modestr = optarg; + break; case '?': default: usage(); @@ -74,8 +85,21 @@ if (argv[0] == NULL) usage(); + if (f_mode) { + errno = 0; + if ((mode = setmode(modestr)) == NULL) { + if (errno) + err(1, NULL); + else + errx(1, "invalid file mode: %s", modestr); + } + creatmode = getmode(mode, basemode); + } else { + creatmode = basemode; + } + for (exitval = 0; *argv != NULL; ++argv) - if (mkfifo(*argv, S_IRWXU | S_IRWXG | S_IRWXO) < 0) { + if (mkfifo(*argv, creatmode) < 0) { warn("%s", *argv); exitval = 1; } @@ -85,6 +109,6 @@ static void usage() { - (void)fprintf(stderr, "usage: mkfifo fifoname ...\n"); + (void)fprintf(stderr, "usage: mkfifo [-m mode] fifoname ...\n"); exit(1); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message