1 diff -Nru mingetty-1.07.orig/mingetty.c mingetty-1.07/mingetty.c
2 --- mingetty-1.07.orig/mingetty.c 2004-01-03 15:15:56.000000000 +0200
3 +++ mingetty-1.07/mingetty.c 2006-11-22 22:13:26.967910100 +0200
5 * - autologin only at first login
6 * - /etc/mingetty.conf that can be used instead of /etc/inittab for
8 - * - Can UTF-8 setup be done within mingetty?
9 + * - Can UTF-8 setup be done within mingetty? Let's try now :-) (VinzC)
10 * - Also add /bin/login-type functionality in here?
13 +/* Additional comments: Vincent Cadet <vcadet@hotmail.com> (2006-11-21)
14 + * - Attempt to make mingetty support UTF-8. Modifications were imported
15 + * from Suse migetty.c 0.9.6s.
23 #include <sys/utsname.h>
29 +#include <sys/ttydefaults.h>
33 +# error ASM_IUTF8 input flag not defined - Cannot define IUTF8
35 +# define IUTF8 ASM_IUTF8
39 /* name of this program (argv[0]) */
40 static char *progname;
42 static char *autologin = NULL;
43 /* try to read a char before dropping to login prompt */
44 static int loginpause = 0;
46 +static int mode = K_RAW;
48 /* error() - output error messages */
49 static void error (const char *fmt, ...)
54 + /* Detect mode of current keyboard setup, e.g. for UTF-8 */
55 + if (ioctl(0, KDGKBMODE, &mode) < 0)
58 /* Write a reset string to the terminal. This is very linux-specific
59 and should be checked for other systems. */
61 - write (0, "\033c", 2);
62 + /* don't write a full reset (ESC c) because this leaves the
63 + unicode mode again if the terminal was in unicode mode
64 + and also undos the ESC sequences in CONSOLE_MAGIC which
65 + are needed for some languages/console-fonts.
66 + Just put the cursor to the home position (ESC [ H),
67 + erase everything below the cursor (ESC [ J), and set the
68 + scrolling region to the full window (ESC [ r) */
69 + write (0, "\033[r\033[H\033[J", 9);
71 sigaction (SIGHUP, &sa_old, NULL);
75 static char *get_logname (void)
77 - static char logname[40];
78 + static char logname[4*UT_NAMESIZE];
84 tcflush (0, TCIFLUSH); /* flush pending input */
86 + /* Check for UTF-8 mode */
90 + setlocale(LC_CTYPE, "en_US.UTF-8");
97 + setlocale(LC_CTYPE, "POSIX");
101 for (*logname = 0; *logname == 0;) {
103 for (bp = logname;;) {
104 if (read (0, &c, 1) < 1) {
105 - if (errno == EINTR || errno == EIO
106 - || errno == ENOENT)
107 + if (errno == EINTR || errno == EAGAIN) {
111 + if (errno == EIO || errno == ENOENT)
113 error ("%s: read: %s", tty, strerror (errno));
115 if (c == '\n' || c == '\r') {
118 - } else if (!isprint (c))
119 - error ("%s: invalid character 0x%x in login"
123 + if (ascii && !isprint (c))
124 + error ("%s: invalid character 0x%x in login name", tty, c);
125 else if ((size_t)(bp - logname) >= sizeof (logname) - 1)
126 error ("%s: too long login name", tty);
134 + if (!ascii && (ic = iconv_open("WCHAR_T", "UTF-8"))) {
135 + char tmpbuf[4*sizeof(logname)], *op, *lp;
136 + size_t len = bp - logname;
137 + size_t out = sizeof(tmpbuf) - 1;
143 + if ((wcl = iconv(ic , &lp, &len, &op, &out)) == (size_t)-1)
144 + error ("%s: invalid character conversion for login name", tty);
147 + wcp = (wint_t*)tmpbuf;
148 + wcp[wcl] = (wint_t)0;
150 + if (!iswprint(*wcp++))
151 + error ("%s: invalid character for login name found", tty);