summaryrefslogtreecommitdiffstats
path: root/login-utils
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:25:41 +0100
committerKarel Zak2006-12-07 00:25:41 +0100
commiteb63b9b8f4cecb34c2478282567862bc48ef256d (patch)
tree99243f8eecb44c2bb6a559982b99c680fcb649e7 /login-utils
parentImported from util-linux-2.9v tarball. (diff)
downloadkernel-qcow2-util-linux-eb63b9b8f4cecb34c2478282567862bc48ef256d.tar.gz
kernel-qcow2-util-linux-eb63b9b8f4cecb34c2478282567862bc48ef256d.tar.xz
kernel-qcow2-util-linux-eb63b9b8f4cecb34c2478282567862bc48ef256d.zip
Imported from util-linux-2.10f tarball.
Diffstat (limited to 'login-utils')
-rw-r--r--login-utils/Makefile4
-rw-r--r--login-utils/agetty.88
-rw-r--r--login-utils/agetty.c14
-rw-r--r--login-utils/chfn.c2
-rw-r--r--login-utils/chsh.c1
-rw-r--r--login-utils/login.110
-rw-r--r--login-utils/login.c41
-rw-r--r--login-utils/mesg.c2
-rw-r--r--login-utils/passwd.c2
-rw-r--r--login-utils/wall.c3
10 files changed, 66 insertions, 21 deletions
diff --git a/login-utils/Makefile b/login-utils/Makefile
index 4dcfee26f..e277d1bad 100644
--- a/login-utils/Makefile
+++ b/login-utils/Makefile
@@ -124,12 +124,12 @@ wall: wall.o ttymsg.o
ifeq "$(USE_TTY_GROUP)" "yes"
login.o: login.c $(LIB)/pathnames.h $(LIB)/setproctitle.c $(LIB)/setproctitle.h
$(CC) -c $(CFLAGS) $(PAMFL) -DUSE_TTY_GROUP login.c
-mesg.o: mesg.c $(LIB)/err.h
+mesg.o: mesg.c $(LIB)/errs.h
$(CC) -c $(CFLAGS) -DUSE_TTY_GROUP mesg.c
else
login.o: $(LIB)/pathnames.h
$(CC) -c $(CFLAGS) $(PAMFL) login.c
-mesg.o: $(LIB)/err.h
+mesg.o: $(LIB)/errs.h
endif
passwd: passwd.o islocal.o setpwnam.o $(LIB)/env.o
diff --git a/login-utils/agetty.8 b/login-utils/agetty.8
index 57c9b6b46..69be5f2be 100644
--- a/login-utils/agetty.8
+++ b/login-utils/agetty.8
@@ -8,6 +8,7 @@ agetty \- alternative Linux getty
.RI "[-l " login_program ]
.RI "[-I " init ]
.RI "[-t " timeout ]
+.RI "[-H " login_host ]
.I port
.I baud_rate,...
.RI [ term ]
@@ -17,6 +18,7 @@ agetty \- alternative Linux getty
.RI "[-l " login_program ]
.RI "[-I " init ]
.RI "[-t " timeout ]
+.RI "[-H " login_host ]
.I baud_rate,...
.I port
.RI [ term ]
@@ -120,6 +122,12 @@ This allows the use of a non-standard login program (for example,
one that asks for a dial-up password or that uses a different
password file).
.TP
+\-H \fIlogin_host\fP
+Write the specified \fIlogin_host\fP into the utmp file. (Normally,
+no login host is given, since \fBagetty\fP is used for local hardwired
+connections and consoles. However, this option can be useful for
+identifying terminal concentrators and the like.
+.TP
\-m
Try to extract the baud rate the CONNECT status message
produced by Hayes(tm)\-compatible modems. These status
diff --git a/login-utils/agetty.c b/login-utils/agetty.c
index c85526dc0..9360be0ae 100644
--- a/login-utils/agetty.c
+++ b/login-utils/agetty.c
@@ -237,6 +237,9 @@ void error P_((int va_alist));
char *progname;
+/* Fake hostname for ut_host specified on command line. */
+char *fakehost = NULL;
+
/* ... */
#ifdef DEBUGGING
#define debug(s) fprintf(dbf,s); fflush(dbf)
@@ -390,7 +393,7 @@ parse_args(argc, argv, op)
extern int optind; /* getopt */
int c;
- while (isascii(c = getopt(argc, argv, "I:Lf:hil:mt:wn"))) {
+ while (isascii(c = getopt(argc, argv, "I:LH:f:hil:mt:wn"))) {
switch (c) {
case 'I':
if (!(op->initstring = malloc(strlen(optarg)))) {
@@ -435,6 +438,9 @@ parse_args(argc, argv, op)
case 'L': /* force local */
op->flags |= F_LOCAL;
break;
+ case 'H': /* fake login host */
+ fakehost = optarg;
+ break;
case 'f': /* custom issue file */
op->flags |= F_CUSTISSUE;
op->issue = optarg;
@@ -547,6 +553,8 @@ update_utmp(line)
strncpy(ut.ut_user, "LOGIN", sizeof(ut.ut_user));
strncpy(ut.ut_line, line, sizeof(ut.ut_line));
+ if (fakehost)
+ strncpy(ut.ut_host, fakehost, sizeof(ut.ut_host));
time(&t);
ut.ut_time = t;
ut.ut_type = LOGIN_PROCESS;
@@ -586,6 +594,8 @@ update_utmp(line)
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));
+ if (fakehost)
+ (void) strncpy(ut.ut_host, fakehost, sizeof(ut.ut_host));
(void) lseek(ut_fd, -ut_size, 1);
(void) write(ut_fd, (char *) &ut, sizeof(ut));
(void) close(ut_fd);
@@ -1160,7 +1170,7 @@ bcode(s)
void
usage()
{
- 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);
+ fprintf(stderr, _("Usage: %s [-hiLmw] [-l login_program] [-t timeout] [-I initstring] [-H login_host] baud_rate,... line [termtype]\nor\t[-hiLmw] [-l login_program] [-t timeout] [-I initstring] [-H login_host] line baud_rate,... [termtype]\n"), progname);
exit(1);
}
diff --git a/login-utils/chfn.c b/login-utils/chfn.c
index 5fe5025de..93e801e0c 100644
--- a/login-utils/chfn.c
+++ b/login-utils/chfn.c
@@ -33,9 +33,7 @@
#include <errno.h>
#include <ctype.h>
#include <getopt.h>
-#include <locale.h>
#include "my_crypt.h"
-#include "../version.h"
#include "nls.h"
#include "env.h"
diff --git a/login-utils/chsh.c b/login-utils/chsh.c
index f9c4d743f..d1d14d0fa 100644
--- a/login-utils/chsh.c
+++ b/login-utils/chsh.c
@@ -37,7 +37,6 @@
#include <ctype.h>
#include <getopt.h>
#include "my_crypt.h"
-#include "../version.h"
#include "nls.h"
#include "env.h"
diff --git a/login-utils/login.1 b/login-utils/login.1
index 88bb4d89e..d21a41efc 100644
--- a/login-utils/login.1
+++ b/login-utils/login.1
@@ -35,14 +35,14 @@ these must be met, or the log in attempt will be denied and a
.B syslog
message will be generated. See the section on "Special Access Restrictions".
-If the user is root, then the login must be occuring on a tty listed in
+If the user is root, then the login must be occurring on a tty listed in
.IR /etc/securetty .
Failures will be logged with the
.B syslog
facility.
-After these conditions are checked, the password will be requested and
-checks (if a password is required for this username). Ten attempts
+After these conditions have been checked, the password will be requested and
+checked (if a password is required for this username). Ten attempts
are allowed before
.B login
dies, but after the first three, the response starts to get very slow.
@@ -53,8 +53,8 @@ facility. This facility is also used to report any successful root logins.
If the file
.I .hushlogin
exists, then a "quiet" login is performed (this disables the checking
-of the checking of mail and the printing of the last login time and
-message of the day). Otherwise, if
+of mail and the printing of the last login time and message of the day).
+Otherwise, if
.I /var/log/lastlog
exists, the last login time is printed (and the current login is
recorded).
diff --git a/login-utils/login.c b/login-utils/login.c
index fa0450164..399b4aee1 100644
--- a/login-utils/login.c
+++ b/login-utils/login.c
@@ -162,6 +162,23 @@
#include "setproctitle.h"
#endif
+/*
+ * RedHat writes:
+ * we've got a REAL HACK to avoid telling people that they have
+ * mail because the imap server has left a turd in their inbox.
+ * It works, but it sucks...
+ * It turns out that the turd is always 523 bytes long, so we
+ * just check for that size.
+ */
+/*
+ * If you want to turn this strange hack off, set
+ #define REDHAT_IGNORED_MAILSIZE 0
+ * In case people complain, this may become a configuration option,
+ * or perhaps this hack is thrown out again.
+ * A better solution would be to check the contents of this file..
+ */
+#define REDHAT_IGNORED_MAILSIZE 523
+
#if 0
/* from before we had a lastlog.h file in linux */
struct lastlog
@@ -241,12 +258,23 @@ const char *months[] =
{ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
"Sep", "Oct", "Nov", "Dec" };
-/* provided by Linus Torvalds 16-Feb-93 */
+/* Nice and simple code provided by Linus Torvalds 16-Feb-93 */
+/* Nonblocking stuff by Maciej W. Rozycki, macro@ds2.pg.gda.pl, 1999.
+ He writes: "Login performs open() on a tty in a blocking mode.
+ In some cases it may make login wait in open() for carrier infinitely,
+ for example if the line is a simplistic case of a three-wire serial
+ connection. I believe login should open the line in the non-blocking mode
+ leaving the decision to make a connection to getty (where it actually
+ belongs). */
void
opentty(const char * tty)
{
int i;
- int fd = open(tty, O_RDWR);
+ int fd = open(tty, O_RDWR | O_NONBLOCK);
+ int flags = fcntl(fd, F_GETFL);
+
+ flags &= ~O_NONBLOCK;
+ fcntl(fd, F_SETFL, flags);
for (i = 0 ; i < fd ; i++)
close(i);
@@ -485,6 +513,12 @@ main(int argc, char **argv)
retcode = pam_set_item(pamh, PAM_TTY, tty);
PAM_FAIL_CHECK;
+ /* Andrew.Taylor@cal.montage.ca: Provide a user prompt to PAM
+ so that the "login: " prompt gets localized. Unfortunately,
+ PAM doesn't have an interface to specify the "Password: " string (yet). */
+ retcode = pam_set_item(pamh, PAM_USER_PROMPT, _("login: "));
+ PAM_FAIL_CHECK;
+
#if 0
/* other than iso-8859-1
* one more time due to reset tty by PAM
@@ -1050,7 +1084,8 @@ Michael Riepe <michael@stud.uni-hannover.de>
motd();
mail = getenv("MAIL");
- if (mail && stat(mail, &st) == 0 && st.st_size != 0) {
+ if (mail && stat(mail, &st) == 0 && st.st_size != 0
+ && st.st_size != REDHAT_IGNORED_MAILSIZE) {
printf(_("You have %smail.\n"),
(st.st_mtime > st.st_atime) ? _("new ") : "");
}
diff --git a/login-utils/mesg.c b/login-utils/mesg.c
index cc8c4010d..bfa17eb11 100644
--- a/login-utils/mesg.c
+++ b/login-utils/mesg.c
@@ -48,12 +48,12 @@
#include <sys/types.h>
#include <sys/stat.h>
-#include <err.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include "errs.h"
#include "nls.h"
int
diff --git a/login-utils/passwd.c b/login-utils/passwd.c
index 90054ccca..ba679cd23 100644
--- a/login-utils/passwd.c
+++ b/login-utils/passwd.c
@@ -68,8 +68,6 @@
#include "nls.h"
#include "env.h"
-#include "../version.h"
-
#ifndef _PATH_CHFN
# define _PATH_CHFN "/usr/bin/chfn"
# define _PATH_CHSH "/usr/bin/chsh"
diff --git a/login-utils/wall.c b/login-utils/wall.c
index 70a0df65b..d476edd64 100644
--- a/login-utils/wall.c
+++ b/login-utils/wall.c
@@ -56,10 +56,7 @@
#include <unistd.h>
#include <utmp.h>
#include "nls.h"
-#ifdef __linux__
-#include <locale.h>
#include "pathnames.h"
-#endif
void makemsg __P((char *));