Re: prihlaseni do konzole bez hesla


To czdebian-l zavinac debian bod cz
From Hans Ginzel <hans zavinac kolej bod mff bod cuni bod cz>
Date Mon, 15 Dec 2003 16:39:29 +0100
Mail-followup-to czdebian-l zavinac debian bod cz
User-agent Mutt/1.5.4i

On Sun, Dec 14, 2003 at 03:41:52PM +0100, Juraj Kubelka wrote:
> mohl bych se zeptat, jak je mozne nastavit system tak, abych nemusel
> pri prihlaseni do konzole zadavat i heslo? Popripade, aby se na vsech
> konzolich automaticky prihlasil jeden uzivatel.

   Ja mam v /etc/inittab jen ctyri konsole, tj. toto je posledni radek

        4:23:respawn:/sbin/getty 38400 tty4

a v ~/.bash_profile

        if [ "`tty`" = "/dev/vc/4" ]
        then
                open -c8 bash
                open -c9 mutt
                open -c10 mc `readlink ~/_` ~/temp
                [ -e _ -a -d _ ] && cd _
                open -c5 bash
                open -c6 bash
                #open -c7 bash startx
                open -c7 bash
        fi

   Prihlasim-li se na 4te konsoli, otevrou se mi dalsi konsole s
pripadnymi aplikacemi.


   Jina moznost je zkompilovat si mingetty s nasl. patchem. Potom lze
mit v /etc/inittab radky typu:

        4:234:respawn:/sbin/mingetty --username hans --nopassword tty4

a byt prihlasen rovnou.


   Dalsi reseni je pocitac nevypinat a neodhlasovat se...
Bohuzel, ale SuspendToHD jsem zatim nerozchodil...



   Zdravi
                                                Hans Ginzel
--

--- mingetty.c.orig     Thu Jun  6 12:29:30 1996
+++ mingetty.c  Fri Jan 28 10:33:15 2000
@@ -25,6 +25,8 @@
  *  as published by the Free Software Foundation; either version
  *  2 of the License, or (at your option) any later version.
  *
+ *  Username command-line parameter by Michal Svec <rebel zavinac penguin bod 
cz>
+ *
  */

 #define DEBUG_THIS 0
@@ -76,6 +78,8 @@
 static int noclear = 0;
 /* Print the whole string of gethostname() instead of just until the next "." 
*/
 static int longhostname = 0;
+/* No password prompt */
+static int nopassword = 0;


 /*
@@ -385,6 +389,8 @@
 static struct option const long_options[] = {
        { "noclear", no_argument, &noclear, 1},
        { "long-hostname", no_argument, &longhostname, 1},
+       { "username", required_argument, 0, 'u'},
+       { "nopassword", no_argument, &nopassword, 1},
        { 0, 0, 0, 0 }
 };

@@ -393,7 +399,7 @@
  */
 int main (int argc, char **argv)
 {
-       char *logname, *s;
+       char *logname = 0, *s;
        int c;

        progname = argv[0];
@@ -410,6 +416,9 @@
                switch (c) {
                        case 0:
                                break;
+                       case 'u':
+                               logname = strdup(optarg);
+                               break;
                        default:
                                usage ();
                }
@@ -430,9 +439,14 @@
        /* flush input and output queues, important for modems */
        ioctl (0, TCFLSH, 2);

-       while ((logname = get_logname ()) == 0);
+       while (!logname)
+               logname = get_logname ();
+
+       if (nopassword)
+               execl (_PATH_LOGIN, _PATH_LOGIN, "-f", "--", logname, NULL);
+       else
+               execl (_PATH_LOGIN, _PATH_LOGIN, "--", logname, NULL);

-       execl (_PATH_LOGIN, _PATH_LOGIN, "--", logname, NULL);
        error ("%s: can't exec " _PATH_LOGIN ": %s", tty, sys_errlist[errno]);
        exit (0);
 }

Partial thread listing: