Automatic login at boot time on Solaris 2.x

Thanks to all who responded to my original question regarding how to get a

SOlaris 2.x machine to automatically log in as a user at boot time.

Original Post:

> We had written a small utility that one could install in the /etc/ttytab

> file on SunOS 4.1.4

> that would allow the system to automatically log in as a specified user

and

> bring up

> OpenWindows with our application running - all without user intervention.

>

> ---- original ttytab SunOS 4.x ----

> # name getty type status comments

> #

> console "/usr/etc/getty cons8" sun on local secure

>

> ---- modified ttytab SunOS 4.x ----

> # name getty type status comments

> #

> console "/usr/appdir/bin/ru <user name>" sun on

local

> secure

>

> Does anyone know of a way to achieve the same functionality under Solaris

> 2.6?

Dieter Gobbers (gobbers@faw,uni-ulm.de responded with:

     add something like

     ru:23:respawn:/usr/appdir/bin/ru <user name>

     in /etc/inittab.

     But be careful and read the manpages before ;-)

Glenn Satchell (glenn@uniq.com.au) responded with:

     What about putting it in a script in /etc/rc3.d/S99ru that does the

same

     thing?

Joe Yao (jsdy@cais.com) responded with:

     Write a script that sets appropriate envoronment variables, opens

stdin

     and stdout and stderr, and does whatever 'init' used to do for

'getty'.

     Call this program from inside 'inittab' with an appropriate label and

at

     an appropriate level.

I ended up creating the following entry in /etc/inittab which calls the

script that follows.

     mp:34:wait:/<path to bin directory>/auto_login >/dev/console

2<>/dev/console </dev/console

Auto_login script:

#!/bin/csh

# @(#)auto_login.csh 1.1 97/12/08 (c) Copyright 1997 RSA

set HOME = <path to users home directory>

set USER = <user name>

# Verify that our user exists.

set exists = `ypmatch $USER passwd >& /dev/null`

if ( "$exists" == "" ) then

     set exists = `grep "^^$USER" /etc/passwd`

     if ( "$exists" == "" ) then

          echo "Could not locate $user in either the NIS passwd map or"

          echo "/etc/passwd. Without this user, the SW loaded"

          echo "in ${HOME} cannot run."

          echo "Please check that the installation completed successfully."

          exit 1

     endif

endif

# see if dtlogin session is already running - if so stop it

set dtrunning = `ps -eaf | grep dtlogin | grep -v grep | head -1 | awk '{

print $2 }'`

if ( "$dtrunning" != "" ) then

     /etc/init.d/dtlogin stop

endif

# The following line changes the ownership and mode of files (like /dev/fbs

# and /dev/kbd) that OpenWindows uses. By default, these files have a

# permission of 0600 and are owned by root. Normally, login(1) sets these

# permissions and modes however... as usual we are not normal. This is

# necessary for OpenWindows to run for a non-root user.

#

/usr/bin/chown $USER /dev/console /dev/kbd /dev/fbs/* /dev/sound/*

/dev/mouse >& /dev/null

# Now launch OpenWindows as the non-root user

# Note that this will cause the error message "can't access tty - no job

control for

# this shell" when the program runs. This is normal and will not cause any

problems

# with running the system.

su - $USER

# Done.

Best Regards,

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

_/_/ James L. Bovitz II _/_/

_/_/ Senior Field Engineering Coordinator _/_/

_/_/ RSA, Inc. - 25 N. Washington Street Rochester, New York 14614 _/_/

_/_/ Phone:(716)327-7134 Fax:(716)262-4808 E-Mail:jlb@rocsoft.com _/_/

_/_/ Web Site:http://www.rocsoft.com _/_/

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

[5639 byte] By [CodeProf.com] at [2007-12-25 11:56:00]