summaryrefslogtreecommitdiffstats
path: root/login-utils/agetty.c
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/agetty.c
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/agetty.c')
-rw-r--r--login-utils/agetty.c14
1 files changed, 12 insertions, 2 deletions
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);
}