Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've got a script in the Solaris 8 initialization phase, under /etc/rc3.d, that contains a su - username -c "a command", but I see thru the boot messages that the su command is asking for the user password. The result is that the boot proceed (there is no console to give su the user password) and the script fails.

The same script on a Solaris 10 works doing everything during the boot.

It is strange that the script run as root asks for a normal user password.

share|improve this question
    
What does su - username run as root do? Have you checked the manpage(s)? It is certainly weird. –  vonbrand Feb 6 '13 at 18:10
    
The - option is a shortcut for -l, that is to log in with the same environment of the target user. And it works if run interactively, without asking the password. –  fluca1978 Feb 7 '13 at 7:21
    
Check as who this script runs, i.e. add some who/whoami/others in there and collect the output [How this reminds me of a 400+ flamewar over at lwn.net on myths around systemd, where some insist that the sysvinit mess is easy to debug...] –  vonbrand Feb 7 '13 at 13:44
    
Wait a minute, what does Solaris 8 use for organizing boot? It's not the traditional SysV init anymore, is it? And Solaris 10? –  vonbrand Feb 7 '13 at 13:46
    
BTW, I got into the habit of using no shortcuts in init (and other system-y) scripts: Don't rely on $PATH, all options fully spelled out, ... This after a few rather unpleasant surprises. –  vonbrand Feb 7 '13 at 13:47

1 Answer 1

Unless you have some really strange custom PAM modules, there's no way that "su" is prompting for a password when run as root. By using su - user -c ... with a dash(-) instead of using su user -c ..., your boot script is processing their start-up "dot" files. It's probably that something in their dot files is invoking another su or that the invoked command is actually doing another su.

On a related note, for many scripts, it's helpful to put in a line reading exec < /dev/null. This will prevent any attempt to read standard input for most things. This may not help for boot scripts and su though, because unless I misremembering, the Solaris 8 su will grab the terminal instead of stdin.

Check the dot files. And try removing the "-" from su so that they aren't processed. If you have any settings that need to be visible for both interactive use and use by the boot script, consider putting just those settings into a so-called environment file. The dot files and the boot script can then both source the environment file. The settings in the environment file will probably change rarely and your boot process is less likely to be impacted by someone munging the dot files.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.