[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

PATCH: add --loginpause to mingetty



Hello Florian,

the attached patches add an option to pause login until the user hits
a key.

We need something like it on OLPC because:

 - we don't want to set an empty password for either user root or olpc

 - at the same time, we want to allow users to login as root at the
   console

 - finally, we do not wish to waste memory on shells the user hasn't
   yet used

The security model we are implementing is very different from UNIX: we
ultimately trust the user at the console, but we don't trust applications
and we don't want them to gain root privileges using su or sudo with no
password.

I'm committing these changes to the OLPC-2 branch of mingetty in
Fedora CVS.  Please, let me know you'd like to merge them or
something similar.

-- 
 \___/
 |___|   Bernardo Innocenti - http://www.codewiz.org/
  \___\  One Laptop Per Child - http://www.laptop.org/
diff -rup mingetty-1.07.orig/mingetty.8 mingetty-1.07/mingetty.8
--- mingetty-1.07.orig/mingetty.8	2003-05-14 04:55:43.000000000 -0400
+++ mingetty-1.07/mingetty.8	2008-01-09 18:17:06.000000000 -0500
@@ -6,6 +6,7 @@ mingetty \- minimal getty for consoles
 [\-\-noclear] [\-\-nonewline] [\-\-noissue] [\-\-nohangup] [\-\-nohostname]
 [\-\-long\-hostname] [\-\-loginprog=/bin/login] [\-\-nice=10] [\-\-delay=5]
 [\-\-chdir=/home] [\-\-chroot=/chroot] [\-\-autologin username]
+[\-\-loginpause]
 .I tty
 .PP
 .SH DESCRIPTION
@@ -62,6 +63,11 @@ Log the specified user automatically in 
 a login name and password. Check the \-f option from
 .B /bin/login
 for this.
+.TP
+.B \-\-loginpause
+Wait for any key before dropping to the login prompt.
+Can be combined with \fB\-\-autologin\fR to save memory by lazily spawning
+shells.
 .PP
 .SH "ISSUE ESCAPES"
 .B mingetty 
diff -rup mingetty-1.07.orig/mingetty.c mingetty-1.07/mingetty.c
--- mingetty-1.07.orig/mingetty.c	2004-01-03 08:15:56.000000000 -0500
+++ mingetty-1.07/mingetty.c	2008-01-09 18:10:15.000000000 -0500
@@ -74,6 +74,8 @@ static char *ch_dir = NULL;
 static int priority = 0;
 /* automatic login with this user */
 static char *autologin = NULL;
+/* try to read a char before dropping to login prompt */
+static int loginpause = 0;
 
 /* error() - output error messages */
 static void error (const char *fmt, ...)
@@ -283,6 +285,10 @@ static void do_prompt (int showlogin)
 		}
 		fclose (fd);
 	}
+    if (loginpause) {
+		puts("[press ENTER to login]");
+		getc(stdin);
+	}
 	if (nohostname == 0)
 		printf ("%s ", hn);
 	if (showlogin)
@@ -327,11 +333,13 @@ static void usage (void)
 		"[--nohangup] [--nohostname] [--long-hostname] "
 		"[--loginprog=/bin/login] [--nice=10] [--delay=10] "
 		"[--chdir=/home] [--chroot=/chroot] [--autologin=user] "
+		"[--loginpause] "
 		"tty' with e.g. tty=tty1", progname);
 }
 
 static struct option const long_options[] = {
 	{ "autologin", required_argument, NULL, 'a' },
+	{ "loginpause", no_argument, &loginpause, 'p' },
 	{ "chdir", required_argument, NULL, 'w' },
 	{ "chroot", required_argument, NULL, 'r' },
 	{ "delay", required_argument, NULL, 'd' },
@@ -366,7 +374,7 @@ int main (int argc, char **argv)
 	putenv ("TERM=linux");
 #endif
 
-	while ((c = getopt_long (argc, argv, "a:d:l:n:w:r:", long_options,
+	while ((c = getopt_long (argc, argv, "a:p:d:l:n:w:r:", long_options,
 		(int *) 0)) != EOF) {
 		switch (c) {
 		case 0:
diff -u -p -r1.2 mingetty-1.00-opt.patch
--- mingetty-1.00-opt.patch	9 Sep 2004 08:31:33 -0000	1.2
+++ mingetty-1.00-opt.patch	10 Jan 2008 00:15:11 -0000
@@ -1,10 +1,11 @@
 --- mingetty-1.00/Makefile.rpm	Mon Mar  4 15:27:11 2002
 +++ mingetty-1.00/Makefile	Mon Mar  4 15:27:34 2002
-@@ -1,6 +1,6 @@
+@@ -1,6 +1,7 @@
  DESTDIR=
  CC=gcc
 -CFLAGS=-O2 -Wall -W -pipe -D_GNU_SOURCE
 +CFLAGS=$(RPM_OPTS) -Wall -D_GNU_SOURCE
++LDFLAGS=$(RPM_OPTS)
  MANDIR=/usr/share/man/man8
  SBINDIR=/sbin
  
Index: mingetty.spec
===================================================================
RCS file: /cvs/pkgs/rpms/mingetty/devel/mingetty.spec,v
retrieving revision 1.19
diff -u -p -r1.19 mingetty.spec
--- mingetty.spec	8 Jan 2008 09:39:25 -0000	1.19
+++ mingetty.spec	10 Jan 2008 00:15:11 -0000
@@ -2,11 +2,12 @@ Summary: A compact getty program for vir
 Name: mingetty
 Version: 1.07
 License: GPLv2+
-Release: 8%{?dist}
+Release: 9%{?dist}
 Group: System Environment/Base
 URL: http://sourceforge.net/projects/mingetty/
 Source: mingetty-%{version}.tar.gz
-Patch: mingetty-1.00-opt.patch
+Patch0: mingetty-1.00-opt.patch
+Patch1: mingetty-1.07-loginpause.patch
 BuildRoot: %{_tmppath}/%{name}-root
 
 %description
@@ -15,8 +16,10 @@ use only on virtual consoles.  Mingetty 
 lines (you should use the mgetty program in that case).
 
 %prep
+rm -rf $RPM_BUILD_ROOT
 %setup -q
-%patch -p1
+%patch0 -p1
+%patch1 -p1
 
 %build
 make "RPM_OPTS=$RPM_OPT_FLAGS"
@@ -38,6 +41,10 @@ rm -rf $RPM_BUILD_ROOT
 %{_mandir}/man8/mingetty.*
 
 %changelog
+* Wed Jan 09 2008 Bernardo Innocenti <bernie codewiz org> - 1.07-9
+- add mingetty-1.07-loginpause.patch
+- improve mingetty-1.00-opt.patch to enable cross building on a 64bit host
+
 * Tue Jan 08 2008 Florian La Roche <laroche redhat com> - 1.07-8
 - add sf.net project url
 - add dist macro to release

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]