Problem with running a script at startup as root?

Usman, I think you have at least two options I already mentioned.

An easiest way

Make a set-UID binary that will(check who started it & allow usage if parent process owner can run it) run prepared script and exit. Put into startup in your desktop manager, that's all. Just be warned it is not the best way and it needs a bit of C coding. Basically you need to make a code like this sample:

int main(){
    setuid(0);
    system("/bin/sh /root/bin/mounts.sh");
}

Be aware that this is a hack, not solution, really. And be sure to use root:allowed_group and 4750 rights on binary if you don't need it to be run by everyone. Remember to add all users which may start this up to allowed_group(pick your name).

A good way

Other, much better way is to make a sort of daemon, spawned @ system boot(say, from init-scripts), but I am unsure how exactly are you going to detect when new X session is started, I wasn't into that topic yet, I can't give any clear advices here.


Set correct permissions on mounted drive path then and you're done.