diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-23 10:17:34 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-23 10:17:34 +0000 |
| commit | 4e70bf4359676b1ecaf658c7550d60a15ec1a02a (patch) | |
| tree | 51504913d74ac02a9b4feba5bdf7716a8cfe4760 | |
| parent | 50e77e1cc12d18716d1ab371ba4b145706e5192d (diff) | |
| download | busybox-w32-4e70bf4359676b1ecaf658c7550d60a15ec1a02a.tar.gz busybox-w32-4e70bf4359676b1ecaf658c7550d60a15ec1a02a.tar.bz2 busybox-w32-4e70bf4359676b1ecaf658c7550d60a15ec1a02a.zip | |
getty: conditionally disable handling of all-caps terminals.
| -rw-r--r-- | loginutils/getty.c | 82 |
1 files changed, 25 insertions, 57 deletions
diff --git a/loginutils/getty.c b/loginutils/getty.c index ebca480bf..9e7cb7a10 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c | |||
| @@ -48,6 +48,9 @@ extern void updwtmp(const char *filename, const struct utmp *ut); | |||
| 48 | * and for line editing at the same time. | 48 | * and for line editing at the same time. |
| 49 | */ | 49 | */ |
| 50 | 50 | ||
| 51 | /* I doubt there are systems which still need this */ | ||
| 52 | #undef HANDLE_ALLCAPS | ||
| 53 | |||
| 51 | #define _PATH_LOGIN "/bin/login" | 54 | #define _PATH_LOGIN "/bin/login" |
| 52 | 55 | ||
| 53 | /* If ISSUE is not defined, agetty will never display the contents of the | 56 | /* If ISSUE is not defined, agetty will never display the contents of the |
| @@ -133,11 +136,13 @@ static const char opt_string[] = "I:LH:f:hil:mt:wn"; | |||
| 133 | /* Storage for things detected while the login name was read. */ | 136 | /* Storage for things detected while the login name was read. */ |
| 134 | 137 | ||
| 135 | struct chardata { | 138 | struct chardata { |
| 136 | int erase; /* erase character */ | 139 | unsigned char erase; /* erase character */ |
| 137 | int kill; /* kill character */ | 140 | unsigned char kill; /* kill character */ |
| 138 | int eol; /* end-of-line character */ | 141 | unsigned char eol; /* end-of-line character */ |
| 139 | int parity; /* what parity did we see */ | 142 | unsigned char parity; /* what parity did we see */ |
| 140 | int capslock; /* upper case without lower case */ | 143 | #ifdef HANDLE_ALLCAPS |
| 144 | unsigned char capslock; /* upper case without lower case */ | ||
| 145 | #endif | ||
| 141 | }; | 146 | }; |
| 142 | 147 | ||
| 143 | /* Initial values for the above. */ | 148 | /* Initial values for the above. */ |
| @@ -147,54 +152,10 @@ static const struct chardata init_chardata = { | |||
| 147 | DEF_KILL, /* default kill character */ | 152 | DEF_KILL, /* default kill character */ |
| 148 | 13, /* default eol char */ | 153 | 13, /* default eol char */ |
| 149 | 0, /* space parity */ | 154 | 0, /* space parity */ |
| 155 | #ifdef HANDLE_ALLCAPS | ||
| 150 | 0, /* no capslock */ | 156 | 0, /* no capslock */ |
| 151 | }; | ||
| 152 | |||
| 153 | #if 0 | ||
| 154 | struct Speedtab { | ||
| 155 | long speed; | ||
| 156 | int code; | ||
| 157 | }; | ||
| 158 | |||
| 159 | static const struct Speedtab speedtab[] = { | ||
| 160 | {50, B50}, | ||
| 161 | {75, B75}, | ||
| 162 | {110, B110}, | ||
| 163 | {134, B134}, | ||
| 164 | {150, B150}, | ||
| 165 | {200, B200}, | ||
| 166 | {300, B300}, | ||
| 167 | {600, B600}, | ||
| 168 | {1200, B1200}, | ||
| 169 | {1800, B1800}, | ||
| 170 | {2400, B2400}, | ||
| 171 | {4800, B4800}, | ||
| 172 | {9600, B9600}, | ||
| 173 | #ifdef B19200 | ||
| 174 | {19200, B19200}, | ||
| 175 | #endif | ||
| 176 | #ifdef B38400 | ||
| 177 | {38400, B38400}, | ||
| 178 | #endif | ||
| 179 | #ifdef EXTA | ||
| 180 | {19200, EXTA}, | ||
| 181 | #endif | ||
| 182 | #ifdef EXTB | ||
| 183 | {38400, EXTB}, | ||
| 184 | #endif | 157 | #endif |
| 185 | #ifdef B57600 | ||
| 186 | {57600, B57600}, | ||
| 187 | #endif | ||
| 188 | #ifdef B115200 | ||
| 189 | {115200, B115200}, | ||
| 190 | #endif | ||
| 191 | #ifdef B230400 | ||
| 192 | {230400, B230400}, | ||
| 193 | #endif | ||
| 194 | {0, 0}, | ||
| 195 | }; | 158 | }; |
| 196 | #endif | ||
| 197 | |||
| 198 | 159 | ||
| 199 | #ifdef SYSV_STYLE | 160 | #ifdef SYSV_STYLE |
| 200 | #ifdef CONFIG_FEATURE_UTMP | 161 | #ifdef CONFIG_FEATURE_UTMP |
| @@ -211,7 +172,7 @@ static char *fakehost = NULL; | |||
| 211 | #ifdef DEBUGGING | 172 | #ifdef DEBUGGING |
| 212 | #define debug(s) fprintf(dbf,s); fflush(dbf) | 173 | #define debug(s) fprintf(dbf,s); fflush(dbf) |
| 213 | #define DEBUGTERM "/dev/ttyp0" | 174 | #define DEBUGTERM "/dev/ttyp0" |
| 214 | FILE *dbf; | 175 | static FILE *dbf; |
| 215 | #else | 176 | #else |
| 216 | #define debug(s) /* nothing */ | 177 | #define debug(s) /* nothing */ |
| 217 | #endif | 178 | #endif |
| @@ -415,7 +376,7 @@ static void termio_init(struct termio *tp, int speed, struct options *op) | |||
| 415 | * Initial termio settings: 8-bit characters, raw-mode, blocking i/o. | 376 | * Initial termio settings: 8-bit characters, raw-mode, blocking i/o. |
| 416 | * Special characters are set after we have read the login name; all | 377 | * Special characters are set after we have read the login name; all |
| 417 | * reads will be done in raw mode anyway. Errors will be dealt with | 378 | * reads will be done in raw mode anyway. Errors will be dealt with |
| 418 | * lateron. | 379 | * later on. |
| 419 | */ | 380 | */ |
| 420 | #ifdef __linux__ | 381 | #ifdef __linux__ |
| 421 | /* flush input and output queues, important for modems! */ | 382 | /* flush input and output queues, important for modems! */ |
| @@ -474,7 +435,7 @@ static void auto_baud(struct termio *tp) | |||
| 474 | 435 | ||
| 475 | /* | 436 | /* |
| 476 | * Use 7-bit characters, don't block if input queue is empty. Errors will | 437 | * Use 7-bit characters, don't block if input queue is empty. Errors will |
| 477 | * be dealt with lateron. | 438 | * be dealt with later on. |
| 478 | */ | 439 | */ |
| 479 | 440 | ||
| 480 | iflag = tp->c_iflag; | 441 | iflag = tp->c_iflag; |
| @@ -503,7 +464,7 @@ static void auto_baud(struct termio *tp) | |||
| 503 | } | 464 | } |
| 504 | } | 465 | } |
| 505 | } | 466 | } |
| 506 | /* Restore terminal settings. Errors will be dealt with lateron. */ | 467 | /* Restore terminal settings. Errors will be dealt with later on. */ |
| 507 | 468 | ||
| 508 | tp->c_iflag = iflag; | 469 | tp->c_iflag = iflag; |
| 509 | tp->c_cc[VMIN] = vmin; | 470 | tp->c_cc[VMIN] = vmin; |
| @@ -525,12 +486,13 @@ static void next_speed(struct termio *tp, struct options *op) | |||
| 525 | /* do_prompt - show login prompt, optionally preceded by /etc/issue contents */ | 486 | /* do_prompt - show login prompt, optionally preceded by /etc/issue contents */ |
| 526 | static void do_prompt(struct options *op, struct termio *tp) | 487 | static void do_prompt(struct options *op, struct termio *tp) |
| 527 | { | 488 | { |
| 528 | #ifdef ISSUE /* optional: show /etc/issue */ | 489 | #ifdef ISSUE |
| 529 | print_login_issue(op->issue, op->tty); | 490 | print_login_issue(op->issue, op->tty); |
| 530 | #endif | 491 | #endif |
| 531 | print_login_prompt(); | 492 | print_login_prompt(); |
| 532 | } | 493 | } |
| 533 | 494 | ||
| 495 | #ifdef HANDLE_ALLCAPS | ||
| 534 | /* caps_lock - string contains upper case without lower case */ | 496 | /* caps_lock - string contains upper case without lower case */ |
| 535 | /* returns 1 if true, 0 if false */ | 497 | /* returns 1 if true, 0 if false */ |
| 536 | static int caps_lock(const char *s) | 498 | static int caps_lock(const char *s) |
| @@ -540,6 +502,7 @@ static int caps_lock(const char *s) | |||
| 540 | return 0; | 502 | return 0; |
| 541 | return 1; | 503 | return 1; |
| 542 | } | 504 | } |
| 505 | #endif | ||
| 543 | 506 | ||
| 544 | #define logname bb_common_bufsiz1 | 507 | #define logname bb_common_bufsiz1 |
| 545 | /* get_logname - get user name, establish parity, speed, erase, kill, eol */ | 508 | /* get_logname - get user name, establish parity, speed, erase, kill, eol */ |
| @@ -551,7 +514,7 @@ static char *get_logname(struct options *op, struct chardata *cp, struct termio | |||
| 551 | char ascval; /* low 7 bits of input character */ | 514 | char ascval; /* low 7 bits of input character */ |
| 552 | int bits; /* # of "1" bits per character */ | 515 | int bits; /* # of "1" bits per character */ |
| 553 | int mask; /* mask with 1 bit up */ | 516 | int mask; /* mask with 1 bit up */ |
| 554 | static const char *const erase[] = { /* backspace-space-backspace */ | 517 | static const char erase[][3] = { /* backspace-space-backspace */ |
| 555 | "\010\040\010", /* space parity */ | 518 | "\010\040\010", /* space parity */ |
| 556 | "\010\040\010", /* odd parity */ | 519 | "\010\040\010", /* odd parity */ |
| 557 | "\210\240\210", /* even parity */ | 520 | "\210\240\210", /* even parity */ |
| @@ -601,7 +564,8 @@ static char *get_logname(struct options *op, struct chardata *cp, struct termio | |||
| 601 | for (bits = 1, mask = 1; mask & 0177; mask <<= 1) | 564 | for (bits = 1, mask = 1; mask & 0177; mask <<= 1) |
| 602 | if (mask & ascval) | 565 | if (mask & ascval) |
| 603 | bits++; /* count "1" bits */ | 566 | bits++; /* count "1" bits */ |
| 604 | cp->parity |= ((bits & 1) ? 1 : 2); | 567 | /* ... |= 2 - even, 1 - odd */ |
| 568 | cp->parity |= 2 - (bits & 1); | ||
| 605 | } | 569 | } |
| 606 | /* Do erase, kill and end-of-line processing. */ | 570 | /* Do erase, kill and end-of-line processing. */ |
| 607 | 571 | ||
| @@ -645,12 +609,14 @@ static char *get_logname(struct options *op, struct chardata *cp, struct termio | |||
| 645 | } | 609 | } |
| 646 | /* Handle names with upper case and no lower case. */ | 610 | /* Handle names with upper case and no lower case. */ |
| 647 | 611 | ||
| 612 | #ifdef HANDLE_ALLCAPS | ||
| 648 | cp->capslock = caps_lock(logname); | 613 | cp->capslock = caps_lock(logname); |
| 649 | if (cp->capslock) { | 614 | if (cp->capslock) { |
| 650 | for (bp = logname; *bp; bp++) | 615 | for (bp = logname; *bp; bp++) |
| 651 | if (isupper(*bp)) | 616 | if (isupper(*bp)) |
| 652 | *bp = tolower(*bp); /* map name to lower case */ | 617 | *bp = tolower(*bp); /* map name to lower case */ |
| 653 | } | 618 | } |
| 619 | #endif | ||
| 654 | return logname; | 620 | return logname; |
| 655 | } | 621 | } |
| 656 | 622 | ||
| @@ -698,11 +664,13 @@ static void termio_final(struct options *op, struct termio *tp, struct chardata | |||
| 698 | } | 664 | } |
| 699 | /* Account for upper case without lower case. */ | 665 | /* Account for upper case without lower case. */ |
| 700 | 666 | ||
| 667 | #ifdef HANDLE_ALLCAPS | ||
| 701 | if (cp->capslock) { | 668 | if (cp->capslock) { |
| 702 | tp->c_iflag |= IUCLC; | 669 | tp->c_iflag |= IUCLC; |
| 703 | tp->c_lflag |= XCASE; | 670 | tp->c_lflag |= XCASE; |
| 704 | tp->c_oflag |= OLCUC; | 671 | tp->c_oflag |= OLCUC; |
| 705 | } | 672 | } |
| 673 | #endif | ||
| 706 | /* Optionally enable hardware flow control */ | 674 | /* Optionally enable hardware flow control */ |
| 707 | 675 | ||
| 708 | #ifdef CRTSCTS | 676 | #ifdef CRTSCTS |
