Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/init/mesg.c


Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/init/mesg.c

    r1765 r2725  
    55 * Copyright (c) 2002 Manuel Novoa III  <mjn3@codepoet.org>
    66 *
    7  * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
     7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    88 */
     9
     10//applet:IF_MESG(APPLET(mesg, _BB_DIR_USR_BIN, _BB_SUID_DROP))
     11
     12//kbuild:lib-$(CONFIG_MESG) += mesg.o
     13
     14//config:config MESG
     15//config:   bool "mesg"
     16//config:   default y
     17//config:   help
     18//config:     Mesg controls access to your terminal by others. It is typically
     19//config:     used to allow or disallow other users to write to your terminal
     20
     21//usage:#define mesg_trivial_usage
     22//usage:       "[y|n]"
     23//usage:#define mesg_full_usage "\n\n"
     24//usage:       "Control write access to your terminal\n"
     25//usage:       "    y   Allow write access to your terminal\n"
     26//usage:       "    n   Disallow write access to your terminal"
    927
    1028#include "libbb.h"
    1129
    1230#ifdef USE_TTY_GROUP
    13 #define S_IWGRP_OR_S_IWOTH  S_IWGRP
     31#define S_IWGRP_OR_S_IWOTH  S_IWGRP
    1432#else
    15 #define S_IWGRP_OR_S_IWOTH  (S_IWGRP | S_IWOTH)
     33#define S_IWGRP_OR_S_IWOTH  (S_IWGRP | S_IWOTH)
    1634#endif
    1735
    18 int mesg_main(int argc, char **argv);
    19 int mesg_main(int argc, char **argv)
     36int mesg_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
     37int mesg_main(int argc UNUSED_PARAM, char **argv)
    2038{
    2139    struct stat sb;
     
    2341    char c = 0;
    2442
    25     if (--argc == 0
    26      || (argc == 1 && ((c = **++argv) == 'y' || c == 'n'))
     43    argv++;
     44
     45    if (!argv[0]
     46     || (!argv[1] && ((c = argv[0][0]) == 'y' || c == 'n'))
    2747    ) {
    28         tty = ttyname(STDERR_FILENO);
     48        tty = xmalloc_ttyname(STDERR_FILENO);
    2949        if (tty == NULL) {
    3050            tty = "ttyname";
    3151        } else if (stat(tty, &sb) == 0) {
    3252            mode_t m;
    33             if (argc == 0) {
     53            if (c == 0) {
    3454                puts((sb.st_mode & (S_IWGRP|S_IWOTH)) ? "is y" : "is n");
    3555                return EXIT_SUCCESS;
     
    4161            }
    4262        }
    43         bb_perror_msg_and_die("%s", tty);
     63        bb_simple_perror_msg_and_die(tty);
    4464    }
    4565    bb_show_usage();
Note: See TracChangeset for help on using the changeset viewer.