Date: Thu, 26 Aug 1999 13:49:49 +0200 From: Sheldon Hearn <sheldonh@uunet.co.za> To: freebsd-gnats-submit@freebsd.org Cc: freebsd-bugs@freebsd.org Subject: Re: bin/13365: Patch to mkfifo(1) for Unix 98 compliance Message-ID: <64850.935668189@axl.noc.iafrica.com>
index | next in thread | raw e-mail
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 <sys/stat.h>
#include <err.h>
+#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
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
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?64850.935668189>
