View Single Post
Posts: 152 | Thanked: 41 times | Joined on Dec 2009 @ Sydney
#14
Originally Posted by texaslabrat View Post
You can't use sudo like that...the "sudo gainroot" launches a new shell process but the next command in your script executes in the exiting "user"-owned shell. It's not a hard problem to fix in a "normal" linux distro (I typically use "su" with flags to switch users inside a script) but I'm not sure how you would do it with the seemingly unique way that the root account and user account are related in maemo. On the surface it would seem as though you could simply issue a "sudo ./myscript" but I don't think that works out of the box in maemo. Hopefully some of the more seasoned maemo veterans will have an answer for the on-liner you are seeking to create.

One thing you *might* try is to setuid the script (chown file to root, and then chmod u+s the file) that does the things you want to do. You would then execute it as "user" but it would automagically run as root. Can provide a nice huge security hole in most unix systems, but with the "sudo gainroot" thing that doesn't even require a password, I'm not sure that's a concern in this particular case.
Just run visudo as root and add scripts/commands you want to be able to run as a normal user with with root privileges.

That's the idea of the sudo system.