1 /* vi: set sw=4 ts=4: */
2 /* agetty.c - another getty program for Linux. By W. Z. Venema 1989
3 Ported to Linux by Peter Orbaek <poe@daimi.aau.dk>
4 This program is freely distributable. The entire man-page used to
5 be here. Now read the real man-page agetty.8 instead.
7 -f option added by Eric Rasmussen <ear@usfirst.org> - 12/28/95
9 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org>
10 - added Native Language Support
12 1999-05-05 Thorsten Kranzkowski <dl8bcu@gmx.net>
13 - enable hardware flow control before displaying /etc/issue
21 #include <sys/ioctl.h>
24 #include <sys/signal.h>
33 #define _PATH_LOGIN "/bin/login"
36 #include <sys/param.h>
40 /* If USE_SYSLOG is undefined all diagnostics go directly to /dev/console. */
47 * Some heuristics to find out what environment we are in: if it is not
48 * System V, assume it is SunOS 4.
51 #ifdef LOGIN_PROCESS /* defined in System V utmp.h */
52 #define SYSV_STYLE /* select System V style getty */
53 #ifdef CONFIG_FEATURE_U_W_TMP
54 extern void updwtmp(const char *filename, const struct utmp *ut);
56 #endif /* LOGIN_PROCESS */
59 * Things you may want to modify.
61 * If ISSUE is not defined, agetty will never display the contents of the
62 * /etc/issue file. You will not want to spit out large "issue" files at the
63 * wrong baud rate. Relevant for System V only.
65 * You may disagree with the default line-editing etc. characters defined
66 * below. Note, however, that DEL cannot be used for interrupt generation
67 * and for line editing at the same time.
71 #define ISSUE "/etc/issue" /* displayed before the login prompt */
72 #include <sys/utsname.h>
76 /* Some shorthands for control characters. */
78 #define CTL(x) (x ^ 0100) /* Assumes ASCII dialect */
79 #define CR CTL('M') /* carriage return */
80 #define NL CTL('J') /* line feed */
81 #define BS CTL('H') /* back space */
82 #define DEL CTL('?') /* delete */
84 /* Defaults for line-editing etc. characters; you may want to change this. */
86 #define DEF_ERASE DEL /* default erase character */
87 #define DEF_INTR CTL('C') /* default interrupt character */
88 #define DEF_QUIT CTL('\\') /* default quit char */
89 #define DEF_KILL CTL('U') /* default kill char */
90 #define DEF_EOF CTL('D') /* default EOF char */
92 #define DEF_SWITCH 0 /* default switch char */
95 * SunOS 4.1.1 termio is broken. We must use the termios stuff instead,
96 * because the termio -> termios translation does not clear the termios
97 * CIBAUD bits. Therefore, the tty driver would sometimes report that input
98 * baud rate != output baud rate. I did not notice that problem with SunOS
99 * 4.1. We will use termios where available, and termio otherwise.
102 /* linux 0.12 termio is broken too, if we use it c_cc[VERASE] isn't set
103 properly, but all is well if we use termios?! */
109 #define termio termios
110 #define TCGETA TCGETS
111 #define TCSETA TCSETS
112 #define TCSETAW TCSETSW
116 * This program tries to not use the standard-i/o library. This keeps the
117 * executable small on systems that do not have shared libraries (System V
125 * When multiple baud rates are specified on the command line, the first one
126 * we will try is the first one specified.
129 #define FIRST_SPEED 0
131 /* Storage for command-line options. */
133 #define MAX_SPEED 10 /* max. nr. of baud rates */
136 int flags; /* toggle switches, see below */
137 int timeout; /* time-out period */
138 char *login; /* login program */
139 char *tty; /* name of tty */
140 char *initstring; /* modem init string */
141 char *issue; /* alternative issue file */
142 int numspeed; /* number of baud rates to try */
143 int speeds[MAX_SPEED]; /* baud rates to be tried */
146 #define F_PARSE (1<<0) /* process modem status messages */
147 #define F_ISSUE (1<<1) /* display /etc/issue */
148 #define F_RTSCTS (1<<2) /* enable RTS/CTS flow control */
149 #define F_LOCAL (1<<3) /* force local */
150 #define F_INITSTRING (1<<4) /* initstring is set */
151 #define F_WAITCRLF (1<<5) /* wait for CR or LF */
152 #define F_CUSTISSUE (1<<6) /* give alternative issue file */
153 #define F_NOPROMPT (1<<7) /* don't ask for login name! */
155 /* Storage for things detected while the login name was read. */
158 int erase; /* erase character */
159 int kill; /* kill character */
160 int eol; /* end-of-line character */
161 int parity; /* what parity did we see */
162 int capslock; /* upper case without lower case */
165 /* Initial values for the above. */
167 struct chardata init_chardata = {
168 DEF_ERASE, /* default erase character */
169 DEF_KILL, /* default kill character */
170 13, /* default eol char */
171 0, /* space parity */
180 static struct Speedtab speedtab[] = {
218 static void parse_args(int argc, char **argv, struct options *op);
219 static void parse_speeds(struct options *op, char *arg);
220 static void open_tty(char *tty, struct termio *tp, int local);
221 static void termio_init(struct termio *tp, int speed, struct options *op);
222 static void auto_baud(struct termio *tp);
223 static void do_prompt(struct options *op, struct termio *tp);
224 static void next_speed(struct termio *tp, struct options *op);
225 static char *get_logname(struct options *op, struct chardata *cp,
228 static void termio_final(struct options *op, struct termio *tp,
230 struct chardata *cp);
231 static int caps_lock(const char *s);
232 static int bcode(const char *s);
233 static void error(const char *fmt, ...) __attribute__ ((noreturn));
235 #ifdef CONFIG_FEATURE_U_W_TMP
236 static void update_utmp(char *line);
239 /* The following is used for understandable diagnostics. */
241 /* Fake hostname for ut_host specified on command line. */
242 static char *fakehost = NULL;
246 #define debug(s) fprintf(dbf,s); fflush(dbf)
247 #define DEBUGTERM "/dev/ttyp0"
250 #define debug(s) /* nothing */
253 int getty_main(int argc, char **argv)
255 char *logname = NULL; /* login name, given to /bin/login */
256 struct chardata chardata; /* set by get_logname() */
257 struct termio termio; /* terminal mode bits */
258 static struct options options = {
259 F_ISSUE, /* show /etc/issue (SYSV_STYLE) */
261 _PATH_LOGIN, /* default login program */
262 "tty1", /* default tty line */
263 "", /* modem init string */
264 ISSUE, /* default issue file */
265 0, /* no baud rates known yet */
269 dbf = xfopen(DEBUGTERM, "w");
274 for (i = 1; i < argc; i++) {
281 /* Parse command-line arguments. */
283 parse_args(argc, argv, &options);
289 /* Update the utmp file. */
293 #ifdef CONFIG_FEATURE_U_W_TMP
294 update_utmp(options.tty);
298 debug("calling open_tty\n");
299 /* Open the tty as standard { input, output, error }. */
300 open_tty(options.tty, &termio, options.flags & F_LOCAL);
307 ioctl(0, TIOCSPGRP, &iv);
310 /* Initialize the termio settings (raw mode, eight-bit, blocking i/o). */
311 debug("calling termio_init\n");
312 termio_init(&termio, options.speeds[FIRST_SPEED], &options);
314 /* write the modem init string and DON'T flush the buffers */
315 if (options.flags & F_INITSTRING) {
316 debug("writing init string\n");
317 write(1, options.initstring, strlen(options.initstring));
320 if (!(options.flags & F_LOCAL)) {
321 /* go to blocking write mode unless -L is specified */
322 fcntl(1, F_SETFL, fcntl(1, F_GETFL, 0) & ~O_NONBLOCK);
325 /* Optionally detect the baud rate from the modem status message. */
326 debug("before autobaud\n");
327 if (options.flags & F_PARSE)
330 /* Set the optional timer. */
332 (void) alarm((unsigned) options.timeout);
334 /* optionally wait for CR or LF before writing /etc/issue */
335 if (options.flags & F_WAITCRLF) {
338 debug("waiting for cr-lf\n");
339 while (read(0, &ch, 1) == 1) {
340 ch &= 0x7f; /* strip "parity bit" */
342 fprintf(dbf, "read %c\n", ch);
344 if (ch == '\n' || ch == '\r')
349 chardata = init_chardata;
350 if (!(options.flags & F_NOPROMPT)) {
351 /* Read the login name. */
352 debug("reading login name\n");
353 /* while ((logname = get_logname(&options, &chardata, &termio)) == 0) */
354 while ((logname = get_logname(&options, &chardata, &termio)) ==
355 NULL) next_speed(&termio, &options);
363 /* Finalize the termio settings. */
365 termio_final(&options, &termio, &chardata);
367 /* Now the newline character should be properly written. */
369 (void) write(1, "\n", 1);
371 /* Let the login program take care of password validation. */
373 (void) execl(options.login, options.login, "--", logname, (char *) 0);
374 error("%s: can't exec %s: %m", options.tty, options.login);
377 /* parse-args - parse command-line arguments */
379 static void parse_args(int argc, char **argv, struct options *op)
381 extern char *optarg; /* getopt */
382 extern int optind; /* getopt */
385 while (isascii(c = getopt(argc, argv, "I:LH:f:hil:mt:wn"))) {
388 if (!(op->initstring = strdup(optarg)))
389 error(memory_exhausted);
395 /* copy optarg into op->initstring decoding \ddd
396 octal codes into chars */
402 *q++ = process_escape_sequence(&p);
409 op->flags |= F_INITSTRING;
412 case 'L': /* force local */
413 op->flags |= F_LOCAL;
415 case 'H': /* fake login host */
418 case 'f': /* custom issue file */
419 op->flags |= F_CUSTISSUE;
422 case 'h': /* enable h/w flow control */
423 op->flags |= F_RTSCTS;
425 case 'i': /* do not show /etc/issue */
426 op->flags &= ~F_ISSUE;
429 op->login = optarg; /* non-default login program */
431 case 'm': /* parse modem status message */
432 op->flags |= F_PARSE;
435 op->flags |= F_NOPROMPT;
437 case 't': /* time out */
438 if ((op->timeout = atoi(optarg)) <= 0)
439 error("bad timeout value: %s", optarg);
442 op->flags |= F_WAITCRLF;
448 debug("after getopt loop\n");
449 if (argc < optind + 2) /* check parameter count */
452 /* we loosen up a bit and accept both "baudrate tty" and "tty baudrate" */
453 if ('0' <= argv[optind][0] && argv[optind][0] <= '9') {
454 /* a number first, assume it's a speed (BSD style) */
455 parse_speeds(op, argv[optind++]); /* baud rate(s) */
456 op->tty = argv[optind]; /* tty name */
458 op->tty = argv[optind++]; /* tty name */
459 parse_speeds(op, argv[optind]); /* baud rate(s) */
463 if (argc > optind && argv[optind])
464 setenv("TERM", argv[optind], 1);
466 debug("exiting parseargs\n");
469 /* parse_speeds - parse alternate baud rates */
471 static void parse_speeds(struct options *op, char *arg)
475 debug("entered parse_speeds\n");
476 for (cp = strtok(arg, ","); cp != 0; cp = strtok((char *) 0, ",")) {
477 if ((op->speeds[op->numspeed++] = bcode(cp)) <= 0)
478 error("bad speed: %s", cp);
479 if (op->numspeed > MAX_SPEED)
480 error("too many alternate speeds");
482 debug("exiting parsespeeds\n");
486 #ifdef CONFIG_FEATURE_U_W_TMP
488 /* update_utmp - update our utmp entry */
489 static void update_utmp(char *line)
494 int mypid = getpid();
495 #if ! (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1))
500 * The utmp file holds miscellaneous information about things started by
501 * /sbin/init and other system-related events. Our purpose is to update
502 * the utmp entry for the current process, in particular the process type
503 * and the tty line we are listening to. Return successfully only if the
504 * utmp file can be opened for update, and if we are able to find our
505 * entry in the utmp file.
507 utmpname(_PATH_UTMP);
509 while ((utp = getutent())
510 && !(utp->ut_type == INIT_PROCESS && utp->ut_pid == mypid)) /* nothing */
514 memcpy(&ut, utp, sizeof(ut));
516 /* some inits don't initialize utmp... */
517 memset(&ut, 0, sizeof(ut));
518 strncpy(ut.ut_id, line + 3, sizeof(ut.ut_id));
522 strncpy(ut.ut_user, "LOGIN", sizeof(ut.ut_user));
523 strncpy(ut.ut_line, line, sizeof(ut.ut_line));
525 strncpy(ut.ut_host, fakehost, sizeof(ut.ut_host));
528 ut.ut_type = LOGIN_PROCESS;
535 updwtmp(_PATH_WTMP, &ut);
539 #endif /* CONFIG_FEATURE_U_W_TMP */
540 #endif /* SYSV_STYLE */
542 /* open_tty - set up tty as standard { input, output, error } */
543 static void open_tty(char *tty, struct termio *tp, int local)
545 /* Get rid of the present standard { output, error} if any. */
549 errno = 0; /* ignore above errors */
551 /* Set up new standard input, unless we are given an already opened port. */
553 if (strcmp(tty, "-")) {
556 /* Sanity checks... */
559 error("/dev: chdir() failed: %m");
560 if (stat(tty, &st) < 0)
561 error("/dev/%s: %m", tty);
562 if ((st.st_mode & S_IFMT) != S_IFCHR)
563 error("/dev/%s: not a character device", tty);
565 /* Open the tty as standard input. */
568 errno = 0; /* ignore close(2) errors */
571 if (open(tty, O_RDWR | O_NONBLOCK, 0) != 0)
572 error("/dev/%s: cannot open as standard input: %m", tty);
577 * Standard input should already be connected to an open port. Make
578 * sure it is open for read/write.
581 if ((fcntl(0, F_GETFL, 0) & O_RDWR) != O_RDWR)
582 error("%s: not open for read/write", tty);
585 /* Set up standard output and standard error file descriptors. */
587 if (dup(0) != 1 || dup(0) != 2) /* set up stdout and stderr */
588 error("%s: dup problem: %m", tty); /* we have a problem */
591 * The following ioctl will fail if stdin is not a tty, but also when
592 * there is noise on the modem control lines. In the latter case, the
593 * common course of action is (1) fix your cables (2) give the modem more
594 * time to properly reset after hanging up. SunOS users can achieve (2)
595 * by patching the SunOS kernel variable "zsadtrlow" to a larger value;
596 * 5 seconds seems to be a good value.
599 if (ioctl(0, TCGETA, tp) < 0)
600 error("%s: ioctl: %m", tty);
603 * It seems to be a terminal. Set proper protections and ownership. Mode
604 * 0622 is suitable for SYSV <4 because /bin/login does not change
605 * protections. SunOS 4 login will change the protections to 0620 (write
606 * access for group tty) after the login has succeeded.
611 /* tty to root.dialout 660 */
615 id = (gr = getgrnam("dialout")) ? gr->gr_gid : 0;
619 /* vcs,vcsa to root.sys 600 */
620 if (!strncmp(tty, "tty", 3) && isdigit(tty[3])) {
623 if (!(vcs = strdup(tty)))
624 error("Can't malloc for vcs");
625 if (!(vcsa = malloc(strlen(tty) + 2)))
626 error("Can't malloc for vcsa");
628 strcpy(vcs + 3, tty + 3);
629 strcpy(vcsa, "vcsa");
630 strcpy(vcsa + 4, tty + 3);
632 id = (gr = getgrnam("sys")) ? gr->gr_gid : 0;
643 (void) chown(tty, 0, 0); /* root, sys */
644 (void) chmod(tty, 0622); /* crw--w--w- */
645 errno = 0; /* ignore above errors */
649 /* termio_init - initialize termio settings */
651 static void termio_init(struct termio *tp, int speed, struct options *op)
655 * Initial termio settings: 8-bit characters, raw-mode, blocking i/o.
656 * Special characters are set after we have read the login name; all
657 * reads will be done in raw mode anyway. Errors will be dealt with
661 /* flush input and output queues, important for modems! */
662 (void) ioctl(0, TCFLSH, TCIOFLUSH);
665 tp->c_cflag = CS8 | HUPCL | CREAD | speed;
666 if (op->flags & F_LOCAL) {
667 tp->c_cflag |= CLOCAL;
670 tp->c_iflag = tp->c_lflag = tp->c_oflag = tp->c_line = 0;
674 /* Optionally enable hardware flow control */
677 if (op->flags & F_RTSCTS)
678 tp->c_cflag |= CRTSCTS;
681 (void) ioctl(0, TCSETA, tp);
683 /* go to blocking input even in local mode */
684 fcntl(0, F_SETFL, fcntl(0, F_GETFL, 0) & ~O_NONBLOCK);
686 debug("term_io 2\n");
689 /* auto_baud - extract baud rate from modem status message */
690 static void auto_baud(struct termio *tp)
700 * This works only if the modem produces its status code AFTER raising
701 * the DCD line, and if the computer is fast enough to set the proper
702 * baud rate before the message has gone by. We expect a message of the
705 * <junk><number><junk>
707 * The number is interpreted as the baud rate of the incoming call. If the
708 * modem does not tell us the baud rate within one second, we will keep
709 * using the current baud rate. It is advisable to enable BREAK
710 * processing (comma-separated list of baud rates) if the processing of
711 * modem status messages is enabled.
715 * Use 7-bit characters, don't block if input queue is empty. Errors will
716 * be dealt with lateron.
720 tp->c_iflag |= ISTRIP; /* enable 8th-bit stripping */
721 vmin = tp->c_cc[VMIN];
722 tp->c_cc[VMIN] = 0; /* don't block if queue empty */
723 (void) ioctl(0, TCSETA, tp);
726 * Wait for a while, then read everything the modem has said so far and
727 * try to extract the speed of the dial-in call.
731 if ((nread = read(0, buf, sizeof(buf) - 1)) > 0) {
733 for (bp = buf; bp < buf + nread; bp++) {
734 if (isascii(*bp) && isdigit(*bp)) {
735 if ((speed = bcode(bp))) {
736 tp->c_cflag &= ~CBAUD;
737 tp->c_cflag |= speed;
743 /* Restore terminal settings. Errors will be dealt with lateron. */
746 tp->c_cc[VMIN] = vmin;
747 (void) ioctl(0, TCSETA, tp);
750 /* do_prompt - show login prompt, optionally preceded by /etc/issue contents */
751 static void do_prompt(struct options *op, struct termio *tp)
753 #ifdef ISSUE /* optional: show /etc/issue */
754 print_login_issue(op->issue, op->tty);
756 print_login_prompt();
759 /* next_speed - select next baud rate */
760 static void next_speed(struct termio *tp, struct options *op)
762 static int baud_index = FIRST_SPEED; /* current speed index */
764 baud_index = (baud_index + 1) % op->numspeed;
765 tp->c_cflag &= ~CBAUD;
766 tp->c_cflag |= op->speeds[baud_index];
767 (void) ioctl(0, TCSETA, tp);
770 /* get_logname - get user name, establish parity, speed, erase, kill, eol */
771 /* return NULL on failure, logname on success */
772 static char *get_logname(struct options *op, struct chardata *cp, struct termio *tp)
774 static char logname[BUFSIZ];
776 char c; /* input character, full eight bits */
777 char ascval; /* low 7 bits of input character */
778 int bits; /* # of "1" bits per character */
779 int mask; /* mask with 1 bit up */
780 static char *erase[] = { /* backspace-space-backspace */
781 "\010\040\010", /* space parity */
782 "\010\040\010", /* odd parity */
783 "\210\240\210", /* even parity */
784 "\210\240\210", /* no parity */
787 /* Initialize kill, erase, parity etc. (also after switching speeds). */
791 /* Flush pending input (esp. after parsing or switching the baud rate). */
794 (void) ioctl(0, TCFLSH, TCIFLUSH);
796 /* Prompt for and read a login name. */
798 for (*logname = 0; *logname == 0; /* void */ ) {
800 /* Write issue file and prompt, with "parity" bit == 0. */
804 /* Read name, watch for break, parity, erase, kill, end-of-line. */
806 for (bp = logname, cp->eol = 0; cp->eol == 0; /* void */ ) {
808 /* Do not report trivial EINTR/EIO errors. */
810 if (read(0, &c, 1) < 1) {
811 if (errno == EINTR || errno == EIO)
813 error("%s: read: %m", op->tty);
815 /* Do BREAK handling elsewhere. */
817 if ((c == 0) && op->numspeed > 1)
821 /* Do parity bit handling. */
823 if (c != (ascval = (c & 0177))) { /* "parity" bit on ? */
824 for (bits = 1, mask = 1; mask & 0177; mask <<= 1)
826 bits++; /* count "1" bits */
827 cp->parity |= ((bits & 1) ? 1 : 2);
829 /* Do erase, kill and end-of-line processing. */
834 *bp = 0; /* terminate logname */
835 cp->eol = ascval; /* set end-of-line char */
840 cp->erase = ascval; /* set erase character */
842 (void) write(1, erase[cp->parity], 3);
848 cp->kill = ascval; /* set kill character */
849 while (bp > logname) {
850 (void) write(1, erase[cp->parity], 3);
857 if (!isascii(ascval) || !isprint(ascval)) {
858 /* ignore garbage characters */ ;
859 } else if (bp - logname >= sizeof(logname) - 1) {
860 error("%s: input overrun", op->tty);
862 (void) write(1, &c, 1); /* echo the character */
863 *bp++ = ascval; /* and store it */
869 /* Handle names with upper case and no lower case. */
871 if ((cp->capslock = caps_lock(logname))) {
872 for (bp = logname; *bp; bp++)
874 *bp = tolower(*bp); /* map name to lower case */
879 /* termio_final - set the final tty mode bits */
880 static void termio_final(struct options *op, struct termio *tp, struct chardata *cp)
882 /* General terminal-independent stuff. */
884 tp->c_iflag |= IXON | IXOFF; /* 2-way flow control */
885 tp->c_lflag |= ICANON | ISIG | ECHO | ECHOE | ECHOK | ECHOKE;
886 /* no longer| ECHOCTL | ECHOPRT */
887 tp->c_oflag |= OPOST;
888 /* tp->c_cflag = 0; */
889 tp->c_cc[VINTR] = DEF_INTR; /* default interrupt */
890 tp->c_cc[VQUIT] = DEF_QUIT; /* default quit */
891 tp->c_cc[VEOF] = DEF_EOF; /* default EOF character */
892 tp->c_cc[VEOL] = DEF_EOL;
893 tp->c_cc[VSWTC] = DEF_SWITCH; /* default switch character */
895 /* Account for special characters seen in input. */
898 tp->c_iflag |= ICRNL; /* map CR in input to NL */
899 tp->c_oflag |= ONLCR; /* map NL in output to CR-NL */
901 tp->c_cc[VERASE] = cp->erase; /* set erase character */
902 tp->c_cc[VKILL] = cp->kill; /* set kill character */
904 /* Account for the presence or absence of parity bits in input. */
906 switch (cp->parity) {
907 case 0: /* space (always 0) parity */
909 case 1: /* odd parity */
910 tp->c_cflag |= PARODD;
912 case 2: /* even parity */
913 tp->c_cflag |= PARENB;
914 tp->c_iflag |= INPCK | ISTRIP;
916 case (1 | 2): /* no parity bit */
917 tp->c_cflag &= ~CSIZE;
921 /* Account for upper case without lower case. */
924 tp->c_iflag |= IUCLC;
925 tp->c_lflag |= XCASE;
926 tp->c_oflag |= OLCUC;
928 /* Optionally enable hardware flow control */
931 if (op->flags & F_RTSCTS)
932 tp->c_cflag |= CRTSCTS;
935 /* Finally, make the new settings effective */
937 if (ioctl(0, TCSETA, tp) < 0)
938 error("%s: ioctl: TCSETA: %m", op->tty);
941 /* caps_lock - string contains upper case without lower case */
942 /* returns 1 if true, 0 if false */
943 static int caps_lock(const char *s)
947 for (capslock = 0; *s; s++) {
951 capslock = isupper(*s);
956 /* bcode - convert speed string to speed code; return 0 on failure */
957 static int bcode(const char *s)
960 long speed = atol(s);
962 for (sp = speedtab; sp->speed; sp++)
963 if (sp->speed == speed)
968 /* error - report errors to console or syslog; only understands %s and %m */
970 #define str2cpy(b,s1,s2) strcat(strcpy(b,s1),s2)
973 * output error messages
975 static void error(const char *fmt, ...)
988 strncpy(buf, applet_name, 256);
989 strncat(buf, ": ", 256);
991 bp = buf + strlen(buf);
994 va_start(va_alist, fmt);
995 vsnprintf(bp, 256 - strlen(buf), fmt, va_alist);
1000 syslog_msg(LOG_AUTH, LOG_ERR, buf);
1002 strncat(bp, "\r\n", 256 - strlen(buf));
1004 if ((fd = open("/dev/console", 1)) >= 0) {
1005 write(fd, buf, strlen(buf));
1009 (void) sleep((unsigned) 10); /* be kind to init(8) */