aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2002-09-16 04:21:46 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2002-09-16 04:21:46 +0000
commit061c9001763f4a19d8104d5be61bbb09b50b1dae (patch)
tree3942c0a93b5e11fbb838777dba8d3002b17c2583
parentebdc8b48a563615f6e0b08bdf2c91241fed669e0 (diff)
downloadbusybox-w32-061c9001763f4a19d8104d5be61bbb09b50b1dae.tar.gz
busybox-w32-061c9001763f4a19d8104d5be61bbb09b50b1dae.tar.bz2
busybox-w32-061c9001763f4a19d8104d5be61bbb09b50b1dae.zip
mesg applet by Manuel Novoa III
-rw-r--r--include/applets.h3
-rw-r--r--include/usage.h7
-rw-r--r--init/Makefile.in1
-rw-r--r--init/config.in1
-rw-r--r--init/mesg.c58
5 files changed, 70 insertions, 0 deletions
diff --git a/include/applets.h b/include/applets.h
index 38d75344f..f6a840024 100644
--- a/include/applets.h
+++ b/include/applets.h
@@ -293,6 +293,9 @@
293#ifdef CONFIG_MD5SUM 293#ifdef CONFIG_MD5SUM
294 APPLET(md5sum, md5sum_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER) 294 APPLET(md5sum, md5sum_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
295#endif 295#endif
296#ifdef CONFIG_MESG
297 APPLET(mesg, mesg_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
298#endif
296#ifdef CONFIG_MKDIR 299#ifdef CONFIG_MKDIR
297 APPLET(mkdir, mkdir_main, _BB_DIR_BIN, _BB_SUID_NEVER) 300 APPLET(mkdir, mkdir_main, _BB_DIR_BIN, _BB_SUID_NEVER)
298#endif 301#endif
diff --git a/include/usage.h b/include/usage.h
index 98b81cf1d..ee697150b 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -1149,6 +1149,13 @@
1149 "busybox: OK\n" \ 1149 "busybox: OK\n" \
1150 "^D\n" 1150 "^D\n"
1151 1151
1152#define mesg_trivial_usage \
1153 "mesg [y|n]"
1154#define mesg_full_usage \
1155 "mesg [Y|N], controls write access to your terminal\n" \
1156 "\ty\tAllow write access to your terminal.\n" \
1157 "\tn\tDisallow write access to your terminal.\n"
1158
1152#define mkdir_trivial_usage \ 1159#define mkdir_trivial_usage \
1153 "[OPTION] DIRECTORY..." 1160 "[OPTION] DIRECTORY..."
1154#define mkdir_full_usage \ 1161#define mkdir_full_usage \
diff --git a/init/Makefile.in b/init/Makefile.in
index 8cc95264d..cd3ead839 100644
--- a/init/Makefile.in
+++ b/init/Makefile.in
@@ -25,6 +25,7 @@ endif
25INIT-y:= 25INIT-y:=
26INIT-$(CONFIG_HALT) += halt.o 26INIT-$(CONFIG_HALT) += halt.o
27INIT-$(CONFIG_INIT) += init.o 27INIT-$(CONFIG_INIT) += init.o
28INIT-$(CONFIG_MESG) += mesg.o
28INIT-$(CONFIG_POWEROFF) += poweroff.o 29INIT-$(CONFIG_POWEROFF) += poweroff.o
29INIT-$(CONFIG_REBOOT) += reboot.o 30INIT-$(CONFIG_REBOOT) += reboot.o
30INIT-$(CONFIG_START_STOP_DAEMON) += start_stop_daemon.o 31INIT-$(CONFIG_START_STOP_DAEMON) += start_stop_daemon.o
diff --git a/init/config.in b/init/config.in
index 58fe1d8e3..e4aa4fbba 100644
--- a/init/config.in
+++ b/init/config.in
@@ -22,6 +22,7 @@ fi
22 22
23bool 'start-stop-daemon' CONFIG_START_STOP_DAEMON 23bool 'start-stop-daemon' CONFIG_START_STOP_DAEMON
24bool 'run-parts' CONFIG_RUN_PARTS 24bool 'run-parts' CONFIG_RUN_PARTS
25bool 'mesg' CONFIG_MESG
25 26
26endmenu 27endmenu
27 28
diff --git a/init/mesg.c b/init/mesg.c
new file mode 100644
index 000000000..f9b46e029
--- /dev/null
+++ b/init/mesg.c
@@ -0,0 +1,58 @@
1/*
2 * mesg implementation for busybox
3 *
4 * Copyright (c) 2002 Manuel Novoa III <mjn3@codepoet.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21#include <unistd.h>
22#include <stdlib.h>
23#include "libbb.h"
24
25#ifdef USE_TTY_GROUP
26#define S_IWGRP_OR_S_IWOTH S_IWGRP
27#else
28#define S_IWGRP_OR_S_IWOTH (S_IWGRP | S_IWOTH)
29#endif
30
31extern int mesg_main(int argc, char *argv[])
32{
33 struct stat sb;
34 char *tty;
35 char c;
36
37 if ((--argc == 0)
38 || ((argc == 1) && (((c = **++argv) == 'y') || (c == 'n')))) {
39 if ((tty = ttyname(STDERR_FILENO)) == NULL) {
40 tty = "ttyname";
41 } else if (stat(tty, &sb) == 0) {
42 if (argc == 0) {
43 puts(((sb.st_mode & (S_IWGRP | S_IWOTH)) ==
44 0) ? "is n" : "is y");
45 return EXIT_SUCCESS;
46 }
47 if (chmod
48 (tty,
49 (c ==
50 'y') ? sb.st_mode | (S_IWGRP_OR_S_IWOTH) : sb.
51 st_mode & ~(S_IWGRP | S_IWOTH)) == 0) {
52 return EXIT_SUCCESS;
53 }
54 }
55 perror_msg_and_die("%s", tty);
56 }
57 show_usage();
58}