Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/loginutils/getty.c

    r3232 r3621  
    2222 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    2323 */
     24//config:config GETTY
     25//config:   bool "getty"
     26//config:   default y
     27//config:   select FEATURE_SYSLOG
     28//config:   help
     29//config:     getty lets you log in on a tty. It is normally invoked by init.
     30//config:
     31//config:     Note that you can save a few bytes by disabling it and
     32//config:     using login applet directly.
     33//config:     If you need to reset tty attributes before calling login,
     34//config:     this script approximates getty:
     35//config:
     36//config:     exec </dev/$1 >/dev/$1 2>&1 || exit 1
     37//config:     reset
     38//config:     stty sane; stty ispeed 38400; stty ospeed 38400
     39//config:     printf "%s login: " "`hostname`"
     40//config:     read -r login
     41//config:     exec /bin/login "$login"
     42
     43//applet:IF_GETTY(APPLET(getty, BB_DIR_SBIN, BB_SUID_DROP))
     44
     45//kbuild:lib-$(CONFIG_GETTY) += getty.o
    2446
    2547#include "libbb.h"
     
    335357     */
    336358
    337     /* line buffered input (NL or EOL or EOF chars end a line);
    338      * recognize INT/QUIT/SUSP chars;
    339      * echo input chars;
    340      * echo BS-SP-BS on erase character;
    341      * echo kill char specially, not as ^c (ECHOKE controls how exactly);
    342      * erase all input via BS-SP-BS on kill char (else go to next line)
    343      */
    344     G.tty_attrs.c_lflag |= ICANON | ISIG | ECHO | ECHOE | ECHOK | ECHOKE;
     359    /* ICANON  line buffered input (NL or EOL or EOF chars end a line);
     360     * ISIG    recognize INT/QUIT/SUSP chars;
     361     * ECHO    echo input chars;
     362     * ECHOE   echo BS-SP-BS on erase character;
     363     * ECHOK   echo kill char specially, not as ^c (ECHOKE controls how exactly);
     364     * ECHOKE  erase all input via BS-SP-BS on kill char (else go to next line)
     365     * ECHOCTL Echo ctrl chars as ^c (else echo verbatim:
     366     *         e.g. up arrow emits "ESC-something" and thus moves cursor up!)
     367     */
     368    G.tty_attrs.c_lflag |= ICANON | ISIG | ECHO | ECHOE | ECHOK | ECHOKE | ECHOCTL;
    345369    /* Other bits in c_lflag:
    346370     * XCASE   Map uppercase to \lowercase [tried, doesn't work]
    347371     * ECHONL  Echo NL even if ECHO is not set
    348      * ECHOCTL Echo ctrl chars as ^c (else don't echo) - maybe set this?
    349372     * ECHOPRT On erase, echo erased chars
    350373     *         [qwe<BS><BS><BS> input looks like "qwe\ewq/" on screen]
     
    520543}
    521544
     545static void sleep10(void)
     546{
     547    sleep(10);
     548}
     549
    522550int getty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
    523551int getty_main(int argc UNUSED_PARAM, char **argv)
     
    557585            //  getsid(0), getpgid(0));
    558586            bb_perror_msg_and_die("setsid");
     587            /*
     588             * When we can end up here?
     589             * Example: setsid() fails when run alone in interactive shell:
     590             *  # getty 115200 /dev/tty2
     591             * because shell's child (getty) is put in a new process group.
     592             * But doesn't fail if shell is not interactive
     593             * (and therefore doesn't create process groups for pipes),
     594             * or if getty is not the first process in the process group:
     595             *  # true | getty 115200 /dev/tty2
     596             */
    559597        }
    560598        /* Looks like we are already a session leader.
     
    589627
    590628    /* Logging. We want special flavor of error_msg_and_die */
    591     die_sleep = 10;
     629    die_func = sleep10;
    592630    msg_eol = "\r\n";
    593631    /* most likely will internally use fd #3 in CLOEXEC mode: */
     
    696734     * and getty is not suid-root applet */
    697735    /* With -n, logname == NULL, and login will ask for username instead */
    698     BB_EXECLP(G.login, G.login, "--", logname, NULL);
     736    BB_EXECLP(G.login, G.login, "--", logname, (char *)0);
    699737    bb_error_msg_and_die("can't execute '%s'", G.login);
    700738}
Note: See TracChangeset for help on using the changeset viewer.