Importing usr.bin/mesg
Replaces commands/mesg. No Minix-specific changes needed. Change-Id: Ief22ad7f050f8083d0b43a4ea90b348c504d99a2
This commit is contained in:
@@ -15,7 +15,7 @@ SUBDIR= add_route arp ash at backup btrace \
|
||||
intr ipcrm ipcs irdpd isoread last \
|
||||
less loadkeys loadramdisk logger look lp \
|
||||
lpd lspci mail MAKEDEV \
|
||||
mesg mined mkfifo \
|
||||
mined mkfifo \
|
||||
mount mt netconf \
|
||||
nonamed od paste patch \
|
||||
ping postinstall poweroff prep printroot \
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
PROG= mesg
|
||||
MAN=
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
@@ -1,48 +0,0 @@
|
||||
/* mesg - enable or disable communications. Author: John J. Ribera */
|
||||
|
||||
/*
|
||||
* mesg - enable or disable communications.
|
||||
*
|
||||
* Usage: mesg [ y | n ]
|
||||
*
|
||||
* 'mesg n' will turn off group and world permissions of the
|
||||
* user's terminal.
|
||||
* 'mesg y' will enable group and world to write to the user's
|
||||
* tty.
|
||||
* mesg with no parameters will put the writeable status
|
||||
* onto stdout.
|
||||
*
|
||||
* Author: John J. Ribera, Jr. 09/09/90
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char *argv []);
|
||||
|
||||
int main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
struct stat statb;
|
||||
char *tty_name;
|
||||
|
||||
if ((tty_name = ttyname(0)) == NULL) exit(2);
|
||||
if (stat(tty_name, &statb) == -1) exit(2);
|
||||
if (--argc) {
|
||||
if (*argv[1] == 'n') statb.st_mode = 0600;
|
||||
else if (*argv[1] == 'y') statb.st_mode = 0620;
|
||||
else {
|
||||
fprintf(stderr, "mesg: usage: mesg [n|y]\n");
|
||||
exit(2);
|
||||
}
|
||||
if (chmod(tty_name, statb.st_mode) == -1) exit(2);
|
||||
} else printf((statb.st_mode & 020) ? "is y\n" : "is n\n");
|
||||
|
||||
if (statb.st_mode & 020) exit(0);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user