summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Robbins <drobbins@gentoo.org>2003-01-01 00:21:15 +0000
committerDaniel Robbins <drobbins@gentoo.org>2003-01-01 00:21:15 +0000
commit2fb5b288232bb2754723dd6e927fe859e73ed4f0 (patch)
tree986156127a06adb8626e5d3f0a390d1d80d4aa1a /net-dialup
parentadded sparc keyword (diff)
downloadgentoo-2-2fb5b288232bb2754723dd6e927fe859e73ed4f0.tar.gz
gentoo-2-2fb5b288232bb2754723dd6e927fe859e73ed4f0.tar.bz2
gentoo-2-2fb5b288232bb2754723dd6e927fe859e73ed4f0.zip
new tweakage for autologin
Diffstat (limited to 'net-dialup')
-rw-r--r--net-dialup/mingetty/ChangeLog6
-rw-r--r--net-dialup/mingetty/files/mingetty-1.00-autologin.patch426
-rw-r--r--net-dialup/mingetty/mingetty-1.00.3.ebuild4
3 files changed, 433 insertions, 3 deletions
diff --git a/net-dialup/mingetty/ChangeLog b/net-dialup/mingetty/ChangeLog
index c2a571752d88..001f902ef49e 100644
--- a/net-dialup/mingetty/ChangeLog
+++ b/net-dialup/mingetty/ChangeLog
@@ -1,6 +1,10 @@
# ChangeLog for net-dialup/mingetty
# Copyright 2002 Gentoo Technologies, Inc.; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/net-dialup/mingetty/ChangeLog,v 1.3 2002/12/31 23:53:31 drobbins Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-dialup/mingetty/ChangeLog,v 1.4 2003/01/01 00:21:07 drobbins Exp $
+
+ 31 Dec 2002; Daniel Robbins <drobbins@gentoo.org>: Added autologin patch to
+ mingetty-1.00.3. Not bumping rev as I did this about 20 mins after unmasking
+ this for x86. This patch includes the Red Hat "opt" patch.
*mingetty-1.00.3 (31 Dec 2002)
diff --git a/net-dialup/mingetty/files/mingetty-1.00-autologin.patch b/net-dialup/mingetty/files/mingetty-1.00-autologin.patch
new file mode 100644
index 000000000000..b9fd596e5de6
--- /dev/null
+++ b/net-dialup/mingetty/files/mingetty-1.00-autologin.patch
@@ -0,0 +1,426 @@
+diff -urN mingetty-1.00/Makefile mingetty-1.00-autologin/Makefile
+--- mingetty-1.00/Makefile Mon Mar 4 07:23:56 2002
++++ mingetty-1.00-autologin/Makefile Tue Dec 31 16:54:22 2002
+@@ -1,6 +1,6 @@
+ DESTDIR=
+ CC=gcc
+-CFLAGS=-O2 -Wall -pipe -D_GNU_SOURCE
++CFLAGS=$(RPM_OPTS) -Wall -D_GNU_SOURCE
+ MANDIR=/usr/man/man8
+ SBINDIR=/sbin
+
+Binary files mingetty-1.00/mingetty and mingetty-1.00-autologin/mingetty differ
+diff -urN mingetty-1.00/mingetty-0.9.4-autologin.patch mingetty-1.00-autologin/mingetty-0.9.4-autologin.patch
+--- mingetty-1.00/mingetty-0.9.4-autologin.patch Mon Mar 4 07:14:22 2002
++++ mingetty-1.00-autologin/mingetty-0.9.4-autologin.patch Wed Dec 31 17:00:00 1969
+@@ -1,202 +0,0 @@
+---- mingetty-0.9.4/mingetty.8.autologin Fri Jun 14 09:54:01 1996
+-+++ mingetty-0.9.4/mingetty.8 Sun Nov 26 10:34:49 2000
+-@@ -3,7 +3,7 @@
+- mingetty \- minimal getty for consoles
+- .SH SYNOPSIS
+- .B mingetty
+--[\-\-noclear] [\-\-long\-hostname]
+-+[\-\-noclear] [\-\-long\-hostname] [\-\-autologin username]
+- .I tty
+- .PP
+- .SH DESCRIPTION
+-@@ -26,6 +26,41 @@
+- .B \-\-long\-hostname
+- By default the hostname is only printed until the first dot.
+- With this option enabled, the full text from gethostname() is shown.
+-+.TP
+-+.B \-\-autologin username
+-+Log the specified user onto the console (normally
+-+.IR /dev/tty1 )
+-+when the system is first booted without prompting for a username or
+-+password.
+-+.IP
+-+When the autologin option is supplied,
+-+.B mingetty
+-+will check that the controlling terminal is the console (normally
+-+.IR /dev/tty1 ),
+-+that a reasonable username has been supplied, and that this is the
+-+first autologin request since the system has booted. If all of these
+-+conditions have been met, a request for an unauthenticated login is
+-+passed to the
+-+.B login
+-+program. Otherwise, a normal interactive login is performed.
+-+.IP
+-+The
+-+.B login
+-+program may deny the request for an unauthenticated login. Typically
+-+this will happen when the user is root, has a UID of 0, or whenever a
+-+normal interactive login would be denied due to the access
+-+restrictions specified in the
+-+.IR nologin ,
+-+.IR usertty ,
+-+or
+-+.I securetty
+-+files.
+-+.IP
+-+Only a single autologin request will be issued after a system boot.
+-+If the automated login request is denied, or if the user logs out,
+-+.B mingetty
+-+will revert to performing normal interactive logins for all subsequent
+-+login requests.
+- .PP
+- .SH "ISSUE ESCAPES"
+- .B mingetty
+-@@ -63,7 +98,8 @@
+- .PP
+- .SH FILES
+- .IR /etc/issue ,
+--.IR /var/run/utmp .
+-+.IR /var/run/utmp ,
+-+.IR /var/log/autologin .
+- .PP
+- .SH "SEE ALSO"
+- .BR mgetty (8),
+---- mingetty-0.9.4/mingetty.c.autologin Sun Nov 26 10:54:13 2000
+-+++ mingetty-0.9.4/mingetty.c Sun Nov 26 10:28:29 2000
+-@@ -17,7 +17,7 @@
+- * should be very reliable. For a modem getty, I'd also use nothing else
+- * but mgetty.
+- *
+-- * Usage: mingetty [--noclear] tty
+-+ * Usage: mingetty [--noclear] [--autologin username] tty
+- * Example entry in /etc/inittab: 1:123:respawn:/sbin/mingetty tty1
+- *
+- * This program is free software; you can redistribute it and/or
+-@@ -49,6 +49,20 @@
+- #endif
+-
+- #ifdef linux
+-+/* Autologin stuff. Currently Linux-specific, since there's no
+-+ standard way of getting the system boot time. The kernel.h and the
+-+ sysinfo prototype are used to get the system uptime under Linux. */
+-+#include <linux/kernel.h>
+-+int sysinfo(struct sysinfo *info);
+-+
+-+/* AUTO_LAST points to a timestamp file used to limit autologins to
+-+ one per system boot. */
+-+#define AUTO_LAST "/var/log/autologin"
+-+
+-+/* AUTO_TTY is the tty on which autologins will be accepted. If set
+-+ to an empty string, autologins will be accepted on any tty. */
+-+#define AUTO_TTY "tty1"
+-+
+- #include <sys/param.h>
+- #define USE_SYSLOG
+- #endif
+-@@ -80,7 +94,8 @@
+- static int noclear = 0;
+- /* Print the whole string of gethostname() instead of just until the next "." */
+- static int longhostname = 0;
+--
+-+/* If supplied, attempt an automatic login with this username. */
+-+static char *autologin_name = NULL;
+-
+- /*
+- * output error messages
+-@@ -385,6 +400,62 @@
+- return logname;
+- }
+-
+-+/*
+-+ * autologin_ok -- returns 1 if it's okay to auto-login when:
+-+ * this login is from /dev/tty1; and
+-+ * there was a login name passed with the --autologin option; and
+-+ * the autologin_name contains only "nice" characters; and
+-+ * this is the first autologin attempt since the last boot;
+-+ * return 0 otherwise.
+-+ */
+-+static int autologin_ok(void)
+-+{
+-+ char c, *cp;
+-+ int stat_err, fd;
+-+ struct sysinfo info;
+-+ struct stat sbuf;
+-+
+-+ /* Autologins are restricted to AUTO_TTY if non-empty. */
+-+ if (AUTO_TTY[0] && strcmp(tty, AUTO_TTY))
+-+ return 0;
+-+
+-+ /* An all-alphanumeric autologin name must be supplied. */
+-+ if (autologin_name == NULL || autologin_name[0] == '\0')
+-+ return 0;
+-+ for (cp = autologin_name; (c = *cp); cp++)
+-+ if (!isalnum(c) && c != '_')
+-+ return 0;
+-+
+-+ /* Get the uptime in info.uptime, and the last autologin time
+-+ in sbuf.st_mtime. */
+-+ sysinfo(&info);
+-+ stat_err = stat(AUTO_LAST, &sbuf);
+-+
+-+ /* If a stat error other than "no such file" occurs, I don't
+-+ know what went wrong, so I'll proceed with caution by
+-+ denying the autologin request. */
+-+ if (stat_err && errno != ENOENT)
+-+ return 0;
+-+
+-+ /* If there's been an autologin granted since the last boot,
+-+ deny this and any subsequent attempts. Note that this test
+-+ is skipped if the AUTO_LAST file doesn't exist. */
+-+ if (!stat_err && time(NULL) - info.uptime < sbuf.st_mtime)
+-+ return 0;
+-+
+-+ /* Create the AUTO_LAST file. The mtime of this file provides
+-+ a persistent record of the last time that an autologin
+-+ request was granted. Deny the autologin request if either
+-+ the file open or file close fails. */
+-+ if ((fd=open(AUTO_LAST, O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0)
+-+ return 0;
+-+ if (close(fd) != 0)
+-+ return 0;
+-+
+-+ /* All tests are okay, so grant the autologin request. */
+-+ return 1;
+-+}
+-+
+- static void usage (void)
+- {
+- error ("usage: '%s tty' with e.g. tty=tty1", progname);
+-@@ -393,6 +464,7 @@
+- static struct option const long_options[] = {
+- { "noclear", no_argument, &noclear, 1},
+- { "long-hostname", no_argument, &longhostname, 1},
+-+ { "autologin", required_argument, NULL, 'a'},
+- { 0, 0, 0, 0 }
+- };
+-
+-@@ -418,6 +490,9 @@
+- switch (c) {
+- case 0:
+- break;
+-+ case 'a':
+-+ autologin_name = optarg;
+-+ break;
+- default:
+- usage ();
+- }
+-@@ -438,9 +513,12 @@
+- /* flush input and output queues, important for modems */
+- ioctl (0, TCFLSH, 2);
+-
+-- while ((logname = get_logname ()) == 0);
+--
+-- execl (_PATH_LOGIN, _PATH_LOGIN, "--", logname, NULL);
+-+ if (autologin_ok()) {
+-+ execl (_PATH_LOGIN, _PATH_LOGIN, "-f", autologin_name, NULL);
+-+ } else {
+-+ while ((logname = get_logname ()) == 0) ;
+-+ execl (_PATH_LOGIN, _PATH_LOGIN, "--", logname, NULL);
+-+ }
+- error ("%s: can't exec " _PATH_LOGIN ": %s", tty, sys_errlist[errno]);
+- exit (0);
+- }
+diff -urN mingetty-1.00/mingetty.8 mingetty-1.00-autologin/mingetty.8
+--- mingetty-1.00/mingetty.8 Mon Mar 4 07:00:44 2002
++++ mingetty-1.00-autologin/mingetty.8 Tue Dec 31 17:00:04 2002
+@@ -3,7 +3,7 @@
+ mingetty \- minimal getty for consoles
+ .SH SYNOPSIS
+ .B mingetty
+-[\-\-noclear] [\-\-long\-hostname]
++[\-\-noclear] [\-\-long\-hostname] [\-\-autologin username]
+ .I tty
+ .PP
+ .SH DESCRIPTION
+@@ -26,6 +26,41 @@
+ .B \-\-long\-hostname
+ By default the hostname is only printed until the first dot.
+ With this option enabled, the full text from gethostname() is shown.
++.TP
++.B \-\-autologin username
++Log the specified user onto the console (normally
++.IR /dev/tty1 )
++when the system is first booted without prompting for a username or
++password.
++.IP
++When the autologin option is supplied,
++.B mingetty
++will check that the controlling terminal is the console (normally
++.IR /dev/tty1 ),
++that a reasonable username has been supplied, and that this is the
++first autologin request since the system has booted. If all of these
++conditions have been met, a request for an unauthenticated login is
++passed to the
++.B login
++program. Otherwise, a normal interactive login is performed.
++.IP
++The
++.B login
++program may deny the request for an unauthenticated login. Typically
++this will happen when the user is root, has a UID of 0, or whenever a
++normal interactive login would be denied due to the access
++restrictions specified in the
++.IR nologin ,
++.IR usertty ,
++or
++.I securetty
++files.
++.IP
++Only a single autologin request will be issued after a system boot.
++If the automated login request is denied, or if the user logs out,
++.B mingetty
++will revert to performing normal interactive logins for all subsequent
++login requests.
+ .PP
+ .SH "ISSUE ESCAPES"
+ .B mingetty
+@@ -64,7 +99,8 @@
+ .PP
+ .SH FILES
+ .IR /etc/issue ,
+-.IR /var/run/utmp .
++.IR /var/run/utmp ,
++.IR /var/log/autologin .
+ .PP
+ .SH "SEE ALSO"
+ .BR mgetty (8),
+diff -urN mingetty-1.00/mingetty.c mingetty-1.00-autologin/mingetty.c
+--- mingetty-1.00/mingetty.c Mon Mar 4 07:10:01 2002
++++ mingetty-1.00-autologin/mingetty.c Tue Dec 31 17:11:36 2002
+@@ -10,7 +10,7 @@
+ * should be very reliable. For a modem getty, I'd also use nothing else
+ * but mgetty.
+ *
+- * Usage: mingetty [--noclear] tty
++ * Usage: mingetty [--noclear] [--autologin username] tty
+ * Example entry in /etc/inittab: 1:123:respawn:/sbin/mingetty tty1
+ *
+ * This program is free software; you can redistribute it and/or
+@@ -46,7 +46,22 @@
+ #define USE_SYSLOG
+ #endif
+
+- /* If USE_SYSLOG is undefined all diagnostics go directly to /dev/console. */
++/* Autologin stuff. Currently Linux-specific, since there's no
++ standard way of getting the system boot time. The kernel.h and the
++ sysinfo prototype are used to get the system uptime under Linux. */
++#include <linux/kernel.h>
++int sysinfo(struct sysinfo *info);
++
++/* AUTO_LAST points to a timestamp file used to limit autologins to
++ one per system boot. */
++#define AUTO_LAST "/var/log/autologin"
++
++/* AUTO_TTY is the tty on which autologins will be accepted. If set
++ to an empty string, autologins will be accepted on any tty. */
++#define AUTO_TTY "tty1"
++
++/* If USE_SYSLOG is undefined all diagnostics go directly to /dev/console. */
++
+ #ifdef USE_SYSLOG
+ #include <sys/syslog.h>
+ #endif
+@@ -73,7 +88,8 @@
+ static int noclear = 0;
+ /* Print the whole string of gethostname() instead of just until the next "." */
+ static int longhostname = 0;
+-
++/* If supplied, attempt an automatic login with this username. */
++static char *autologin_name = NULL;
+
+ /*
+ * output error messages
+@@ -378,6 +394,62 @@
+ return logname;
+ }
+
++/*
++ * autologin_ok -- returns 1 if it's okay to auto-login when:
++ * this login is from /dev/tty1; and
++ * there was a login name passed with the --autologin option; and
++ * the autologin_name contains only "nice" characters; and
++ * this is the first autologin attempt since the last boot;
++ * return 0 otherwise.
++ */
++static int autologin_ok(void)
++{
++ char c, *cp;
++ int stat_err, fd;
++ struct sysinfo info;
++ struct stat sbuf;
++
++ /* Autologins are restricted to AUTO_TTY if non-empty. */
++ if (AUTO_TTY[0] && strcmp(tty, AUTO_TTY))
++ return 0;
++
++ /* An all-alphanumeric autologin name must be supplied. */
++ if (autologin_name == NULL || autologin_name[0] == '\0')
++ return 0;
++ for (cp = autologin_name; (c = *cp); cp++)
++ if (!isalnum(c) && c != '_')
++ return 0;
++
++ /* Get the uptime in info.uptime, and the last autologin time
++ in sbuf.st_mtime. */
++ sysinfo(&info);
++ stat_err = stat(AUTO_LAST, &sbuf);
++
++ /* If a stat error other than "no such file" occurs, I don't
++ know what went wrong, so I'll proceed with caution by
++ denying the autologin request. */
++ if (stat_err && errno != ENOENT)
++ return 0;
++
++ /* If there's been an autologin granted since the last boot,
++ deny this and any subsequent attempts. Note that this test
++ is skipped if the AUTO_LAST file doesn't exist. */
++ if (!stat_err && time(NULL) - info.uptime < sbuf.st_mtime)
++ return 0;
++
++ /* Create the AUTO_LAST file. The mtime of this file provides
++ a persistent record of the last time that an autologin
++ request was granted. Deny the autologin request if either
++ the file open or file close fails. */
++ if ((fd=open(AUTO_LAST, O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0)
++ return 0;
++ if (close(fd) != 0)
++ return 0;
++
++ /* All tests are okay, so grant the autologin request. */
++ return 1;
++}
++
+ static void usage (void)
+ {
+ error ("usage: '%s tty' with e.g. tty=tty1", progname);
+@@ -386,6 +458,7 @@
+ static struct option const long_options[] = {
+ { "noclear", no_argument, &noclear, 1},
+ { "long-hostname", no_argument, &longhostname, 1},
++ { "autologin", required_argument, NULL, 'a'},
+ { 0, 0, 0, 0 }
+ };
+
+@@ -415,6 +488,9 @@
+ switch (c) {
+ case 0:
+ break;
++ case 'a':
++ autologin_name = optarg;
++ break;
+ default:
+ usage ();
+ }
+@@ -435,9 +511,12 @@
+ /* flush input and output queues, important for modems */
+ ioctl (0, TCFLSH, 2);
+
+- while ((logname = get_logname ()) == 0);
+-
+- execl (_PATH_LOGIN, _PATH_LOGIN, "--", logname, NULL);
++ if (autologin_ok()) {
++ execl (_PATH_LOGIN, _PATH_LOGIN, "-f", autologin_name, NULL);
++ } else {
++ while ((logname = get_logname ()) == 0) ;
++ execl (_PATH_LOGIN, _PATH_LOGIN, "--", logname, NULL);
++ }
+ error ("%s: can't exec " _PATH_LOGIN ": %s", tty, sys_errlist[errno]);
+ exit (0);
+ }
+Binary files mingetty-1.00/mingetty.o and mingetty-1.00-autologin/mingetty.o differ
diff --git a/net-dialup/mingetty/mingetty-1.00.3.ebuild b/net-dialup/mingetty/mingetty-1.00.3.ebuild
index 92357b1c4846..359a86d46480 100644
--- a/net-dialup/mingetty/mingetty-1.00.3.ebuild
+++ b/net-dialup/mingetty/mingetty-1.00.3.ebuild
@@ -1,6 +1,6 @@
# Copyright 2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/net-dialup/mingetty/mingetty-1.00.3.ebuild,v 1.1 2002/12/31 23:53:31 drobbins Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-dialup/mingetty/mingetty-1.00.3.ebuild,v 1.2 2003/01/01 00:21:07 drobbins Exp $
RHP=${PN}-1.00
S=${WORKDIR}/${RHP}
@@ -21,7 +21,7 @@ src_unpack() {
rpm2targz ${DISTDIR}/${MYP}.src.rpm || die
tar zxf ${WORKDIR}/${MYP}.src.tar.gz || die
tar zxf ${WORKDIR}/${RHP}.tar.gz || die
- patch -p0 < ${RHP}-opt.patch || die
+ patch -p0 < ${FILESDIR}/mingetty-1.00-autologin.patch || die
}
src_compile() {