Operating System - HP-UX
1819966 Members
3838 Online
109607 Solutions
New Discussion юеВ

init.d script permission denied

 
Jeffrey S. Sims
Trusted Contributor

init.d script permission denied

Hi everyone,

Background: I have to create a second instance of a running "gateway" software to start up at boot. The gateway is RedBack (database stuff) and has to run as a different user, only one specified user can start the gateway. The old instance starts fine, so I copied that init.d script and edited it as needed, and then changed the environment variables in the /etc/rc.config.d file for UDTHOME,UDTBIN & RBHOME (special environment variables).

Situation: The command to start or stop the gateway dies when I try to execute it. The startup says it is already running and stop says permission denied. The command on the properly functioning gateway is su username -c "/path/to/program". The problem is the second or "newer" instance of the gateway will not start unless I put the command su - username -c "/path/to/program" (notice the - after su).

Tried: I have even stated all the environment variables given from the env command in the /etc/rc.config.d/file and still no luck.

Any suggestions as to what may be happening?
3 REPLIES 3
Jason Morgan_1
Advisor

Re: init.d script permission denied

I would suggest you create a second user account with the exact same permissions as the working user account. Remember this "RedBack" software may not normally allow a second instance of the program to run.

-Jason
Never Underestimate the Power of Human Stupidity -RAH
Jeffrey S. Sims
Trusted Contributor

Re: init.d script permission denied

The second instance will run perfectly if I put the - in the su command, or if I manually login as that user and type the command manually. There isn't a problem with not allowing a second instance in that respect. However there is something that is set with the su - that isn't set with just su.

Just a reminder, I have already copied the output from the env command and declared all of those environment variables and that didn't work either.
Jim Moffitt_1
Valued Contributor

Re: init.d script permission denied

Jeff, when you put the - after the su command it's like you telneted into that user. Here's an excerpt from the su man page:
If you specify the - option of the su command, the new shell starts up as if you just logged in, except as follows:

+ The HOME variable is reset to the new user's home directory.

+ If the new user name is root, the path and prompt variables are
reset:

PATH=/usr/bin:/usr/sbin:/sbin
PS1=#

For other user names:

PATH=/usr/bin
PS1=$

+ The rest of the environment is deleted and reset to the login
state. However, the login files are normally executed anyway,
usually restoring the expected value of PATH and other
variables.

However if you don't user the - after su:

If you omit the - option, the new shell starts up as if you invoked it as a subshell, except as follows:

+ If the new user name is root, the path and prompt variables are
reset:
PATH=/usr/bin:/usr/sbin:/sbin
PS1=#

+ The rest of the environment is retained.

Hope this helps explain it.