Operating System - HP-UX
1826291 Members
4666 Online
109692 Solutions
New Discussion

Re: startup (rc) script for non root user

 
David Makowsky
New Member

startup (rc) script for non root user

I would like to have a startup script start a process for a non root user. I would like the real user id, not just the effective user id, to be that of the user. Therefore I believe "su - user" is not an option. Is there any way to do this?
There are three types of people in the world. Those that are good at math and those that are not.
4 REPLIES 4
Paul Hite
Trusted Contributor

Re: startup (rc) script for non root user

"su - user" will set the real uid of the process to user.

If the process itself had the set-uid set and was owned by user but then run by root, then the process would have a real-uid of root but an effective-uid of user.

But the su command uses the setuid(2) system call set set the uid. So this will do what you want.
David Makowsky
New Member

Re: startup (rc) script for non root user

Let me rephrase what I am after. I login under a user account, say user abc, and then do a "su - def". I then type "whoami". I will see "def". However, if I type "who am i" (with spaces), I will see "abc". This is in fact why I (apparently mistakenly) believed that the "su -" would not change the real user id.

What I would like, and I am afraid this is going to sound confusing, is for a startup script to call a user process. If the user process were to do a "who am i" (with spaces) the return would not be root but would be the user id.
There are three types of people in the world. Those that are good at math and those that are not.
Paul Hite
Trusted Contributor

Re: startup (rc) script for non root user

"who am i" doesn't work like that. That command will examine /dev/tty to find the current terminal and then match the utmp record to see who logged in at that terminal.

In the case of processes that are run in the start-up scripts, there is no attached terminal. "who am i" should fail if things are working correctly. A similiar result would occur if you did "who am i" via remsh.

There is a "whoami" which just looks at the process' uid. But scripts that run via the start-up scripts should simply not be using "who am i" or any other terminal related commands.

We use "su - user" a lot in our start-up scripts and they all work fine.
Anthony Goonetilleke
Esteemed Contributor

Re: startup (rc) script for non root user

if you use the following syntax

su - oracle -c script

in you rc files it should run the script as the effective user i.e oracle
Minimum effort maximum output!