User context for init.d scripts

User avatar
jayrock
Posts: 223
Joined: Thu Dec 02, 2010 12:55 am

User context for init.d scripts

Postby jayrock » Mon Jan 10, 2011 3:10 am

Hello,

I'm a little confused with regards to the scripts in init.d. In which context are they executed?

I have a script with some commands. I cannot execute those commands from shell as user, but only as root. The script however seems to work fine once put into init.d.

Googled for it but found contradicting answers here as well. Some claim the context for init.d is root, others say su is needed. It seems the majority thinks that init.d is owned and executed by root, but still I would be glad if someone could clarify this.

Then again, the script used here http://wiki.amahi.org/index.php/Mount_Shares_Locally requires an input file with root credentials - why?


Thanks,

jayrock

User avatar
moredruid
Expert
Posts: 791
Joined: Tue Jan 20, 2009 1:33 am
Location: Netherlands
Contact:

Re: User context for init.d scripts

Postby moredruid » Mon Jan 10, 2011 3:36 am

I think the /etc/init.d/* should be owned by root. You _can_ however run them in the sudo context if your privileges are sufficient. It might be sufficient to have them owned by a normal user but with the setuid bit set to root, I'm not sure.

could you post your script so we can analyse why it's failing for a normal useraccount?
echo '16i[q]sa[ln0=aln100%Pln100/snlbx]sbA0D2173656C7572206968616D41snlbxq' | dc
Galileo - HP Proliant ML110 G6 quad core Xeon 2.4GHz, 4GB RAM, 2x750GB RAID1 + 2x1TB RAID1 HDD

User avatar
jayrock
Posts: 223
Joined: Thu Dec 02, 2010 12:55 am

Re: User context for init.d scripts

Postby jayrock » Mon Jan 10, 2011 5:37 am

Thanks for your quick response, it's absolutely fine for me that init.d scripts run as root, I just to want be sure I understand what's going on.

One script is actually posted here, it's "hdparm" that requires the user to be root. As mentioned the script runs fine so no problem. http://forums.amahi.org/viewtopic.php?p=11679#p11679

The other one is a Ruby program that calls an ICMP ping procedure (and others) which requires root. Again, no promblem here, just want be sure about what I'm doing. See here: http://forums.amahi.org/viewtopic.php?p=11632#p11632

So to conclude, for now I assume that when I test the program / script as root, it will behave exactly as when it's started via init.d

Leaves the question open, why does http://wiki.amahi.org/index.php/Mount_Shares_Locally require root credentials to be supplied?

Cheers,

jayrock

User avatar
radioz
Posts: 406
Joined: Tue Nov 24, 2009 1:07 pm

Re: User context for init.d scripts

Postby radioz » Mon Jan 10, 2011 9:23 am

I haven't looked at the code for the mount_shares_locally script, but since it needs to mount file systems, it would need root permissions to do that.

User avatar
jayrock
Posts: 223
Joined: Thu Dec 02, 2010 12:55 am

Re: User context for init.d scripts

Postby jayrock » Mon Jan 10, 2011 10:04 am

Well, yes - but that's the whole point, as a script in init.d it has root permission anyway. Maybe it wouldnt need the supplied credentials then. It's just a bit confusing.

Who is online

Users browsing this forum: No registered users and 49 guests