LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 04-09-2010, 05:30 PM   #1
racoco
LQ Newbie
 
Registered: Mar 2005
Location: 01833 USA
Distribution: fedora
Posts: 3

Rep: Reputation: 0
HowTo "su aUser" as root and not require a password


I need to write a cron script that will run on a SunOS 5.9. it will be kicked off as "root".

The script will "su anotherUser" and then do a bunch of stuff under the environment of "anotherUser" (which is an NIS userID, it is not a local user; ie it has no entry in /etc/passwd).

Now, for RHEL and AIX systems, I have successfully run this as follows (from w/in a cron script) as:

0 2 * * * su aUser -c "/whatever/aCommand"

or

0 2 * * * su -c "/whatever/aCommand" aUser

depending on the shell and OS. It just so happens that for those systems the "su" command - when run as root - does not require that the password be interactively entered. (I have nothing to do with the administration of these systems).

However, on a particular SunOS 5.9 host, the "su" always requires that a password be given (the user I am trying to "su" to is in the /etc/sudoers file with NOPASSWD specified; tho i do not think this has any bearing on the issue).

I suspect I need to twiddle something in /etc/pam.conf? But I cannot figure out what (if in fact that is the thing to do).

Any suggestions out there?

tx,

rich
 
Old 04-09-2010, 05:47 PM   #2
ShadowCat8
Member
 
Registered: Nov 2004
Location: San Bernardino, CA
Distribution: Gentoo, Arch, (RedHat4.x-9.x, FedoraCore 1.x-4.x, Debian Potato-Sarge, LFS 6.0, etc.)
Posts: 261

Rep: Reputation: 52
Greetings,

It has been a *long* time since I've had to mess with SunOS... Probably close to 10 years now. BUT, that being said, I think that if you want to accomplish running something as another user on a SunOS box, I think you need to use sudo to make it non-interactive.

HTH.
 
Old 04-09-2010, 10:23 PM   #3
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197

Rep: Reputation: 105Reputation: 105
Sudo and su are entirely different things.

Sudo is an add on piece of software that references the /etc/sudoers file and allows ordinary users to run commands with root privileges.

su is the operating system command for changing users.

As root user in both Solaris 9 and Solaris 10, I routinely su to another user without using a password. I use this, for example, to set people's vacation messages when they aren't comfortable with the command line to do it themselves.

I also have scripts that use that syntax:

su - backup -c "ssh ${TAPESERVER} \"mt -f ${TAPDEV} rewoffl\"" ;

for example (where the user is "backup", and I really don't remember or care what I ever set the password to for that user).

So, the question here is what is happening for the system that rococo is dealing with? Does that happen on the command line as well as in cron? Have you got the syntax right? Are you sure that's running as root? I suppose it's possible that there is some non standard setting that prevents root from being able to su to a user without the password? I'm not familiar with any such setting; but, assuming rococo has checked out everything else, that's the direction to be looking for an answer. It's a slightly difficult thing to google for.
 
Old 04-10-2010, 09:36 AM   #4
racoco
LQ Newbie
 
Registered: Mar 2005
Location: 01833 USA
Distribution: fedora
Posts: 3

Original Poster
Rep: Reputation: 0
choogendyk is correct. my issue is not related to 'sudo'. i can "sudo" (as the non-root user in question) w/o entering a password b/c I set up /etc/sudoers for that non-root user with tht NOPASSWD flag.

To be very precise (where nru = a non-root username):

nru: sudo cat /etc/sudoers #succeeds w/o need for password

My problem is this:

root: su nru -c /an/nfsmount/bashScript.sh
passwd:

That is, I am executing the above "su" command as root wishing to run
the bashScript.sh file as the non-root user nru, who is an NIS username (not a local user found in /etc/passwd). [In fact, the basj script also resides on an NFS mount under directories owned by 'nru'; but that is beside the point I believe.] On the SUN platform, I am asked for nru's password, even tho it is root running the command! This behavior does not occur on two RHEL hosts and an AIX host.

I ran this on the command-line testing things out before I put the command in root's cron file. It never occurred to me it might succeed under cron control but fail as root in a command shell. I cannot believe that is the case, but I suppose I ought to try it.

I really believe the answer is in the PAM configuration. But I cannot figure out which of the many "login" configs effect that. I also need to know if there are additional side-effects were I to discover which PAM line to modify.

This should not be so difficult...Sigh...
 
Old 04-17-2010, 02:24 PM   #5
carltm
Member
 
Registered: Jan 2007
Location: Canton, MI
Distribution: CentOS, SuSE, Red Hat, Debian, etc.
Posts: 703

Rep: Reputation: 99
It must be something about version 5.9. I just tried on OpenSolaris version
SunOS 5.11 and it works as expected.

Quote:
root@calculon:~# whoami
root
root@calculon:~# su - carl -c "whoami"
Sun Microsystems Inc. SunOS 5.11 snv_111b November 2008
carl
root@calculon:~#
You might want to see if there are any updates for the package containing
su. Also check if there are more than one executables named su.

Last edited by carltm; 04-17-2010 at 02:26 PM. Reason: added more
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"su - root" giving incorrect password but normal root login works. ?? arashi256 Linux - Newbie 10 06-03-2010 03:13 AM
Unable to reset root password / init: "x" respawning very fast gshenbag Linux - Enterprise 5 12-30-2009 02:19 AM
Tried to Install Flash Plugin but says "Authenticating as Root" password required David Underhill Linux - Laptop and Netbook 5 11-05-2009 05:36 AM
New system won't allow root after installation - using correct password and "root" kn2y Linux - Newbie 6 11-07-2008 07:52 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 04:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration