diff options
Diffstat (limited to 'login-utils')
-rw-r--r-- | login-utils/Makefile | 15 | ||||
-rw-r--r-- | login-utils/agetty.c | 131 | ||||
-rw-r--r-- | login-utils/checktty.c | 40 | ||||
-rw-r--r-- | login-utils/chfn.c | 64 | ||||
-rw-r--r-- | login-utils/chsh.c | 78 | ||||
-rw-r--r-- | login-utils/cryptocard.c | 17 | ||||
-rw-r--r-- | login-utils/islocal.c | 7 | ||||
-rw-r--r-- | login-utils/last.c | 96 | ||||
-rw-r--r-- | login-utils/login.1 | 15 | ||||
-rw-r--r-- | login-utils/login.c | 179 | ||||
-rw-r--r-- | login-utils/mesg.c | 16 | ||||
-rw-r--r-- | login-utils/newgrp.c | 25 | ||||
-rw-r--r-- | login-utils/passwd.c | 93 | ||||
-rw-r--r-- | login-utils/setpwnam.c | 1 | ||||
-rw-r--r-- | login-utils/shutdown.c | 101 | ||||
-rw-r--r-- | login-utils/simpleinit.c | 34 | ||||
-rw-r--r-- | login-utils/ttymsg.c | 42 | ||||
-rw-r--r-- | login-utils/vipw.c | 33 | ||||
-rw-r--r-- | login-utils/wall.c | 69 |
19 files changed, 659 insertions, 397 deletions
diff --git a/login-utils/Makefile b/login-utils/Makefile index f4bbc5a99..4dcfee26f 100644 --- a/login-utils/Makefile +++ b/login-utils/Makefile @@ -3,9 +3,10 @@ # Revised: Sun Nov 10 20:28:43 1996 by faith@cs.unc.edu # Copyright 1992, 1993, 1994, 1995 Rickard E. Faith (faith@cs.unc.edu) # -# Suggested changed from Bauke Jan Douma <bjdouma@xs4all.nl> have been +# Suggested changes from Bauke Jan Douma <bjdouma@xs4all.nl> have been # implemented to handle shadow and sysvinit systems +include ../make_include include ../MCONFIG # Where to put man pages? @@ -37,7 +38,7 @@ USRBIN.PASSWD= passwd USRSBIN.PUTILS= vipw -ifeq "$(HAVE_LIBCRYPT)" "yes" +ifeq "$(NEED_LIBCRYPT)" "yes" CRYPT=-lcrypt endif @@ -84,9 +85,9 @@ all-misc: $(USRBIN.MISC) agetty.o: $(LIB)/pathnames.h agetty: agetty.o -chfn: chfn.o islocal.o setpwnam.o +chfn: chfn.o islocal.o setpwnam.o $(LIB)/env.o $(CC) $(LDFLAGS) -o $@ $^ $(CRYPT) $(PAM) -chsh: chsh.o islocal.o setpwnam.o +chsh: chsh.o islocal.o setpwnam.o $(LIB)/env.o $(CC) $(LDFLAGS) -o $@ $^ $(CRYPT) $(PAM) islocal.o: $(LIB)/pathnames.h last.o: $(LIB)/pathnames.h @@ -101,13 +102,17 @@ login: login.o $(LIB)/setproctitle.o checktty.o endif mesg: mesg.o $(ERR_O) + newgrp: newgrp.o $(CC) $(LDFLAGS) -o $@ $^ $(CRYPT) $(PAM) + setpwnam.o: $(LIB)/pathnames.h shutdown.o: $(LIB)/pathnames.h $(LIB)/linux_reboot.h shutdown: shutdown.o $(LIB)/my_reboot.o simpleinit.o: $(LIB)/pathnames.h $(LIB)/linux_reboot.h simpleinit: simpleinit.o $(LIB)/my_reboot.o + $(CC) $(LDFLAGS) -o $@ $^ $(CRYPT) + vipw.o: $(LIB)/pathnames.h vipw: vipw.o @@ -127,7 +132,7 @@ login.o: $(LIB)/pathnames.h mesg.o: $(LIB)/err.h endif -passwd: passwd.o islocal.o setpwnam.o +passwd: passwd.o islocal.o setpwnam.o $(LIB)/env.o $(CC) $(LDFLAGS) -o $@ $^ $(CRYPT) ifeq "$(REQUIRE_PASSWORD)" "yes" diff --git a/login-utils/agetty.c b/login-utils/agetty.c index 96d7b38d0..c85526dc0 100644 --- a/login-utils/agetty.c +++ b/login-utils/agetty.c @@ -4,6 +4,13 @@ be here. Now read the real man-page agetty.8 instead. -f option added by Eric Rasmussen <ear@usfirst.org> - 12/28/95 + + 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + - added Native Language Support + + 1999-05-05 Thorsten Kranzkowski <dl8bcu@gmx.net> + - enable hardware flow control before displaying /etc/issue + */ #include <stdio.h> @@ -23,6 +30,7 @@ #include <getopt.h> #include <memory.h> #include <sys/file.h> +#include "nls.h" #ifdef __linux__ #include "pathnames.h" @@ -255,6 +263,10 @@ main(argc, argv) 0, /* no baud rates known yet */ }; + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + /* The BSD-style init command passes us a useless process name. */ #ifdef SYSV_STYLE @@ -288,7 +300,7 @@ main(argc, argv) update_utmp(options.tty); #endif - debug("calling open_tty\n"); + debug(_("calling open_tty\n")); /* Open the tty as standard { input, output, error }. */ open_tty(options.tty, &termio, options.flags & F_LOCAL); @@ -301,12 +313,12 @@ main(argc, argv) } #endif /* Initialize the termio settings (raw mode, eight-bit, blocking i/o). */ - debug("calling termio_init\n"); - termio_init(&termio, options.speeds[FIRST_SPEED], options.flags & F_LOCAL); + debug(_("calling termio_init\n")); + termio_init(&termio, options.speeds[FIRST_SPEED], &options); /* write the modem init string and DON'T flush the buffers */ if (options.flags & F_INITSTRING) { - debug("writing init string\n"); + debug(_("writing init string\n")); write(1, options.initstring, strlen(options.initstring)); } @@ -316,7 +328,7 @@ main(argc, argv) } /* Optionally detect the baud rate from the modem status message. */ - debug("before autobaud\n"); + debug(_("before autobaud\n")); if (options.flags & F_PARSE) auto_baud(&termio); @@ -328,11 +340,11 @@ main(argc, argv) if (options.flags & F_WAITCRLF) { char ch; - debug("waiting for cr-lf\n"); + debug(_("waiting for cr-lf\n")); while(read(0, &ch, 1) == 1) { ch &= 0x7f; /* strip "parity bit" */ #ifdef DEBUGGING - fprintf(dbf, "read %c\n", ch); + fprintf(dbf, _("read %c\n"), ch); #endif if (ch == '\n' || ch == '\r') break; } @@ -341,7 +353,7 @@ main(argc, argv) chardata = init_chardata; if (!(options.flags & F_NOPROMPT)) { /* Read the login name. */ - debug("reading login name\n"); + debug(_("reading login name\n")); while ((logname = get_logname(&options, &chardata, &termio)) == 0) next_speed(&termio, &options); } @@ -362,7 +374,7 @@ main(argc, argv) /* Let the login program take care of password validation. */ (void) execl(options.login, options.login, "--", logname, (char *) 0); - error("%s: can't exec %s: %m", options.tty, options.login); + error(_("%s: can't exec %s: %m"), options.tty, options.login); exit(0); /* quiet GCC */ } @@ -382,7 +394,7 @@ parse_args(argc, argv, op) switch (c) { case 'I': if (!(op->initstring = malloc(strlen(optarg)))) { - error("can't malloc initstring"); + error(_("can't malloc initstring")); break; } { @@ -444,7 +456,7 @@ parse_args(argc, argv, op) break; case 't': /* time out */ if ((op->timeout = atoi(optarg)) <= 0) - error("bad timeout value: %s", optarg); + error(_("bad timeout value: %s"), optarg); break; case 'w': op->flags |= F_WAITCRLF; @@ -453,7 +465,7 @@ parse_args(argc, argv, op) usage(); } } - debug("after getopt loop\n"); + debug(_("after getopt loop\n")); if (argc < optind + 2) /* check parameter count */ usage(); @@ -471,7 +483,7 @@ parse_args(argc, argv, op) if (argc > optind && argv[optind]) setenv ("TERM", argv[optind], 1); - debug("exiting parseargs\n"); + debug(_("exiting parseargs\n")); } /* parse_speeds - parse alternate baud rates */ @@ -484,14 +496,14 @@ parse_speeds(op, arg) char *strtok(); char *cp; - debug("entered parse_speeds\n"); + debug(_("entered parse_speeds\n")); for (cp = strtok(arg, ","); cp != 0; cp = strtok((char *) 0, ",")) { if ((op->speeds[op->numspeed++] = bcode(cp)) <= 0) - error("bad speed: %s", cp); + error(_("bad speed: %s"), cp); if (op->numspeed > MAX_SPEED) - error("too many alternate speeds"); + error(_("too many alternate speeds")); } - debug("exiting parsespeeds\n"); + debug(_("exiting parsespeeds\n")); } #ifdef SYSV_STYLE @@ -503,7 +515,6 @@ update_utmp(line) { struct utmp ut; time_t t; - int ut_fd; int mypid = getpid(); long time(); long lseek(); @@ -548,6 +559,7 @@ update_utmp(line) #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) updwtmp(_PATH_WTMP, &ut); #else + int ut_fd; int lf; if ((lf = open(_PATH_WTMPLOCK, O_CREAT|O_WRONLY, 0660)) >= 0) { @@ -562,24 +574,26 @@ update_utmp(line) #endif } #else /* not __linux__ */ - if ((ut_fd = open(UTMP_FILE, 2)) < 0) { - error("%s: open for update: %m", UTMP_FILE); - } else { - long ut_size = sizeof(ut); /* avoid nonsense */ - - while (read(ut_fd, (char *) &ut, sizeof(ut)) == sizeof(ut)) { - if (ut.ut_type == INIT_PROCESS && ut.ut_pid == mypid) { - ut.ut_type = LOGIN_PROCESS; - ut.ut_time = time((long *) 0); - (void) strncpy(ut.ut_name, "LOGIN", sizeof(ut.ut_name)); - (void) strncpy(ut.ut_line, line, sizeof(ut.ut_line)); - (void) lseek(ut_fd, -ut_size, 1); - (void) write(ut_fd, (char *) &ut, sizeof(ut)); - (void) close(ut_fd); - return; - } - } - error("%s: no utmp entry", line); + { int ut_fd; + if ((ut_fd = open(UTMP_FILE, 2)) < 0) { + error(_("%s: open for update: %m"), UTMP_FILE); + } else { + long ut_size = sizeof(ut); /* avoid nonsense */ + + while (read(ut_fd, (char *) &ut, sizeof(ut)) == sizeof(ut)) { + if (ut.ut_type == INIT_PROCESS && ut.ut_pid == mypid) { + ut.ut_type = LOGIN_PROCESS; + ut.ut_time = time((long *) 0); + (void) strncpy(ut.ut_name, "LOGIN", sizeof(ut.ut_name)); + (void) strncpy(ut.ut_line, line, sizeof(ut.ut_line)); + (void) lseek(ut_fd, -ut_size, 1); + (void) write(ut_fd, (char *) &ut, sizeof(ut)); + (void) close(ut_fd); + return; + } + } + error(_("%s: no utmp entry"), line); + } } #endif /* __linux__ */ } @@ -607,20 +621,20 @@ open_tty(tty, tp, local) /* Sanity checks... */ if (chdir("/dev")) - error("/dev: chdir() failed: %m"); + error(_("/dev: chdir() failed: %m")); if (stat(tty, &st) < 0) error("/dev/%s: %m", tty); if ((st.st_mode & S_IFMT) != S_IFCHR) - error("/dev/%s: not a character device", tty); + error(_("/dev/%s: not a character device"), tty); /* Open the tty as standard input. */ (void) close(0); errno = 0; /* ignore close(2) errors */ - debug("open(2)\n"); + debug(_("open(2)\n")); if (open(tty, O_RDWR|O_NONBLOCK, 0) != 0) - error("/dev/%s: cannot open as standard input: %m", tty); + error(_("/dev/%s: cannot open as standard input: %m"), tty); } else { @@ -630,13 +644,13 @@ open_tty(tty, tp, local) */ if ((fcntl(0, F_GETFL, 0) & O_RDWR) != O_RDWR) - error("%s: not open for read/write", tty); + error(_("%s: not open for read/write"), tty); } /* Set up standard output and standard error file descriptors. */ - debug("duping\n"); + debug(_("duping\n")); if (dup(0) != 1 || dup(0) != 2) /* set up stdout and stderr */ - error("%s: dup problem: %m", tty); /* we have a problem */ + error(_("%s: dup problem: %m"), tty); /* we have a problem */ /* * The following ioctl will fail if stdin is not a tty, but also when @@ -668,10 +682,10 @@ char gbuf[1024]; char area[1024]; void -termio_init(tp, speed, local) +termio_init(tp, speed, op) struct termio *tp; int speed; - int local; + struct options *op; { /* @@ -686,19 +700,27 @@ termio_init(tp, speed, local) #endif tp->c_cflag = CS8 | HUPCL | CREAD | speed; - if (local) { + if (op->flags & F_LOCAL) { tp->c_cflag |= CLOCAL; } tp->c_iflag = tp->c_lflag = tp->c_oflag = tp->c_line = 0; tp->c_cc[VMIN] = 1; tp->c_cc[VTIME] = 0; + + /* Optionally enable hardware flow control */ + +#ifdef CRTSCTS + if (op->flags & F_RTSCTS) + tp->c_cflag |= CRTSCTS; +#endif + (void) ioctl(0, TCSETA, tp); /* go to blocking input even in local mode */ fcntl(0, F_SETFL, fcntl(0, F_GETFL, 0) & ~O_NONBLOCK); - debug("term_io 2\n"); + debug(_("term_io 2\n")); } /* auto_baud - extract baud rate from modem status message */ @@ -878,9 +900,9 @@ do_prompt(op, tp) if (ut->ut_type == USER_PROCESS) users++; endutent(); - printf ("%d", users); + printf ("%d ", users); if (c == 'U') - printf (" user%s", users == 1 ? "" : "s"); + printf ((users == 1) ? _("user") : _("users")); break; } default: @@ -968,7 +990,7 @@ char *get_logname(op, cp, tp) if (read(0, &c, 1) < 1) { if (errno == EINTR || errno == EIO) exit(0); - error("%s: read: %m", op->tty); + error(_("%s: read: %m"), op->tty); } /* Do BREAK handling elsewhere. */ @@ -1014,7 +1036,7 @@ char *get_logname(op, cp, tp) if (!isascii(ascval) || !isprint(ascval)) { /* ignore garbage characters */ ; } else if (bp - logname >= sizeof(logname) - 1) { - error("%s: input overrun", op->tty); + error(_("%s: input overrun"), op->tty); } else { (void) write(1, &c, 1); /* echo the character */ *bp++ = ascval; /* and store it */ @@ -1138,10 +1160,7 @@ bcode(s) void usage() { - static char msg[] = - "[-hiLmw] [-l login_program] [-t timeout] [-I initstring] baud_rate,... line [termtype]\nor\t[-hiLmw] [-l login_program] [-t timeout] [-I initstring] line baud_rate,... [termtype]"; - - fprintf(stderr, "Usage: %s %s\n", progname, msg); + fprintf(stderr, _("Usage: %s [-hiLmw] [-l login_program] [-t timeout] [-I initstring] baud_rate,... line [termtype]\nor\t[-hiLmw] [-l login_program] [-t timeout] [-I initstring] line baud_rate,... [termtype]\n"), progname); exit(1); } @@ -1220,6 +1239,6 @@ error(va_alist) (void) close(fd); } #endif - (void) sleep((unsigned) 10); /* be kind to init(8) */ + (void) sleep((unsigned) 10); /* be kind to init(8) */ exit(1); } diff --git a/login-utils/checktty.c b/login-utils/checktty.c index 15873aa44..66fee7338 100644 --- a/login-utils/checktty.c +++ b/login-utils/checktty.c @@ -1,6 +1,10 @@ /* checktty.c - linked into login, checks user against /etc/usertty Created 25-Aug-95 by Peter Orbaek <poe@daimi.aau.dk> Fixed by JDS June 1996 to clear lists and close files + + 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + - added Native Language Support + */ #include <sys/types.h> @@ -17,6 +21,7 @@ #include <malloc.h> #include <netdb.h> #include <sys/syslog.h> +#include "nls.h" #ifdef __linux__ # include <sys/sysmacros.h> @@ -38,13 +43,13 @@ char *hostname; void badlogin(const char *s) { - printf("badlogin: %s\n", s); + printf(_("badlogin: %s\n"), s); } void sleepexit(int x) { - printf("sleepexit %d\n", x); + printf(_("sleepexit %d\n"), x); exit(1); } #endif @@ -100,8 +105,8 @@ new_class(char *class) tc = (struct ttyclass *)malloc(sizeof(struct ttyclass)); if (tc == NULL) { - printf("login: memory low, login may fail\n"); - syslog(LOG_WARNING, "can't malloc for ttyclass"); + printf(_("login: memory low, login may fail\n")); + syslog(LOG_WARNING, _("can't malloc for ttyclass")); return NULL; } @@ -122,8 +127,8 @@ add_to_class(struct ttyclass *tc, char *tty) ge = (struct grplist *)malloc(sizeof(struct grplist)); if (ge == NULL) { - printf("login: memory low, login may fail\n"); - syslog(LOG_WARNING, "can't malloc for grplist"); + printf(_("login: memory low, login may fail\n")); + syslog(LOG_WARNING, _("can't malloc for grplist")); return; } @@ -135,8 +140,6 @@ add_to_class(struct ttyclass *tc, char *tty) /* return true if tty is a pty. Very linux dependent */ -/* Note that the new dynamic ptys (say /dev/pty/0 etc) have major in 128-135 */ -/* We might try TIOCGPTN or so to recognise these new ones, if desired */ static int isapty(const char *tty) { @@ -150,16 +153,25 @@ isapty(const char *tty) #if defined(__linux__) if((stat(devname, &stb) >= 0) && S_ISCHR(stb.st_mode)) { + int majordev = major(stb.st_rdev); + + /* this is for linux versions before 1.3: use major 4 */ + if(majordev == TTY_MAJOR && minor(stb.st_rdev) >= 192) + return 1; #if defined(PTY_SLAVE_MAJOR) - /* this is for linux 1.3 and newer */ - if(major(stb.st_rdev) == PTY_SLAVE_MAJOR) + /* this is for linux 1.3 and newer: use major 3 */ + if(majordev == PTY_SLAVE_MAJOR) return 1; #endif - /* this is for linux versions before 1.3, backward compat. */ - if(major(stb.st_rdev) == TTY_MAJOR && minor(stb.st_rdev) >= 192) +#if defined(UNIX98_PTY_SLAVE_MAJOR) && defined(UNIX98_PTY_MAJOR_COUNT) + /* this is for linux 2.1.116 and newer: use majors 136-143 */ + if(majordev >= UNIX98_PTY_SLAVE_MAJOR && + majordev < UNIX98_PTY_SLAVE_MAJOR + UNIX98_PTY_MAJOR_COUNT) return 1; +#endif + } #endif return 0; @@ -416,7 +428,7 @@ checktty(const char *user, const char *tty, struct passwd *pwd) } /* there was a default rule, but user didn't match, reject! */ - printf("Login on %s from %s denied by default.\n", tty, hostname); + printf(_("Login on %s from %s denied by default.\n"), tty, hostname); badlogin(user); sleepexit(1); } @@ -427,7 +439,7 @@ checktty(const char *user, const char *tty, struct passwd *pwd) name of the tty where the user is trying to log in. So deny access! */ - printf("Login on %s from %s denied.\n", tty, hostname); + printf(_("Login on %s from %s denied.\n"), tty, hostname); badlogin(user); sleepexit(1); } diff --git a/login-utils/chfn.c b/login-utils/chfn.c index 3da2360f1..5fe5025de 100644 --- a/login-utils/chfn.c +++ b/login-utils/chfn.c @@ -13,8 +13,12 @@ * Updated Thu Oct 12 09:19:26 1995 by faith@cs.unc.edu with security * patches from Zefram <A.Main@dcs.warwick.ac.uk> * - * Hacked by Peter Breitenlohner, peb@mppmu.mpg.de, - * to remove trailing empty fields. Oct 5, 96. + * Hacked by Peter Breitenlohner, peb@mppmu.mpg.de, + * to remove trailing empty fields. Oct 5, 96. + * + * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + * - added Native Language Support + * * */ @@ -32,6 +36,8 @@ #include <locale.h> #include "my_crypt.h" #include "../version.h" +#include "nls.h" +#include "env.h" #if REQUIRE_PASSWORD && USE_PAM #include <security/pam_appl.h> @@ -79,14 +85,14 @@ extern int setpwnam P((struct passwd *pwd)); #define memzero(ptr, size) memset((char *) ptr, 0, size) -/* we do not accept gecos field sizes lengther than MAX_FIELD_SIZE */ +/* we do not accept gecos field sizes longer than MAX_FIELD_SIZE */ #define MAX_FIELD_SIZE 256 int main (argc, argv) int argc; char *argv[]; { - char *cp, *pwdstr; + char *cp; uid_t uid; struct finfo oldf, newf; boolean interactive; @@ -98,15 +104,17 @@ int main (argc, argv) struct pam_conv conv = { misc_conv, NULL }; #endif + sanitize_env(); + setlocale(LC_ALL, ""); /* both for messages and for iscntrl() below */ + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + /* whoami is the program name for error messages */ whoami = argv[0]; if (! whoami) whoami = "chfn"; for (cp = whoami; *cp; cp++) if (*cp == '/') whoami = cp + 1; - /* iscntrl() below should not reject actual names */ - setlocale(LC_ALL,""); - /* * "oldf" contains the users original finger information. * "newf" contains the changed finger information, and contains NULL @@ -125,19 +133,19 @@ int main (argc, argv) if (! newf.username) { parse_passwd (getpwuid (uid), &oldf); if (! oldf.username) { - fprintf (stderr, "%s: you (user %d) don't exist.\n", whoami, uid); + fprintf (stderr, _("%s: you (user %d) don't exist.\n"), whoami, uid); return (-1); } } else { parse_passwd (getpwnam (newf.username), &oldf); if (! oldf.username) { cp = newf.username; - fprintf (stderr, "%s: user \"%s\" does not exist.\n", whoami, cp); + fprintf (stderr, _("%s: user \"%s\" does not exist.\n"), whoami, cp); return (-1); } } if (!(is_local(oldf.username))) { - fprintf (stderr, "%s: can only change local entries; use yp%s instead.\n", + fprintf (stderr, _("%s: can only change local entries; use yp%s instead.\n"), whoami, whoami); exit(1); } @@ -149,28 +157,28 @@ int main (argc, argv) return (-1); } - printf ("Changing finger information for %s.\n", oldf.username); + printf (_("Changing finger information for %s.\n"), oldf.username); #if REQUIRE_PASSWORD # if USE_PAM if(uid != 0) { if (pam_start("chfn", oldf.username, &conv, &pamh)) { - puts("Password error."); + puts(_("Password error.")); exit(1); } if (pam_authenticate(pamh, 0)) { - puts("Password error."); + puts(_("Password error.")); exit(1); } retcode = pam_acct_mgmt(pamh, 0); if (retcode == PAM_NEW_AUTHTOK_REQD) { retcode = pam_chauthtok(pamh, PAM_CHANGE_EXPIRED_AUTHTOK); } else if (retcode) { - puts("Password error."); + puts(_("Password error.")); exit(1); } if (pam_setcred(pamh, 0)) { - puts("Password error."); + puts(_("Password error.")); exit(1); } /* no need to establish a session; this isn't a session-oriented @@ -179,10 +187,10 @@ int main (argc, argv) # else /* USE_PAM */ /* require password, unless root */ if(uid != 0 && oldf.pw->pw_passwd && oldf.pw->pw_passwd[0]) { - pwdstr = getpass("Password: "); + char *pwdstr = getpass(_("Password: ")); if(strncmp(oldf.pw->pw_passwd, crypt(pwdstr, oldf.pw->pw_passwd), 13)) { - puts("Incorrect password."); + puts(_("Incorrect password.")); exit(1); } } @@ -193,7 +201,7 @@ int main (argc, argv) if (interactive) ask_info (&oldf, &newf); if (! set_changed_data (&oldf, &newf)) { - printf ("Finger information not changed.\n"); + printf (_("Finger information not changed.\n")); return 0; } status = save_new_data (&oldf); @@ -296,9 +304,9 @@ static boolean parse_argv (argc, argv, pinfo) static void usage (fp) FILE *fp; { - fprintf (fp, "Usage: %s [ -f full-name ] [ -o office ] ", whoami); - fprintf (fp, "[ -p office-phone ]\n [ -h home-phone ] "); - fprintf (fp, "[ --help ] [ --version ]\n"); + fprintf (fp, _("Usage: %s [ -f full-name ] [ -o office ] "), whoami); + fprintf (fp, _("[ -p office-phone ]\n [ -h home-phone ] ")); + fprintf (fp, _("[ --help ] [ --version ]\n")); } /* @@ -367,7 +375,7 @@ static char *prompt (question, def_val) printf("%s [%s]: ", question, def_val); *buf = 0; if (fgets (buf, sizeof (buf), stdin) == NULL) { - printf ("\nAborted.\n"); + printf (_("\nAborted.\n")); exit (-1); } /* remove the newline at the end of buf. */ @@ -400,7 +408,7 @@ static int check_gecos_string (msg, gecos) if (strlen(gecos) > MAX_FIELD_SIZE) { if (msg != NULL) printf("%s: ", msg); - printf("field is too long.\n"); + printf(_("field is too long.\n")); return -1; } @@ -408,12 +416,12 @@ static int check_gecos_string (msg, gecos) c = gecos[i]; if (c == ',' || c == ':' || c == '=' || c == '"' || c == '\n') { if (msg) printf ("%s: ", msg); - printf ("'%c' is not allowed.\n", c); + printf (_("'%c' is not allowed.\n"), c); return (-1); } if (iscntrl (c)) { if (msg) printf ("%s: ", msg); - printf ("Control characters are not allowed.\n"); + printf (_("Control characters are not allowed.\n")); return (-1); } } @@ -478,10 +486,10 @@ static int save_new_data (pinfo) pinfo->pw->pw_gecos = gecos; if (setpwnam (pinfo->pw) < 0) { perror ("setpwnam"); - printf( "Finger information *NOT* changed. Try again later.\n" ); + printf( _("Finger information *NOT* changed. Try again later.\n" )); return (-1); } - printf ("Finger information changed.\n"); + printf (_("Finger information changed.\n")); return 0; } @@ -495,7 +503,7 @@ static void *xmalloc (bytes) vp = malloc (bytes); if (! vp && bytes > 0) { - perror ("malloc failed"); + perror (_("malloc failed")); exit (-1); } return vp; diff --git a/login-utils/chsh.c b/login-utils/chsh.c index 8e8a51bc0..f9c4d743f 100644 --- a/login-utils/chsh.c +++ b/login-utils/chsh.c @@ -17,6 +17,10 @@ * suggestion from Zefram. Disallowing users with shells not in /etc/shells * from changing their shell. * + * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + * - added Native Language Support + * + * */ #if 0 @@ -34,6 +38,8 @@ #include <getopt.h> #include "my_crypt.h" #include "../version.h" +#include "nls.h" +#include "env.h" #if REQUIRE_PASSWORD && USE_PAM #include <security/pam_appl.h> @@ -79,7 +85,7 @@ int main (argc, argv) int argc; char *argv[]; { - char *cp, *shell, *oldshell, *pwdstr; + char *cp, *shell, *oldshell; uid_t uid; struct sinfo info; struct passwd *pw; @@ -90,6 +96,11 @@ int main (argc, argv) struct pam_conv conv = { misc_conv, NULL }; #endif + sanitize_env(); + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + /* whoami is the program name for error messages */ whoami = argv[0]; if (! whoami) whoami = "chsh"; @@ -104,20 +115,19 @@ int main (argc, argv) if (! info.username) { pw = getpwuid (uid); if (! pw) { - fprintf (stderr, "%s: you (user %d) don't exist.\n", whoami, uid); + fprintf (stderr, _("%s: you (user %d) don't exist.\n"), whoami, uid); return (-1); } } else { pw = getpwnam (info.username); if (! pw) { cp = info.username; - fprintf (stderr, "%s: user \"%s\" does not exist.\n", whoami, cp); + fprintf (stderr, _("%s: user \"%s\" does not exist.\n"), whoami, cp); return (-1); } } if (!(is_local(pw->pw_name))) { - fprintf (stderr, "%s: can only change local entries; use yp%s instead.\n -", + fprintf (stderr, _("%s: can only change local entries; use yp%s instead.\n"), whoami, whoami); exit(1); } @@ -128,35 +138,35 @@ int main (argc, argv) /* reality check */ if (uid != 0 && (uid != pw->pw_uid || !get_shell_list(oldshell))) { errno = EACCES; - fprintf(stderr,"%s: Your shell is not in /etc/shells, shell change" - " denied\n",whoami); + fprintf(stderr,_("%s: Your shell is not in /etc/shells, shell change" + " denied\n"),whoami); return (-1); } shell = info.shell; - printf( "Changing shell for %s.\n", pw->pw_name ); + printf( _("Changing shell for %s.\n"), pw->pw_name ); #if REQUIRE_PASSWORD # if USE_PAM if(uid != 0) { if (pam_start("chsh", pw->pw_name, &conv, &pamh)) { - puts("Password error."); + puts(_("Password error.")); exit(1); } if (pam_authenticate(pamh, 0)) { - puts("Password error."); + puts(_("Password error.")); exit(1); } retcode = pam_acct_mgmt(pamh, 0); if (retcode == PAM_NEW_AUTHTOK_REQD) { retcode = pam_chauthtok(pamh, PAM_CHANGE_EXPIRED_AUTHTOK); } else if (retcode) { - puts("Password error."); + puts(_("Password error.")); exit(1); } if (pam_setcred(pamh, 0)) { - puts("Password error."); + puts(_("Password error.")); exit(1); } /* no need to establish a session; this isn't a session-oriented @@ -165,10 +175,10 @@ int main (argc, argv) # else /* USE_PAM */ /* require password, unless root */ if(uid != 0 && pw->pw_passwd && pw->pw_passwd[0]) { - pwdstr = getpass("Password: "); + char *pwdstr = getpass(_("Password: ")); if(strncmp(pw->pw_passwd, crypt(pwdstr, pw->pw_passwd), 13)) { - puts("Incorrect password."); + puts(_("Incorrect password.")); exit(1); } } @@ -176,24 +186,24 @@ int main (argc, argv) #endif /* REQUIRE_PASSWORD */ if (! shell) { - shell = prompt ("New shell", oldshell); + shell = prompt (_("New shell"), oldshell); if (! shell) return 0; } if (check_shell (shell) < 0) return (-1); if (! strcmp (pw->pw_shell, shell)) { - printf ("Shell not changed.\n"); + printf (_("Shell not changed.\n")); return 0; } if (!strcmp(shell, "/bin/sh")) shell = ""; pw->pw_shell = shell; if (setpwnam (pw) < 0) { perror ("setpwnam"); - printf( "Shell *NOT* changed. Try again later.\n" ); + printf( _("Shell *NOT* changed. Try again later.\n") ); return (-1); } - printf ("Shell changed.\n"); + printf (_("Shell changed.\n")); return 0; } @@ -261,9 +271,9 @@ static void parse_argv (argc, argv, pinfo) static void usage (fp) FILE *fp; { - fprintf (fp, "Usage: %s [ -s shell ] ", whoami); - fprintf (fp, "[ --list-shells ] [ --help ] [ --version ]\n"); - fprintf (fp, " [ username ]\n"); + fprintf (fp, _("Usage: %s [ -s shell ] "), whoami); + fprintf (fp, _("[ --list-shells ] [ --help ] [ --version ]\n")); + fprintf (fp, _(" [ username ]\n")); } /* @@ -281,7 +291,7 @@ static char *prompt (question, def_val) printf("%s [%s]: ", question, def_val); *buf = 0; if (fgets (buf, sizeof (buf), stdin) == NULL) { - printf ("\nAborted.\n"); + printf (_("\nAborted.\n")); exit (-1); } /* remove the newline at the end of buf. */ @@ -307,44 +317,44 @@ static int check_shell (shell) int i, c; if (*shell != '/') { - printf ("%s: shell must be a full path name.\n", whoami); + printf (_("%s: shell must be a full path name.\n"), whoami); return (-1); } if (access (shell, F_OK) < 0) { - printf ("%s: \"%s\" does not exist.\n", whoami, shell); + printf (_("%s: \"%s\" does not exist.\n"), whoami, shell); return (-1); } if (access (shell, X_OK) < 0) { - printf ("%s: \"%s\" is not executable.\n", whoami, shell); + printf (_("%s: \"%s\" is not executable.\n"), whoami, shell); return (-1); } /* keep /etc/passwd clean. */ for (i = 0; i < strlen (shell); i++) { c = shell[i]; if (c == ',' || c == ':' || c == '=' || c == '"' || c == '\n') { - printf ("%s: '%c' is not allowed.\n", whoami, c); + printf (_("%s: '%c' is not allowed.\n"), whoami, c); return (-1); } if (iscntrl (c)) { - printf ("%s: Control characters are not allowed.\n", whoami); + printf (_("%s: Control characters are not allowed.\n"), whoami); return (-1); } } #if ONLY_LISTED_SHELLS if (! get_shell_list (shell)) { if (!getuid()) - printf ("Warning: \"%s\" is not listed in /etc/shells\n", shell); + printf (_("Warning: \"%s\" is not listed in /etc/shells\n"), shell); else { - printf ("%s: \"%s\" is not listed in /etc/shells.\n", + printf (_("%s: \"%s\" is not listed in /etc/shells.\n"), whoami, shell); - printf( "%s: use -l option to see list\n", whoami ); + printf( _("%s: use -l option to see list\n"), whoami ); exit(1); } } #else if (! get_shell_list (shell)) { - printf ("Warning: \"%s\" is not listed in /etc/shells.\n", shell); - printf( "Use %s -l to see list.\n", whoami ); + printf (_("Warning: \"%s\" is not listed in /etc/shells.\n"), shell); + printf( _("Use %s -l to see list.\n"), whoami ); } #endif return 0; @@ -365,7 +375,7 @@ static boolean get_shell_list (shell_name) found = false; fp = fopen ("/etc/shells", "r"); if (! fp) { - if (! shell_name) printf ("No known shells.\n"); + if (! shell_name) printf (_("No known shells.\n")); return true; } while (fgets (buf, sizeof (buf), fp) != NULL) { @@ -399,7 +409,7 @@ static void *xmalloc (bytes) vp = malloc (bytes); if (! vp && bytes > 0) { - perror ("malloc failed"); + perror (_("malloc failed")); exit (-1); } return vp; diff --git a/login-utils/cryptocard.c b/login-utils/cryptocard.c index b3edc6fd4..1195b2eb8 100644 --- a/login-utils/cryptocard.c +++ b/login-utils/cryptocard.c @@ -16,6 +16,10 @@ The sources for this code are maintained in ftp://ftp.daimi.aau.dk/pub/linux/poe/poeigl-X.XX.tar.gz + + 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + - added Native Language Support + */ #ifdef CRYPTOCARD @@ -40,6 +44,7 @@ #include <pwd.h> #include <sys/param.h> #include <sys/stat.h> +#include "nls.h" #ifdef KOONTZ_DES #include "../koontz-des/des.h" @@ -62,12 +67,12 @@ generate_challenge(void) /* create and present a challenge string */ if ((rfd = open("/dev/urandom", O_RDONLY)) < 0) { - syslog(LOG_NOTICE, "couldn't open /dev/urandom"); + syslog(LOG_NOTICE, _("couldn't open /dev/urandom")); return NULL; } if (read(rfd, &clong, 4) < 4) { close(rfd); - syslog(LOG_NOTICE, "couldn't read random data from /dev/urandom"); + syslog(LOG_NOTICE, _("couldn't read random data from /dev/urandom")); return NULL; } close(rfd); @@ -90,22 +95,22 @@ get_key() sprintf(keyfile, "%s/.cryptocard", pwd->pw_dir); if ((rfd = open(keyfile, O_RDONLY)) < 0) { - syslog(LOG_NOTICE, "can't open %s for reading", keyfile); + syslog(LOG_NOTICE, _("can't open %s for reading"), keyfile); goto bail_out; } if (fstat(rfd, &statbuf) < 0) { - syslog(LOG_NOTICE, "can't stat(%s)", keyfile); + syslog(LOG_NOTICE, _("can't stat(%s)"), keyfile); goto close_and_bail_out; } if ((statbuf.st_uid != pwd->pw_uid) || ((statbuf.st_mode & S_IFMT) != S_IFREG) || (statbuf.st_mode & (S_IRWXU|S_IRWXG|S_IRWXO))) { - syslog(LOG_NOTICE, "%s doesn't have the correct filemodes", keyfile); + syslog(LOG_NOTICE, _("%s doesn't have the correct filemodes"), keyfile); goto close_and_bail_out; } if (read(rfd, key, 8) < 8) { - syslog(LOG_NOTICE, "can't read data from %s", keyfile); + syslog(LOG_NOTICE, _("can't read data from %s"), keyfile); goto close_and_bail_out; } diff --git a/login-utils/islocal.c b/login-utils/islocal.c index 5480c5744..10a709b56 100644 --- a/login-utils/islocal.c +++ b/login-utils/islocal.c @@ -10,11 +10,16 @@ to distinguish user names where one is a prefix of the other, and to use "pathnames.h". Oct 5, 96. + 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + - added Native Language Support + + */ #include <stdio.h> #include <string.h> +#include "nls.h" #include "pathnames.h" #define MAX_LENGTH 1024 @@ -28,7 +33,7 @@ is_local(char *user) int len; if(!(fd = fopen(_PATH_PASSWD, "r"))) { - fprintf(stderr,"Can't read %s, exiting.",_PATH_PASSWD); + fprintf(stderr,_("Can't read %s, exiting."),_PATH_PASSWD); exit(1); } diff --git a/login-utils/last.c b/login-utils/last.c index cf59b8ea6..b78d00b86 100644 --- a/login-utils/last.c +++ b/login-utils/last.c @@ -18,12 +18,17 @@ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ + /* 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + * - added Native Language Support + */ + /* * last */ #include <sys/param.h> #include <sys/stat.h> #include <sys/file.h> +#include <sys/types.h> #include <signal.h> #include <string.h> #include <time.h> @@ -32,18 +37,23 @@ #include <getopt.h> #include <stdlib.h> #include <unistd.h> + +#include <sys/socket.h> +#include <netinet/in.h> #include <arpa/inet.h> + #include "pathnames.h" +#include "nls.h" #define SECDAY (24*60*60) /* seconds in a day */ #define NO 0 /* false/no */ #define YES 1 /* true/yes */ -static struct utmp buf[1024]; /* utmp read buffer */ +static struct utmp utmpbuf; -#define HMAX (int)sizeof(buf[0].ut_host) /* size of utmp host field */ -#define LMAX (int)sizeof(buf[0].ut_line) /* size of utmp tty field */ -#define NMAX (int)sizeof(buf[0].ut_name) /* size of utmp name field */ +#define HMAX (int)sizeof(utmpbuf.ut_host) /* size of utmp host field */ +#define LMAX (int)sizeof(utmpbuf.ut_line) /* size of utmp tty field */ +#define NMAX (int)sizeof(utmpbuf.ut_name) /* size of utmp name field */ #ifndef MIN #define MIN(a,b) (((a) < (b)) ? (a) : (b)) @@ -94,6 +104,10 @@ main(argc, argv) extern char *optarg; int ch; + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + while ((ch = getopt(argc, argv, "0123456789yli:f:h:t:")) != EOF) switch((char)ch) { case '0': case '1': case '2': case '3': case '4': @@ -126,7 +140,7 @@ main(argc, argv) break; case '?': default: - fputs("usage: last [-#] [-f file] [-t tty] [-h hostname] [user ...]\n", stderr); + fputs(_("usage: last [-#] [-f file] [-t tty] [-h hostname] [user ...]\n"), stderr); exit(1); } for (argv += optind; *argv; ++argv) { @@ -183,31 +197,39 @@ wtmp() { register struct utmp *bp; /* current structure */ register TTY *T; /* tty list entry */ - struct stat stb; /* stat of file for size */ - long bl, delta, /* time difference */ - lseek(), time(); - int bytes, wfd; + long delta; /* time difference */ void onintr(); - char *ct, *crmsg = NULL; + char *crmsg = NULL; + char *ct = NULL; + struct utmp **utmplist = NULL; + int listlen = 0; + int listnr = 0; + int i; + + utmpname(file); + + (void)time(&utmpbuf.ut_time); + (void)signal(SIGINT, onintr); + (void)signal(SIGQUIT, onintr); - if ((wfd = open(file, O_RDONLY, 0)) < 0 || fstat(wfd, &stb) == -1) { - perror(file); - exit(1); + setutent(); + while((bp = getutent())) { + if(listnr >= listlen) { + listlen += 10; + listlen *= 2; /* avoid quadratic behaviour */ + utmplist = realloc(utmplist, sizeof(bp) * listlen); + } + + utmplist[listnr] = malloc(sizeof(*bp)); + memcpy(utmplist[listnr++], bp, sizeof(*bp)); } - bl = (stb.st_size + sizeof(buf) - 1) / sizeof(buf); + endutent(); - (void)time(&buf[0].ut_time); - (void)signal(SIGINT, onintr); - (void)signal(SIGQUIT, onintr); + if(listnr) + ct = ctime(&utmplist[0]->ut_time); - while (--bl >= 0) { - if (lseek(wfd, (long)(bl * sizeof(buf)), SEEK_SET) == -1 || - (bytes = read(wfd, (char *)buf, sizeof(buf))) == -1) { - fprintf(stderr, "last: %s: ", file); - perror((char *)NULL); - exit(1); - } - for (bp = &buf[bytes / sizeof(buf[0]) - 1]; bp >= buf; --bp) { + for(i = listnr - 1; i >= 0; i--) { + bp = utmplist[i]; /* * if the terminal line is '~', the machine stopped. * see utmp(5) for more info. @@ -258,7 +280,7 @@ wtmp() print_partial_line(bp); if (!T->logout) - puts(" still logged in"); + puts(_(" still logged in")); else { if (T->logout < 0) { T->logout = -T->logout; @@ -276,10 +298,11 @@ wtmp() return; } T->logout = bp->ut_time; - } + utmpbuf.ut_time = bp->ut_time; + free(bp); } - ct = ctime(&buf[0].ut_time); - printf("\nwtmp begins %10.10s %5.5s \n", ct, ct + 11); + if(utmplist) free(utmplist); + if(ct) printf(_("\nwtmp begins %s"), ct); /* ct already ends in \n */ } /* @@ -293,7 +316,7 @@ want(bp, check) { register ARG *step; - if (check) + if (check) { /* * when uucp and ftp log in over a network, the entry in * the utmp file is the name plus their process id. See @@ -303,6 +326,7 @@ want(bp, check) bp->ut_line[3] = '\0'; else if (!strncmp(bp->ut_line, "uucp", sizeof("uucp") - 1)) bp->ut_line[4] = '\0'; + } if (!arglist) return(YES); @@ -340,7 +364,7 @@ addarg(type, arg) register ARG *cur; if (!(cur = (ARG *)malloc((unsigned int)sizeof(ARG)))) { - fputs("last: malloc failure.\n", stderr); + fputs(_("last: malloc failure.\n"), stderr); exit(1); } cur->next = arglist; @@ -360,7 +384,7 @@ addtty(ttyname) register TTY *cur; if (!(cur = (TTY *)malloc((unsigned int)sizeof(TTY)))) { - fputs("last: malloc failure.\n", stderr); + fputs(_("last: malloc failure.\n"), stderr); exit(1); } cur->next = ttylist; @@ -389,7 +413,7 @@ hostconv(arg) if (first) { first = 0; if (gethostname(name, sizeof(name))) { - perror("last: gethostname"); + perror(_("last: gethostname")); exit(1); } hostdot = strchr(name, '.'); @@ -415,7 +439,7 @@ ttyconv(arg) if (strlen(arg) == 2) { /* either 6 for "ttyxx" or 8 for "console" */ if (!(mval = malloc((unsigned int)8))) { - fputs("last: malloc failure.\n", stderr); + fputs(_("last: malloc failure.\n"), stderr); exit(1); } if (!strcmp(arg, "co")) @@ -441,8 +465,8 @@ onintr(signo) { char *ct; - ct = ctime(&buf[0].ut_time); - printf("\ninterrupted %10.10s %5.5s \n", ct, ct + 11); + ct = ctime(&utmpbuf.ut_time); + printf(_("\ninterrupted %10.10s %5.5s \n"), ct, ct + 11); if (signo == SIGINT) exit(1); (void)fflush(stdout); /* fix required for rsh */ diff --git a/login-utils/login.1 b/login-utils/login.1 index a2acbd9f7..88bb4d89e 100644 --- a/login-utils/login.1 +++ b/login-utils/login.1 @@ -25,7 +25,7 @@ If the user is .I not root, and if .I /etc/nologin -exists, the contents of of this file are printed to the screen, and the +exists, the contents of this file are printed to the screen, and the login is terminated. This is typically used to prevent logins when the system is being taken down. @@ -243,7 +243,8 @@ the user to for example run the command: xterm -e /bin/login. .PP .IP o A domain name suffix such as @.some.dom, meaning that the user may -rlogin/telnet from any host whose domain name has the suffix .some.dom. +rlogin/telnet from any host whose domain name has the suffix +\&.some.dom. .PP .IP o A range of IPv4 addresses, written @x.x.x.x/y.y.y.y where x.x.x.x is @@ -307,6 +308,16 @@ The undocumented BSD option is not supported. This may be required by some .BR rlogind (8) programs. + +A recursive login, as used to be possible in the good old days, +no longer works; for most purposes +.BR su (1) +is a satisfactory substitute. Indeed, for security reasons, +login does a vhangup() system call to remove any possible +listening processes on the tty. This is to avoid password +sniffing. If one uses the command "login", then the surrounding shell +gets killed by vhangup() because it's no longer the true owner of the tty. +This can be avoided by using "exec login" in a top-level shell or xterm. .SH AUTHOR Derived from BSD login 5.40 (5/9/89) by Michael Glad (glad@daimi.dk) for HP-UX diff --git a/login-utils/login.c b/login-utils/login.c index c742af75c..fa0450164 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -51,6 +51,11 @@ 1992-02-05 poe@daimi.aau.dk: Ported the stuff to Linux 0.12 From 1992 till now (1997) this code for Linux has been maintained at ftp.daimi.aau.dk:/pub/linux/poe/ + + 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + - added Native Language Support + Sun Mar 21 1999 - Arnaldo Carvalho de Melo <acme@conectiva.com.br> + - fixed strerr(errno) in gettext calls */ /* @@ -112,6 +117,7 @@ #include <sys/sysmacros.h> #include <netdb.h> #include "my_crypt.h" +#include "nls.h" #ifdef __linux__ # include <sys/sysmacros.h> @@ -275,7 +281,7 @@ main(int argc, char **argv) struct group *gr; register int ch; register char *p; - int ask, fflag, hflag, pflag, cnt; + int ask, fflag, hflag, pflag, cnt, errsv; int quietlog, passwd_req; char *domain, *ttyn; char tbuf[MAXPATHLEN + 2], tname[sizeof(_PATH_TTY) + 10]; @@ -292,7 +298,6 @@ main(int argc, char **argv) pam_handle_t *pamh = NULL; struct pam_conv conv = { misc_conv, NULL }; pid_t childPid; - void (*oldSigHandler) (); #else char *salt, *pp; #endif @@ -304,6 +309,10 @@ main(int argc, char **argv) alarm((unsigned int)timeout); signal(SIGQUIT, SIG_IGN); signal(SIGINT, SIG_IGN); + + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); setpriority(PRIO_PROCESS, 0, 0); #ifdef HAVE_QUOTA @@ -337,14 +346,14 @@ main(int argc, char **argv) case 'h': if (getuid()) { fprintf(stderr, - "login: -h for super-user only.\n"); + _("login: -h for super-user only.\n")); exit(1); } hflag = 1; if (domain && (p = index(optarg, '.')) && strcasecmp(p, domain) == 0) *p = 0; - hostname = optarg; + hostname = strdup(optarg); /* strdup: Ambrose C. Li */ { struct hostent *he = gethostbyname(hostname); if (he) { @@ -362,7 +371,7 @@ main(int argc, char **argv) case '?': default: fprintf(stderr, - "usage: login [-fp] [username]\n"); + _("usage: login [-fp] [username]\n")); exit(1); } argc -= optind; @@ -450,6 +459,12 @@ main(int argc, char **argv) openlog("login", LOG_ODELAY, LOG_AUTHPRIV); +#if 0 + /* other than iso-8859-1 */ + printf("\033(K"); + fprintf(stderr,"\033(K"); +#endif + #ifdef USE_PAM /* username is initialized to NULL and if specified on the command line it is set. @@ -458,9 +473,9 @@ main(int argc, char **argv) retcode = pam_start("login",username, &conv, &pamh); if(retcode != PAM_SUCCESS) { - fprintf(stderr,"login: PAM Failure, aborting: %s\n", + fprintf(stderr,_("login: PAM Failure, aborting: %s\n"), pam_strerror(pamh, retcode)); - syslog(LOG_ERR,"Couldn't initialize PAM: %s", pam_strerror(pamh, retcode)); + syslog(LOG_ERR,_("Couldn't initialize PAM: %s"), pam_strerror(pamh, retcode)); exit(99); } /* hostname & tty are either set to NULL or their correct values, @@ -469,6 +484,15 @@ main(int argc, char **argv) PAM_FAIL_CHECK; retcode = pam_set_item(pamh, PAM_TTY, tty); PAM_FAIL_CHECK; + +#if 0 + /* other than iso-8859-1 + * one more time due to reset tty by PAM + */ + printf("\033(K"); + fprintf(stderr,"\033(K"); +#endif + /* if fflag == 1, then the user has already been authenticated */ if (fflag && (getuid() == 0)) passwd_req = 0; @@ -491,9 +515,9 @@ main(int argc, char **argv) (retcode == PAM_CRED_INSUFFICIENT) || (retcode == PAM_AUTHINFO_UNAVAIL))) { pam_get_item(pamh, PAM_USER, (const void **) &username); - syslog(LOG_NOTICE,"FAILED LOGIN %d FROM %s FOR %s, %s", + syslog(LOG_NOTICE,_("FAILED LOGIN %d FROM %s FOR %s, %s"), failcount, hostname, username, pam_strerror(pamh, retcode)); - fprintf(stderr,"Login incorrect\n\n"); + fprintf(stderr,_("Login incorrect\n\n")); pam_set_item(pamh,PAM_USER,NULL); retcode = pam_authenticate(pamh, 0); } @@ -502,14 +526,14 @@ main(int argc, char **argv) pam_get_item(pamh, PAM_USER, (const void **) &username); if (retcode == PAM_MAXTRIES) - syslog(LOG_NOTICE,"TOO MANY LOGIN TRIES (%d) FROM %s FOR " - "%s, %s", failcount, hostname, username, + syslog(LOG_NOTICE,_("TOO MANY LOGIN TRIES (%d) FROM %s FOR " + "%s, %s"), failcount, hostname, username, pam_strerror(pamh, retcode)); else - syslog(LOG_NOTICE,"FAILED LOGIN SESSION FROM %s FOR %s, %s", + syslog(LOG_NOTICE,_("FAILED LOGIN SESSION FROM %s FOR %s, %s"), hostname, username, pam_strerror(pamh, retcode)); - fprintf(stderr,"\nLogin incorrect\n"); + fprintf(stderr,_("\nLogin incorrect\n")); pam_end(pamh, retcode); exit(0); } @@ -558,7 +582,7 @@ main(int argc, char **argv) Feb 95 <alvaro@etsit.upm.es> */ if (username[0] == '+') { - puts("Illegal username"); + puts(_("Illegal username")); badlogin(username); sleepexit(1); } @@ -601,16 +625,16 @@ main(int argc, char **argv) */ if (pwd && pwd->pw_uid == 0 && !rootterm(tty)) { fprintf(stderr, - "%s login refused on this terminal.\n", + _("%s login refused on this terminal.\n"), pwd->pw_name); if (hostname) syslog(LOG_NOTICE, - "LOGIN %s REFUSED FROM %s ON TTY %s", + _("LOGIN %s REFUSED FROM %s ON TTY %s"), pwd->pw_name, hostname, tty); else syslog(LOG_NOTICE, - "LOGIN %s REFUSED ON TTY %s", + _("LOGIN %s REFUSED ON TTY %s"), pwd->pw_name, tty); continue; } @@ -623,7 +647,7 @@ main(int argc, char **argv) break; setpriority(PRIO_PROCESS, 0, -4); - pp = getpass("Password: "); + pp = getpass(_("Password: ")); # ifdef CRYPTOCARD if (strncmp(pp, "CRYPTO", 6) == 0) { @@ -662,7 +686,7 @@ main(int argc, char **argv) if (pwd && !strcmp(p, pwd->pw_passwd)) break; - printf("Login incorrect\n"); + printf(_("Login incorrect\n")); badlogin(username); /* log ALL bad logins */ failures++; @@ -684,11 +708,11 @@ main(int argc, char **argv) switch(errno) { case EUSERS: fprintf(stderr, - "Too many users logged on already.\nTry again later.\n"); + _("Too many users logged on already.\nTry again later.\n")); break; case EPROCLIM: fprintf(stderr, - "You have too many processes running.\n"); + _("You have too many processes running.\n")); break; default: perror("quota (Q_SETUID)"); @@ -734,7 +758,7 @@ main(int argc, char **argv) #ifndef __linux__ # ifdef KERBEROS if (notickets && !quietlog) - printf("Warning: no Kerberos tickets issued\n"); + printf(_("Warning: no Kerberos tickets issued\n")); # endif # ifndef USE_PAM /* PAM does all of this for us */ @@ -746,13 +770,13 @@ main(int argc, char **argv) if (pwd->pw_change) { if (tp.tv_sec >= pwd->pw_change) { - printf("Sorry -- your password has expired.\n"); + printf(_("Sorry -- your password has expired.\n")); sleepexit(1); } else if (tp.tv_sec - pwd->pw_change < TWOWEEKS && !quietlog) { struct tm *ttp; ttp = localtime(&pwd->pw_change); - printf("Warning: your password expires on %s %d, %d\n", + printf(_("Warning: your password expires on %s %d, %d\n"), months[ttp->tm_mon], ttp->tm_mday, TM_YEAR_BASE + ttp->tm_year); } @@ -760,13 +784,13 @@ main(int argc, char **argv) if (pwd->pw_expire) { if (tp.tv_sec >= pwd->pw_expire) { - printf("Sorry -- your account has expired.\n"); + printf(_("Sorry -- your account has expired.\n")); sleepexit(1); } else if (tp.tv_sec - pwd->pw_expire < TWOWEEKS && !quietlog) { struct tm *ttp; ttp = localtime(&pwd->pw_expire); - printf("Warning: your account expires on %s %d, %d\n", + printf(_("Warning: your account expires on %s %d, %d\n"), months[ttp->tm_mon], ttp->tm_mday, TM_YEAR_BASE + ttp->tm_year); } @@ -796,7 +820,6 @@ main(int argc, char **argv) struct utmp ut; int wtmp; struct utmp *utp; - time_t t; pid_t mypid = getpid(); utmpname(_PATH_UTMP); @@ -814,6 +837,16 @@ Michael Riepe <michael@stud.uni-hannover.de> && utp->ut_type >= INIT_PROCESS && utp->ut_type <= DEAD_PROCESS) break; + + /* If we can't find a pre-existing entry by pid, try by line. + BSD network daemons may rely on this. (anonymous) */ + if (utp == NULL) { + setutent(); + ut.ut_type = LOGIN_PROCESS; + strncpy(ut.ut_id, ttyn + 8, sizeof(ut.ut_id)); + strncpy(ut.ut_line, ttyn + 5, sizeof(ut.ut_line)); + utp = getutid(&ut); + } if (utp) { memcpy(&ut, utp, sizeof(ut)); @@ -821,7 +854,6 @@ Michael Riepe <michael@stud.uni-hannover.de> /* some gettys/telnetds don't initialize utmp... */ memset(&ut, 0, sizeof(ut)); } - /* endutent(); superfluous, error for glibc */ if (ut.ut_id[0] == 0) strncpy(ut.ut_id, ttyn + 8, sizeof(ut.ut_id)); @@ -829,9 +861,16 @@ Michael Riepe <michael@stud.uni-hannover.de> strncpy(ut.ut_user, username, sizeof(ut.ut_user)); strncpy(ut.ut_line, ttyn + 5, sizeof(ut.ut_line)); ut.ut_line[sizeof(ut.ut_line)-1] = 0; - time(&t); - ut.ut_time = t; /* ut_time is not always a time_t */ - /* (we might test #ifdef _HAVE_UT_TV ) */ +#ifdef _HAVE_UT_TV /* in <utmpbits.h> included by <utmp.h> */ + gettimeofday(&ut.ut_tv, NULL); +#else + { + time_t t; + time(&t); + ut.ut_time = t; /* ut_time is not always a time_t */ + /* glibc2 #defines it as ut_tv.tv_sec */ + } +#endif ut.ut_type = USER_PROCESS; ut.ut_pid = mypid; if (hostname) { @@ -985,23 +1024,23 @@ Michael Riepe <michael@stud.uni-hannover.de> #endif if (tty[sizeof("tty")-1] == 'S') - syslog(LOG_INFO, "DIALUP AT %s BY %s", tty, pwd->pw_name); + syslog(LOG_INFO, _("DIALUP AT %s BY %s"), tty, pwd->pw_name); /* allow tracking of good logins. -steve philp (sphilp@mail.alliance.net) */ if (pwd->pw_uid == 0) { if (hostname) - syslog(LOG_NOTICE, "ROOT LOGIN ON %s FROM %s", + syslog(LOG_NOTICE, _("ROOT LOGIN ON %s FROM %s"), tty, hostname); else - syslog(LOG_NOTICE, "ROOT LOGIN ON %s", tty); + syslog(LOG_NOTICE, _("ROOT LOGIN ON %s"), tty); } else { if (hostname) - syslog(LOG_INFO, "LOGIN ON %s BY %s FROM %s", tty, + syslog(LOG_INFO, _("LOGIN ON %s BY %s FROM %s"), tty, pwd->pw_name, hostname); else - syslog(LOG_INFO, "LOGIN ON %s BY %s", tty, + syslog(LOG_INFO, _("LOGIN ON %s BY %s"), tty, pwd->pw_name); } @@ -1012,8 +1051,8 @@ Michael Riepe <michael@stud.uni-hannover.de> motd(); mail = getenv("MAIL"); if (mail && stat(mail, &st) == 0 && st.st_size != 0) { - printf("You have %smail.\n", - (st.st_mtime > st.st_atime) ? "new " : ""); + printf(_("You have %smail.\n"), + (st.st_mtime > st.st_atime) ? _("new ") : ""); } } @@ -1029,8 +1068,9 @@ Michael Riepe <michael@stud.uni-hannover.de> signal(SIGINT, SIG_IGN); childPid = fork(); if (childPid < 0) { + int errsv = errno; /* error in fork() */ - fprintf(stderr,"login: failure forking: %s", strerror(errno)); + fprintf(stderr,_("login: failure forking: %s"), strerror(errsv)); PAM_END; exit(0); } else if (childPid) { @@ -1045,17 +1085,17 @@ Michael Riepe <michael@stud.uni-hannover.de> /* discard permissions last so can't get killed and drop core */ if(setuid(pwd->pw_uid) < 0 && pwd->pw_uid) { - syslog(LOG_ALERT, "setuid() failed"); + syslog(LOG_ALERT, _("setuid() failed")); exit(1); } /* wait until here to change directory! */ if (chdir(pwd->pw_dir) < 0) { - printf("No directory %s!\n", pwd->pw_dir); + printf(_("No directory %s!\n"), pwd->pw_dir); if (chdir("/")) exit(0); pwd->pw_dir = "/"; - printf("Logging in with home = \"/\".\n"); + printf(_("Logging in with home = \"/\".\n")); } /* if the shell field has a space: treat it like a shell script */ @@ -1063,7 +1103,7 @@ Michael Riepe <michael@stud.uni-hannover.de> buff = malloc(strlen(pwd->pw_shell) + 6); if (!buff) { - fprintf(stderr, "login: no memory for shell script.\n"); + fprintf(stderr, _("login: no memory for shell script.\n")); exit(0); } @@ -1088,11 +1128,13 @@ Michael Riepe <michael@stud.uni-hannover.de> execvp(childArgv[0], childArgv + 1); - if (!strcmp(childArgv[0], "/bin/sh")) - fprintf(stderr, "login: couldn't exec shell script: %s.\n", - strerror(errno)); + errsv = errno; + + if (!strcmp(childArgv[0], "/bin/sh")) + fprintf(stderr, _("login: couldn't exec shell script: %s.\n"), + strerror(errsv)); else - fprintf(stderr, "login: no shell: %s.\n", strerror(errno)); + fprintf(stderr, _("login: no shell: %s.\n"), strerror(errsv)); exit(0); } @@ -1108,7 +1150,7 @@ getloginname() cnt2 = 0; for (;;) { cnt = 0; - printf("\n%s login: ", thishost); fflush(stdout); + printf(_("\n%s login: "), thishost); fflush(stdout); for (p = nbuf; (ch = getchar()) != '\n'; ) { if (ch == EOF) { badlogin("EOF"); @@ -1119,15 +1161,15 @@ getloginname() cnt++; if (cnt > UT_NAMESIZE + 20) { - fprintf(stderr, "login name much too long.\n"); - badlogin("NAME too long"); + fprintf(stderr, _("login name much too long.\n")); + badlogin(_("NAME too long")); exit(0); } } if (p > nbuf) { if (nbuf[0] == '-') fprintf(stderr, - "login names may not start with '-'.\n"); + _("login names may not start with '-'.\n")); else { *p = '\0'; username = nbuf; @@ -1137,8 +1179,8 @@ getloginname() cnt2++; if (cnt2 > 50) { - fprintf(stderr, "too many bare linefeeds.\n"); - badlogin("EXCESSIVE linefeeds"); + fprintf(stderr, _("too many bare linefeeds.\n")); + badlogin(_("EXCESSIVE linefeeds")); exit(0); } } @@ -1149,7 +1191,7 @@ timedout() { struct termio ti; - fprintf(stderr, "Login timed out after %d seconds\n", timeout); + fprintf(stderr, _("Login timed out after %d seconds\n"), timeout); /* reset echo */ ioctl(0, TCGETA, &ti); @@ -1171,7 +1213,7 @@ rootterm(ttyn) { int fd; char buf[100],*p; - int cnt, more; + int cnt, more = 0; fd = open(SECURETTY, O_RDONLY); if(fd < 0) return 1; @@ -1249,14 +1291,14 @@ dolastlog(quiet) if (!quiet) { if (read(fd, (char *)&ll, sizeof(ll)) == sizeof(ll) && ll.ll_time != 0) { - printf("Last login: %.*s ", + printf(_("Last login: %.*s "), 24-5, (char *)ctime(&ll.ll_time)); if (*ll.ll_host != '\0') - printf("from %.*s\n", + printf(_("from %.*s\n"), (int)sizeof(ll.ll_host), ll.ll_host); else - printf("on %.*s\n", + printf(_("on %.*s\n"), (int)sizeof(ll.ll_line), ll.ll_line); } lseek(fd, (off_t)pwd->pw_uid * sizeof(ll), SEEK_SET); @@ -1277,12 +1319,21 @@ dolastlog(quiet) void badlogin(const char *name) { - if (hostname) - syslog(LOG_NOTICE, "%d LOGIN FAILURE%s FROM %s, %s", - failures, failures > 1 ? "S" : "", hostname, name); - else - syslog(LOG_NOTICE, "%d LOGIN FAILURE%s ON %s, %s", - failures, failures > 1 ? "S" : "", tty, name); + if (failures == 1) { + if (hostname) + syslog(LOG_NOTICE, _("LOGIN FAILURE FROM %s, %s"), + hostname, name); + else + syslog(LOG_NOTICE, _("LOGIN FAILURE ON %s, %s"), + tty, name); + } else { + if (hostname) + syslog(LOG_NOTICE, _("%d LOGIN FAILURES FROM %s, %s"), + failures, hostname, name); + else + syslog(LOG_NOTICE, _("%d LOGIN FAILURES ON %s, %s"), + failures, tty, name); + } } #undef UNKNOWN diff --git a/login-utils/mesg.c b/login-utils/mesg.c index d05d333c9..cc8c4010d 100644 --- a/login-utils/mesg.c +++ b/login-utils/mesg.c @@ -38,6 +38,10 @@ * Modified Fri Mar 10 20:27:19 1995, faith@cs.unc.edu, for Linux * Modified Mon Jul 1 18:14:10 1996, janl@ifi.uio.no, writing to stdout * as suggested by Michael Meskes <meskes@Informatik.RWTH-Aachen.DE> + * + * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + * - added Native Language Support + * * */ @@ -50,6 +54,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include "nls.h" int main(argc, argv) @@ -60,6 +65,11 @@ main(argc, argv) char *tty; int ch; + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + + while ((ch = getopt(argc, argv, "")) != EOF) switch (ch) { case '?': @@ -76,10 +86,10 @@ main(argc, argv) if (*argv == NULL) { if (sb.st_mode & (S_IWGRP | S_IWOTH)) { - (void)fprintf(stdout, "is y\n"); + (void)fprintf(stdout, _("is y\n")); exit(0); } - (void)fprintf(stdout, "is n\n"); + (void)fprintf(stdout, _("is n\n")); exit(1); } @@ -99,6 +109,6 @@ main(argc, argv) exit(1); } -usage: (void)fprintf(stderr, "usage: mesg [y | n]\n"); +usage: (void)fprintf(stderr, _("usage: mesg [y | n]\n")); exit(2); } diff --git a/login-utils/newgrp.c b/login-utils/newgrp.c index 5c26a4a0e..1f8be95f2 100644 --- a/login-utils/newgrp.c +++ b/login-utils/newgrp.c @@ -3,6 +3,10 @@ /* Vesa Roukonen added code for asking password */ /* Currently maintained at ftp://ftp.daimi.aau.dk/pub/linux/poe/ */ +/* 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + * - added Native Language Support + */ + #include <unistd.h> #include <pwd.h> #include <grp.h> @@ -11,6 +15,7 @@ #include <errno.h> #include "pathnames.h" #include "my_crypt.h" +#include "nls.h" #ifndef TRUE # define TRUE 1 @@ -39,7 +44,7 @@ allow_setgid(struct passwd *pe, struct group *ge) if(ge->gr_passwd && ge->gr_passwd[0] != 0) { if(strcmp(ge->gr_passwd, - crypt(getpass("Password: "), ge->gr_passwd)) == 0) { + crypt(getpass(_("Password: ")), ge->gr_passwd)) == 0) { return TRUE; /* password accepted */ } } @@ -53,9 +58,13 @@ main(int argc, char *argv[]) struct passwd *pw_entry; struct group *gr_entry; char *shell; + + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); if (!(pw_entry = getpwuid(getuid()))) { - perror("newgrp: Who are you?"); + perror(_("newgrp: Who are you?")); exit(1); } @@ -63,34 +72,34 @@ main(int argc, char *argv[]) if (argc < 2) { if(setgid(pw_entry->pw_gid) < 0) { - perror("newgrp: setgid"); + perror(_("newgrp: setgid")); exit(1); } } else { if (!(gr_entry = getgrnam(argv[1]))) { - perror("newgrp: No such group."); + perror(_("newgrp: No such group.")); exit(1); } else { if(allow_setgid(pw_entry, gr_entry)) { if(setgid(gr_entry->gr_gid) < 0) { - perror("newgrp: setgid"); + perror(_("newgrp: setgid")); exit(1); } } else { - puts("newgrp: Permission denied"); + puts(_("newgrp: Permission denied")); exit(1); } } } if(setuid(getuid()) < 0) { - perror("newgrp: setuid"); + perror(_("newgrp: setuid")); exit(1); } fflush(stdout); fflush(stderr); execl(shell,shell,(char*)0); - perror("No shell"); + perror(_("No shell")); fflush(stderr); exit(1); } diff --git a/login-utils/passwd.c b/login-utils/passwd.c index 0057a283b..90054ccca 100644 --- a/login-utils/passwd.c +++ b/login-utils/passwd.c @@ -38,6 +38,12 @@ * auth.warning. (Of course, the password itself is not logged.) */ + /* 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + * - added Native Language Support + * Sun Mar 21 1999 - Arnaldo Carvalho de Melo <acme@conectiva.com.br> + * - fixed strerr(errno) in gettext calls + */ + /* * Usage: passwd [username [password]] * Only root may use the one and two argument forms. @@ -59,12 +65,10 @@ #include <errno.h> #include <sys/resource.h> #include "my_crypt.h" +#include "nls.h" +#include "env.h" -#if 0 -# include "../version.h" -#else -char version[] = "admutil 1.18, 15-Oct-95"; -#endif +#include "../version.h" #ifndef _PATH_CHFN # define _PATH_CHFN "/usr/bin/chfn" @@ -156,7 +160,7 @@ int check_passwd(char *passwd, char *oldpasswd, char *user, char *gecos) char *c, *g, *p; if ( (strlen(passwd) < 6) ) { - printf("The password must have at least 6 characters, try again.\n"); + printf(_("The password must have at least 6 characters, try again.\n")); return 0; } @@ -169,19 +173,19 @@ int check_passwd(char *passwd, char *oldpasswd, char *user, char *gecos) } if ( (other + digit + ucase + lcase) < 2) { - printf("The password must contain characters out of two of the following\n"); - printf("classes: upper and lower case letters, digits and non alphanumeric\n"); - printf("characters. See passwd(1) for more information.\n"); + printf(_("The password must contain characters out of two of the following\n")); + printf(_("classes: upper and lower case letters, digits and non alphanumeric\n")); + printf(_("characters. See passwd(1) for more information.\n")); return 0; } if ( oldpasswd[0] && !strncmp(oldpasswd, crypt(passwd, oldpasswd), 13) ) { - printf("You cannot reuse the old password.\n"); + printf(_("You cannot reuse the old password.\n")); return 0; } if ( !check_passwd_string(passwd, user) ) { - printf("Please don't use something like your username as password!\n"); + printf(_("Please don't use something like your username as password!\n")); return 0; } @@ -192,14 +196,14 @@ int check_passwd(char *passwd, char *oldpasswd, char *user, char *gecos) g[c-gecos] = 0; while ( (c=rindex(g, ' ')) ) { if ( !check_passwd_string(passwd, c+1) ) { - printf("Please don't use something like your realname as password!\n"); + printf(_("Please don't use something like your realname as password!\n")); free (g); return 0; } *c = '\0'; } /* while */ if ( !check_passwd_string(passwd, g) ) { - printf("Please don't use something like your realname as password!\n"); + printf(_("Please don't use something like your realname as password!\n")); free (g); return 0; } @@ -216,8 +220,8 @@ int check_passwd(char *passwd, char *oldpasswd, char *user, char *gecos) void usage() { - printf ("Usage: passwd [username [password]]\n"); - printf("Only root may use the one and two argument forms.\n"); + printf (_("Usage: passwd [username [password]]\n")); + printf(_("Only root may use the one and two argument forms.\n")); } int @@ -248,6 +252,11 @@ main(argc, argv) {0, 0, 0, 0} }; + sanitize_env(); + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + optind = 0; while ( (c = getopt_long(argc, argv, "foqsvV", long_options, &opt_index)) != -1 ) { switch (c) { @@ -265,17 +274,17 @@ main(argc, argv) break; case 'V': case 'v': - printf("%s\n", version); + printf("%s\n", util_linux_version); exit(0); default: - fprintf(stderr, "Usage: passwd [-foqsvV] [user [password]]\n"); + fprintf(stderr, _("Usage: passwd [-foqsvV] [user [password]]\n")); exit(1); } /* switch (c) */ } /* while */ if (fullname || shell) { char *args[100]; - int i, j; + int i, j, errsv; setuid(getuid()); /* drop special privs. */ if (fullname) @@ -288,29 +297,33 @@ main(argc, argv) args[j] = NULL; execv(args[0], args); - fprintf(stderr, "Can't exec %s: %s\n", args[0], strerror(errno)); + errsv = errno; + fprintf(stderr, _("Can't exec %s: %s\n"), args[0], strerror(errsv)); exit(1); } switch (argc - optind) { case 0: - if ( !(user = getlogin()) ) { + /* Why use getlogin()? Some systems allow having several + usernames with the same uid, especially several root accounts. + One changes the password for the username, not the uid. */ + if ( !(user = getlogin()) || !*user ) { if ( !(pe = getpwuid( getuid() )) ) { - pexit("Cannot find login name"); + pexit(_("Cannot find login name")); } else user = pe->pw_name; } break; case 1: if(gotuid) { - printf("Only root can change the password for others.\n"); + printf(_("Only root can change the password for others.\n")); exit (1); } else user = argv[optind]; break; case 2: if(gotuid) { - printf("Only root can change the password for others.\n"); + printf(_("Only root can change the password for others.\n")); exit(1); } else { user = argv[optind]; @@ -318,33 +331,33 @@ main(argc, argv) } break; default: - printf("Too many arguments.\n"); + printf(_("Too many arguments.\n")); exit (1); } /* switch */ if(!(pe = getpwnam(user))) { - pexit("Can't find username anywhere. Is `%s' really a user?", user); + pexit(_("Can't find username anywhere. Is `%s' really a user?"), user); } if (!(is_local(user))) { - puts("Sorry, I can only change local passwords. Use yppasswd instead."); + puts(_("Sorry, I can only change local passwords. Use yppasswd instead.")); exit(1); } /* if somebody got into changing utmp... */ if(gotuid && gotuid != pe->pw_uid) { - puts("UID and username does not match, imposter!"); + puts(_("UID and username does not match, imposter!")); exit(1); } if ( !silent ) - printf( "Changing password for %s\n", user ); + printf( _("Changing password for %s\n"), user ); if ( (gotuid && pe->pw_passwd && pe->pw_passwd[0]) || (!gotuid && !strcmp(user,"root")) ) { - oldstr = getpass("Enter old password: "); + oldstr = getpass(_("Enter old password: ")); if(strncmp(pe->pw_passwd, crypt(oldstr, pe->pw_passwd), 13)) { - puts("Illegal password, imposter."); + puts(_("Illegal password, imposter.")); exit(1); } } @@ -356,9 +369,9 @@ main(argc, argv) /* password not set on command line by root, ask for it ... */ redo_it: - pwdstr = getpass("Enter new password: "); + pwdstr = getpass(_("Enter new password: ")); if (pwdstr[0] == '\0') { - puts("Password not changed."); + puts(_("Password not changed.")); exit(1); } @@ -368,10 +381,10 @@ main(argc, argv) strncpy(pwdstr1, pwdstr, 9); pwdstr1[9] = 0; - pwdstr = getpass("Re-type new password: "); + pwdstr = getpass(_("Re-type new password: ")); if(strncmp(pwdstr, pwdstr1, 8)) { - puts("You misspelled it. Password not changed."); + puts(_("You misspelled it. Password not changed.")); exit(1); } } /* pwdstr i.e. password set on command line */ @@ -386,28 +399,28 @@ main(argc, argv) #ifdef LOGALL openlog("passwd", 0, LOG_AUTH); if (gotuid) - syslog(LOG_NOTICE,"password changed, user %s",user); + syslog(LOG_NOTICE,_("password changed, user %s"),user); else { if ( !strcmp(user, "root") ) - syslog(LOG_WARNING,"ROOT PASSWORD CHANGED"); + syslog(LOG_WARNING,_("ROOT PASSWORD CHANGED")); else - syslog(LOG_NOTICE,"password changed by root, user %s",user); + syslog(LOG_NOTICE,_("password changed by root, user %s"),user); } closelog(); #endif /* LOGALL */ pe->pw_passwd = cryptstr; #ifdef DEBUG - printf ("calling setpwnam to set password.\n"); + printf (_("calling setpwnam to set password.\n")); #else if (setpwnam( pe ) < 0) { perror( "setpwnam" ); - printf( "Password *NOT* changed. Try again later.\n" ); + printf( _("Password *NOT* changed. Try again later.\n" )); exit( 1 ); } #endif if ( !silent ) - printf("Password changed.\n"); + printf(_("Password changed.\n")); exit(0); } diff --git a/login-utils/setpwnam.c b/login-utils/setpwnam.c index 1f1067cf1..8631e7adc 100644 --- a/login-utils/setpwnam.c +++ b/login-utils/setpwnam.c @@ -41,6 +41,7 @@ * $Author: poer $ * $Revision: 1.13 $ * $Date: 1997/06/23 08:26:29 $ + * */ #undef DEBUG diff --git a/login-utils/shutdown.c b/login-utils/shutdown.c index 8ba13b647..7ccb748ac 100644 --- a/login-utils/shutdown.c +++ b/login-utils/shutdown.c @@ -27,6 +27,10 @@ * * Changes by Richard Gooch <rgooch@atnf.csiro.au> (butchered by aeb) * introducing shutdown.conf. + * + * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + * - added Native Language Support + * */ #include <stdio.h> @@ -48,6 +52,7 @@ #include <sys/resource.h> #include "linux_reboot.h" #include "pathnames.h" +#include "nls.h" static void usage(), int_handler(), write_user(struct utmp *); static void wall(), write_wtmp(), unmount_disks(), unmount_disks_ourselves(); @@ -69,6 +74,7 @@ char halt_action[256]; /* to find out what to do upon halt */ /* #define DEBUGGING */ #define WR(s) write(fd, s, strlen(s)) +#define WRCRLF write(fd, "\r\n", 2) #define ERRSTRING sys_errlist[errno] @@ -76,7 +82,7 @@ void usage() { fprintf(stderr, - "Usage: shutdown [-h|-r] [-fqs] [now|hh:ss|+mins]\n"); + _("Usage: shutdown [-h|-r] [-fqs] [now|hh:ss|+mins]\n")); exit(1); } @@ -94,7 +100,7 @@ int_handler() { unlink(_PATH_NOLOGIN); signal(SIGINT, SIG_DFL); - my_puts("Shutdown process aborted"); + my_puts(_("Shutdown process aborted")); exit(1); } @@ -110,9 +116,13 @@ main(int argc, char *argv[]) int fd; char *ptr; + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + #ifndef DEBUGGING if(geteuid()) { - fprintf(stderr, "%s: Only root can shut a system down.\n", + fprintf(stderr, _("%s: Only root can shut a system down.\n"), argv[0]); exit(1); } @@ -206,8 +216,8 @@ main(int argc, char *argv[]) then = 3600 * hour + 60 * minute; timeout = then - now; if(timeout < 0) { - fprintf(stderr, "That must be tomorrow, " - "can't you wait till then?\n"); + fprintf(stderr, _("That must be tomorrow, " + "can't you wait till then?\n")); exit(1); } } else { @@ -233,6 +243,9 @@ main(int argc, char *argv[]) if (fgets (line, sizeof(line), fp) != NULL && strncasecmp (line, "HALT_ACTION", 11) == 0 && iswhitespace(line[11])) { + p = index(line, '\n'); + if (p) + *p = 0; /* strip final '\n' */ p = line+11; while(iswhitespace(*p)) p++; @@ -255,16 +268,16 @@ main(int argc, char *argv[]) } *ptr = '\0'; } else if (!opt_msgset) { - strcpy(message, "for maintenance; bounce, bounce"); + strcpy(message, _("for maintenance; bounce, bounce")); } #ifdef DEBUGGING - printf("timeout = %d, quiet = %d, reboot = %d\n", + printf(_("timeout = %d, quiet = %d, reboot = %d\n"), timeout, opt_quiet, opt_reboot); #endif /* so much for option-processing, now begin termination... */ - if(!(whom = getlogin())) whom = "ghost"; + if(!(whom = getlogin()) || !*whom) whom = "ghost"; if(strlen(whom) > 40) whom[40] = 0; /* see write_user() */ setpriority(PRIO_PROCESS, 0, PRIO_MIN); @@ -282,9 +295,14 @@ main(int argc, char *argv[]) if((fd = open(_PATH_NOLOGIN, O_WRONLY|O_CREAT, 0644)) >= 0) { - WR("\r\nThe system is being shut down within 5 minutes\r\n"); + /* keep xgettext happy and leave \r\n outside strings */ + WRCRLF; + WR(_("The system is being shut down within 5 minutes")); + WRCRLF; write(fd, message, strlen(message)); - WR("\r\nLogin is therefore prohibited.\r\n"); + WRCRLF; + WR(_("Login is therefore prohibited.")); + WRCRLF; close(fd); } @@ -304,8 +322,8 @@ main(int argc, char *argv[]) /* do syslog message... */ openlog(prog, LOG_CONS, LOG_AUTH); - syslog(LOG_NOTICE, "%s by %s: %s", - opt_reboot ? "rebooted" : "halted", whom, message); + syslog(LOG_NOTICE, _("%s by %s: %s"), + opt_reboot ? _("rebooted") : _("halted"), whom, message); closelog(); if(opt_fast) @@ -335,6 +353,14 @@ main(int argc, char *argv[]) /* turn off accounting */ acct(NULL); #endif + /* RedHat and SuSE like to remove /etc/nologin. + Perhaps the usual sequence is + touch nologin; shutdown -h; fiddle with hardware; + boot; fiddle with software; rm nologin + and removing it here will be counterproductive. + Let us see whether people complain. */ + unlink(_PATH_NOLOGIN); + sync(); sleep(2); @@ -348,9 +374,9 @@ main(int argc, char *argv[]) if(opt_reboot) { my_reboot(LINUX_REBOOT_CMD_RESTART); /* RB_AUTOBOOT */ - my_puts("\nWhy am I still alive after reboot?"); + my_puts(_("\nWhy am I still alive after reboot?")); } else { - my_puts("\nNow you can turn off the power..."); + my_puts(_("\nNow you can turn off the power...")); /* allow C-A-D now, faith@cs.unc.edu, re-fixed 8-Jul-96 */ my_reboot(LINUX_REBOOT_CMD_CAD_ON); /* RB_ENABLE_CAD */ @@ -365,10 +391,10 @@ main(int argc, char *argv[]) void do_halt(char *action) { if (strcasecmp (action, "power_off") == 0) { - printf("Calling kernel power-off facility...\n"); + printf(_("Calling kernel power-off facility...\n")); fflush(stdout); my_reboot(LINUX_REBOOT_CMD_POWER_OFF); - printf("Error powering off\t%s\n", ERRSTRING); + printf(_("Error powering off\t%s\n"), ERRSTRING); fflush(stdout); sleep (2); } else @@ -376,10 +402,10 @@ do_halt(char *action) { /* This should be improved; e.g. Mike Jagdis wants "/sbin/mdstop -a" */ /* Maybe we should also fork and wait */ if (action[0] == '/') { - printf("Executing the program \"%s\" ...\n", action); + printf(_("Executing the program \"%s\" ...\n"), action); fflush(stdout); execl(action, action, NULL); - printf("Error executing\t%s\n", ERRSTRING); + printf(_("Error executing\t%s\n"), ERRSTRING); fflush(stdout); sleep (2); } @@ -402,23 +428,27 @@ write_user(struct utmp *ut) if((fd = open(term, O_WRONLY|O_NONBLOCK)) < 0) return; - sprintf(msg, "\007\r\nURGENT: broadcast message from %s:\r\n", whom); + sprintf(msg, _("\007URGENT: broadcast message from %s:"), whom); + WRCRLF; WR(msg); + WRCRLF; if(minutes == 0) { - sprintf(msg, "System going down IMMEDIATELY!\r\n\n"); + sprintf(msg, _("System going down IMMEDIATELY!\n")); } else if(minutes > 60) { hours = minutes / 60; - sprintf(msg, "System going down in %d hour%s %d minutes\r\n", - hours, hours == 1 ? "" : "s", minutes - 60*hours); + sprintf(msg, _("System going down in %d hour%s %d minutes"), + hours, hours == 1 ? "" : _("s"), minutes - 60*hours); } else { - sprintf(msg, "System going down in %d minute%s\r\n\n", - minutes, minutes == 1 ? "" : "s"); + sprintf(msg, _("System going down in %d minute%s\n"), + minutes, minutes == 1 ? "" : _("s")); } WR(msg); + WRCRLF; - sprintf(msg, "\t... %s ...\r\n\n", message); + sprintf(msg, _("\t... %s ...\n"), message); WR(msg); + WRCRLF; close(fd); } @@ -473,7 +503,7 @@ swap_off() sync(); if ((pid = fork()) < 0) { - my_puts("Cannot fork for swapoff. Shrug!"); + my_puts(_("Cannot fork for swapoff. Shrug!")); return; } if (!pid) { @@ -481,8 +511,8 @@ swap_off() execl("/etc/swapoff", SWAPOFF_ARGS, NULL); execl("/bin/swapoff", SWAPOFF_ARGS, NULL); execlp("swapoff", SWAPOFF_ARGS, NULL); - my_puts("Cannot exec swapoff, " - "hoping umount will do the trick."); + my_puts(_("Cannot exec swapoff, " + "hoping umount will do the trick.")); exit(0); } while ((result = wait(&status)) != -1 && result != pid) @@ -500,20 +530,25 @@ unmount_disks() sync(); if ((pid = fork()) < 0) { - my_puts("Cannot fork for umount, trying manually."); + my_puts(_("Cannot fork for umount, trying manually.")); unmount_disks_ourselves(); return; } if (!pid) { execl(_PATH_UMOUNT, UMOUNT_ARGS, NULL); - my_puts("Cannot exec " _PATH_UMOUNT ", trying umount."); + + /* need my_printf instead of my_puts here */ + freopen(_PATH_CONSOLE, "w", stdout); + printf(_("Cannot exec %s, trying umount.\n"), _PATH_UMOUNT); + fflush(stdout); + execlp("umount", UMOUNT_ARGS, NULL); - my_puts("Cannot exec umount, giving up on umount."); + my_puts(_("Cannot exec umount, giving up on umount.")); exit(0); } while ((result = wait(&status)) != -1 && result != pid) ; - my_puts("Unmounting any remaining filesystems..."); + my_puts(_("Unmounting any remaining filesystems...")); unmount_disks_ourselves(); } @@ -549,7 +584,7 @@ unmount_disks_ourselves() printf("umount %s\n", filesys); #else if (umount(mntlist[i]) < 0) - printf("shutdown: Couldn't umount %s\n", filesys); + printf(_("shutdown: Couldn't umount %s\n"), filesys); #endif } } diff --git a/login-utils/simpleinit.c b/login-utils/simpleinit.c index 1664404c3..1e496ad59 100644 --- a/login-utils/simpleinit.c +++ b/login-utils/simpleinit.c @@ -1,6 +1,10 @@ /* simpleinit.c - poe@daimi.aau.dk */ /* Version 1.21 */ +/* 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + * - added Native Language Support + */ + #include <sys/types.h> #include <stdlib.h> #include <unistd.h> @@ -21,6 +25,7 @@ #include "my_crypt.h" #include "pathnames.h" #include "linux_reboot.h" +#include "nls.h" #define CMDSIZ 150 /* max size of a line in inittab */ #define NUMCMD 30 /* max number of lines in inittab */ @@ -71,15 +76,15 @@ enter_single() pid_t pid; int i; - err("Booting to single user mode.\n"); + err(_("Booting to single user mode.\n")); if((pid = fork()) == 0) { /* the child */ execl(_PATH_BSHELL, _PATH_BSHELL, NULL); - err("exec of single user shell failed\n"); + err(_("exec of single user shell failed\n")); } else if(pid > 0) { while(wait(&i) != pid) /* nothing */; } else if(pid < 0) { - err("fork of single user shell failed\n"); + err(_("fork of single user shell failed\n")); } unlink(_PATH_SINGLE); } @@ -95,6 +100,11 @@ int main(int argc, char *argv[]) signal(SIGTSTP, tstp_handler); signal(SIGINT, int_handler); + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + + /* * start up in single user mode if /etc/singleboot exists or if * argv[1] is "single". @@ -206,14 +216,14 @@ int boot_single(int singlearg, int argc, char *argv[]) return 1; /* a bad /etc/passwd should not lock out */ for(i = 0; i < MAXTRIES; i++) { - pass = getpass("Password: "); + pass = getpass(_("Password: ")); if(pass == NULL) continue; if(!strcmp(crypt(pass, rootpass), rootpass)) { return 1; } - puts("\nWrong password.\n"); + puts(_("\nWrong password.\n")); } } else return 1; } @@ -239,16 +249,16 @@ int do_rc() close(0); if(open(_PATH_RC, O_RDONLY, 0) == 0) { execv(_PATH_BSHELL, argv); - err("exec rc failed\n"); + err(_("exec rc failed\n")); _exit(2); } - err("open of rc file failed\n"); + err(_("open of rc file failed\n")); _exit(1); } else if(pid > 0) { /* parent, wait till rc process dies before spawning */ while(wait(&stat) != pid) /* nothing */; } else if(pid < 0) { - err("fork of rc shell failed\n"); + err(_("fork of rc shell failed\n")); } return WEXITSTATUS(stat); } @@ -260,7 +270,7 @@ void spawn(int i) if((pid = fork()) < 0) { inittab[i].pid = -1; - err("fork failed\n"); + err(_("fork failed\n")); return; } if(pid) { @@ -289,7 +299,7 @@ void spawn(int i) env[2] = (char *)0; execve(inittab[i].toks[0], inittab[i].toks, env); - err("exec failed\n"); + err(_("exec failed\n")); sleep(5); _exit(1); } @@ -311,7 +321,7 @@ void read_inittab() /* termenv = "vt100"; */ if(!(f = fopen(_PATH_INITTAB, "r"))) { - err("cannot open inittab\n"); + err(_("cannot open inittab\n")); _exit(1); } @@ -349,7 +359,7 @@ void read_inittab() /* special-case termcap for the console ttys */ (void) sprintf(tty, "/dev/%s", inittab[i].tty); if(!termenv || stat(tty, &stb) < 0) { - err("no TERM or cannot stat tty\n"); + err(_("no TERM or cannot stat tty\n")); } else { /* is it a console tty? */ if(major(stb.st_rdev) == 4 && minor(stb.st_rdev) < 64) { diff --git a/login-utils/ttymsg.c b/login-utils/ttymsg.c index 7caf35be3..6bf2f82f6 100644 --- a/login-utils/ttymsg.c +++ b/login-utils/ttymsg.c @@ -34,6 +34,12 @@ * */ + /* 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + * - added Native Language Support + * Sun Mar 21 1999 - Arnaldo Carvalho de Melo <acme@conectiva.com.br> + * - fixed strerr(errno) in gettext calls + */ + #include <sys/types.h> #include <sys/uio.h> #include <signal.h> @@ -45,6 +51,7 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> +#include "nls.h" #ifdef __linux__ #include "pathnames.h" @@ -68,19 +75,20 @@ ttymsg(iov, iovcnt, line, tmout) static char errbuf[MAXNAMLEN+1024]; register int cnt, fd, left, wret; struct iovec localiov[6]; - int forked = 0; + int forked = 0, errsv; if (iovcnt > sizeof(localiov) / sizeof(localiov[0])) - return ("too many iov's (change code in wall/ttymsg.c)"); + return (_("too many iov's (change code in wall/ttymsg.c)")); + + /* The old code here rejected the line argument when it contained a '/', + saying: "A slash may be an attempt to break security...". + However, if a user can control the line argument here + then he can make this routine write to /dev/hda or /dev/sda + already. So, this test was worthless, and these days it is + also wrong since people use /dev/pts/xxx. */ - if (strchr(line, '/')) { - /* A slash is an attempt to break security... */ - (void) sprintf(errbuf, "'/' in \"%s\"", device); - errbuf[1024] = 0; /* protect caller */ - return (errbuf); - } if (strlen(line) + sizeof(_PATH_DEV) + 1 > sizeof(device)) { - (void) sprintf(errbuf, "excessively long line arg"); + (void) sprintf(errbuf, _("excessively long line arg")); return (errbuf); } (void) sprintf(device, "%s%s", _PATH_DEV, line); @@ -134,10 +142,12 @@ ttymsg(iov, iovcnt, line, tmout) cpid = fork(); if (cpid < 0) { if (strlen(strerror(errno)) > 1000) - (void) sprintf(errbuf, "cannot fork"); - else + (void) sprintf(errbuf, _("cannot fork")); + else { + errsv = errno; (void) sprintf(errbuf, - "fork: %s", strerror(errno)); + _("fork: %s"), strerror(errsv)); + } (void) close(fd); return (errbuf); } @@ -164,10 +174,12 @@ ttymsg(iov, iovcnt, line, tmout) if (forked) _exit(1); if (strlen(strerror(errno)) > 1000) - (void) sprintf(errbuf, "%s: BAD ERROR", device); - else + (void) sprintf(errbuf, _("%s: BAD ERROR"), device); + else { + errsv = errno; (void) sprintf(errbuf, "%s: %s", device, - strerror(errno)); + strerror(errsv)); + } errbuf[1024] = 0; return (errbuf); } diff --git a/login-utils/vipw.c b/login-utils/vipw.c index 50270a6e3..dfcdca2ed 100644 --- a/login-utils/vipw.c +++ b/login-utils/vipw.c @@ -37,6 +37,11 @@ * <joey@finlandia.infodrom.north.de>. Support for vigr. * * Martin Schulze's patches adapted to Util-Linux by Nicolai Langfeldt. + * + * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + * - added Native Language Support + * Sun Mar 21 1999 - Arnaldo Carvalho de Melo <acme@conectiva.com.br> + * - fixed strerr(errno) in gettext calls */ static char version_string[] = "vipw 1.4"; @@ -59,6 +64,7 @@ static char version_string[] = "vipw 1.4"; #include <unistd.h> #include "setpwnam.h" +#include "nls.h" #define FILENAMELEN 67 @@ -140,7 +146,7 @@ pw_lock() #if 0 /* flock()ing is superfluous here, with the ptmp/ptmptmp system. */ if (flock(lockfd, LOCK_EX|LOCK_NB)) { (void)fprintf(stderr, - "%s: the %s file is busy.\n", progname, + _("%s: the %s file is busy.\n"), progname, program == VIPW ? "password" : "group" ); exit(1); } @@ -156,13 +162,15 @@ pw_lock() if (ret == -1) { if (errno == EEXIST) (void)fprintf(stderr, - "%s: the %s file is busy (%s present)\n", + _("%s: the %s file is busy (%s present)\n"), progname, program == VIPW ? "password" : "group", tmp_file); - else - (void)fprintf(stderr, "%s: can't link %s: %s\n", progname, - tmp_file, strerror(errno)); + else { + int errsv = errno; + (void)fprintf(stderr, _("%s: can't link %s: %s\n"), progname, + tmp_file, strerror(errsv)); + } exit(1); } copyfile(lockfd, fd); @@ -180,9 +188,10 @@ pw_unlock() unlink(tmp); link(orig_file, tmp); if (rename(tmp_file, orig_file) == -1) { + int errsv = errno; (void)fprintf(stderr, - "%s: can't unlock %s: %s (your changes are still in %s)\n", - progname, orig_file, strerror(errno), tmp_file); + _("%s: can't unlock %s: %s (your changes are still in %s)\n"), + progname, orig_file, strerror(errsv), tmp_file); exit(1); } (void)unlink(tmp_file); @@ -205,7 +214,7 @@ pw_edit(int notsetuid) pid = fork(); if (pid < 0) { - (void)fprintf(stderr, "%s: Cannot fork\n", progname); + (void)fprintf(stderr, _("%s: Cannot fork\n"), progname); exit(1); } if (!pid) { @@ -245,7 +254,7 @@ pw_error(name, err, eval) (void)fprintf(stderr, "%s\n", strerror(sverrno)); } (void)fprintf(stderr, - "%s: %s unchanged\n", progname, orig_file); + _("%s: %s unchanged\n"), progname, orig_file); (void)unlink(tmp_file); exit(eval); } @@ -254,6 +263,10 @@ int main(int argc, char *argv[]) { struct stat begin, end; + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + bzero(tmp_file, FILENAMELEN); progname = (rindex(argv[0], '/')) ? rindex(argv[0], '/') + 1 : argv[0]; if (!strcmp(progname, "vigr")) { @@ -284,7 +297,7 @@ int main(int argc, char *argv[]) if (stat(tmp_file, &end)) pw_error(tmp_file, 1, 1); if (begin.st_mtime == end.st_mtime) { - (void)fprintf(stderr, "%s: no changes made\n", progname); + (void)fprintf(stderr, _("%s: no changes made\n"), progname); pw_error((char *)NULL, 0, 0); } pw_unlock(); diff --git a/login-utils/wall.c b/login-utils/wall.c index eda7e611d..70a0df65b 100644 --- a/login-utils/wall.c +++ b/login-utils/wall.c @@ -36,6 +36,10 @@ /* * This program is not related to David Wall, whose Stanford Ph.D. thesis * is entitled "Mechanisms for Broadcast and Selective Broadcast". + * + * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org> + * - added Native Language Support + * */ #include <sys/param.h> @@ -44,12 +48,14 @@ #include <sys/uio.h> #include <paths.h> +#include <ctype.h> #include <pwd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <utmp.h> +#include "nls.h" #ifdef __linux__ #include <locale.h> #include "pathnames.h" @@ -63,6 +69,8 @@ int nobanner; int mbufsize; char *mbuf; +char *progname = "wall"; + /* ARGSUSED */ int main(argc, argv) @@ -72,15 +80,19 @@ main(argc, argv) extern int optind; int ch; struct iovec iov; - struct utmp utmp; - FILE *fp; + struct utmp *utmpptr; char *p, *ttymsg(); - char line[sizeof(utmp.ut_line) + 1]; + char line[sizeof(utmpptr->ut_line) + 1]; + + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + + progname = argv[0]; + p = rindex(progname, '/'); + if (p) + progname = p+1; -#ifdef __linux__ - setlocale(LC_CTYPE,""); -#endif - while ((ch = getopt(argc, argv, "n")) != EOF) switch (ch) { case 'n': @@ -91,7 +103,7 @@ main(argc, argv) case '?': default: usage: - (void)fprintf(stderr, "usage: wall [file]\n"); + (void)fprintf(stderr, _("usage: %s [file]\n"), progname); exit(1); } argc -= optind; @@ -101,26 +113,24 @@ usage: makemsg(*argv); - if (!(fp = fopen(_PATH_UTMP, "r"))) { - (void)fprintf(stderr, "wall: cannot read %s.\n", _PATH_UTMP); - exit(1); - } + setutent(); + iov.iov_base = mbuf; iov.iov_len = mbufsize; - /* NOSTRICT */ - while (fread((char *)&utmp, sizeof(utmp), 1, fp) == 1) { - if (!utmp.ut_name[0] || - !strncmp(utmp.ut_name, IGNOREUSER, sizeof(utmp.ut_name))) + while((utmpptr = getutent())) { + if (!utmpptr->ut_name[0] || + !strncmp(utmpptr->ut_name, IGNOREUSER, sizeof(utmpptr->ut_name))) + continue; +#ifdef USER_PROCESS + if (utmpptr->ut_type != USER_PROCESS) continue; -#ifdef __linux__ - if (utmp.ut_type != USER_PROCESS) - continue; #endif - strncpy(line, utmp.ut_line, sizeof(utmp.ut_line)); - line[sizeof(utmp.ut_line)-1] = '\0'; + strncpy(line, utmpptr->ut_line, sizeof(utmpptr->ut_line)); + line[sizeof(utmpptr->ut_line)-1] = '\0'; if ((p = ttymsg(&iov, 1, line, 60*5)) != NULL) - (void)fprintf(stderr, "wall: %s\n", p); + (void)fprintf(stderr, "%s: %s\n", progname, p); } + endutent(); exit(0); } @@ -138,17 +148,16 @@ makemsg(fname) char *p, *whom, *where, hostname[MAXHOSTNAMELEN], lbuf[MAXHOSTNAMELEN + 320], tmpname[sizeof(_PATH_TMP) + 20]; - char *getlogin(), *strcpy(), *ttyname(); (void)sprintf(tmpname, "%s/wall.XXXXXX", _PATH_TMP); if (!(fd = mkstemp(tmpname)) || !(fp = fdopen(fd, "r+"))) { - (void)fprintf(stderr, "wall: can't open temporary file.\n"); + (void)fprintf(stderr, _("%s: can't open temporary file.\n"), progname); exit(1); } (void)unlink(tmpname); if (!nobanner) { - if (!(whom = getlogin())) + if (!(whom = getlogin()) || !*whom) whom = (pw = getpwuid(getuid())) ? pw->pw_name : "???"; if (!whom || strlen(whom) > 100) whom = "someone"; @@ -169,7 +178,7 @@ makemsg(fname) /* snprintf is not always available, but the sprintf's here will not overflow as long as %d takes at most 100 chars */ (void)fprintf(fp, "\r%79s\r\n", " "); - (void)sprintf(lbuf, "Broadcast Message from %s@%s", + (void)sprintf(lbuf, _("Broadcast Message from %s@%s"), whom, hostname); (void)fprintf(fp, "%-79.79s\007\007\r\n", lbuf); (void)sprintf(lbuf, " (%s) at %d:%02d ...", @@ -179,7 +188,7 @@ makemsg(fname) (void)fprintf(fp, "%79s\r\n", " "); if (fname && !(freopen(fname, "r", stdin))) { - (void)fprintf(stderr, "wall: can't read %s.\n", fname); + (void)fprintf(stderr, _("%s: can't read %s.\n"), progname, fname); exit(1); } while (fgets(lbuf, sizeof(lbuf), stdin)) @@ -204,16 +213,16 @@ makemsg(fname) rewind(fp); if (fstat(fd, &sbuf)) { - (void)fprintf(stderr, "wall: can't stat temporary file.\n"); + (void)fprintf(stderr, _("%s: can't stat temporary file.\n"), progname); exit(1); } mbufsize = sbuf.st_size; if (!(mbuf = malloc((u_int)mbufsize))) { - (void)fprintf(stderr, "wall: out of memory.\n"); + (void)fprintf(stderr, _("%s: Out of memory!\n"), progname); exit(1); } if (fread(mbuf, sizeof(*mbuf), mbufsize, fp) != mbufsize) { - (void)fprintf(stderr, "wall: can't read temporary file.\n"); + (void)fprintf(stderr, _("%s: can't read temporary file.\n"), progname); exit(1); } (void)close(fd); |