1 /* vi: set sw=4 ts=4: */
3 * mesg implementation for busybox
5 * Copyright (c) 2002 Manuel Novoa III <mjn3@codepoet.org>
7 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
13 #define S_IWGRP_OR_S_IWOTH S_IWGRP
15 #define S_IWGRP_OR_S_IWOTH (S_IWGRP | S_IWOTH)
18 int mesg_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
19 int mesg_main(int argc UNUSED_PARAM, char **argv)
28 || (!argv[1] && ((c = argv[0][0]) == 'y' || c == 'n'))
30 tty = xmalloc_ttyname(STDERR_FILENO);
33 } else if (stat(tty, &sb) == 0) {
36 puts((sb.st_mode & (S_IWGRP|S_IWOTH)) ? "is y" : "is n");
39 m = (c == 'y') ? sb.st_mode | S_IWGRP_OR_S_IWOTH
40 : sb.st_mode & ~(S_IWGRP|S_IWOTH);
41 if (chmod(tty, m) == 0) {
45 bb_simple_perror_msg_and_die(tty);