Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/loginutils/getty.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/loginutils/getty.c
r3232 r3621 22 22 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 23 23 */ 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 24 46 25 47 #include "libbb.h" … … 335 357 */ 336 358 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; 345 369 /* Other bits in c_lflag: 346 370 * XCASE Map uppercase to \lowercase [tried, doesn't work] 347 371 * ECHONL Echo NL even if ECHO is not set 348 * ECHOCTL Echo ctrl chars as ^c (else don't echo) - maybe set this?349 372 * ECHOPRT On erase, echo erased chars 350 373 * [qwe<BS><BS><BS> input looks like "qwe\ewq/" on screen] … … 520 543 } 521 544 545 static void sleep10(void) 546 { 547 sleep(10); 548 } 549 522 550 int getty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 523 551 int getty_main(int argc UNUSED_PARAM, char **argv) … … 557 585 // getsid(0), getpgid(0)); 558 586 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 */ 559 597 } 560 598 /* Looks like we are already a session leader. … … 589 627 590 628 /* Logging. We want special flavor of error_msg_and_die */ 591 die_ sleep =10;629 die_func = sleep10; 592 630 msg_eol = "\r\n"; 593 631 /* most likely will internally use fd #3 in CLOEXEC mode: */ … … 696 734 * and getty is not suid-root applet */ 697 735 /* 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); 699 737 bb_error_msg_and_die("can't execute '%s'", G.login); 700 738 }
Note:
See TracChangeset
for help on using the changeset viewer.