![]() |
[Announce] easyroot -- an even better way of becoming root
This is a simple utility for gaining root access. It is similar to (and inspired by) becomeroot, but better in a number of ways:
* sources .bashrc and other startup scripts when turning on root mode * correctly sets the home directory for user root * doesn't force the built-in shell onto the user In addition, there is now a shortcut for entering root mode - "root". ----- Edit: newer version of easyroot is backward compatible with 'sudo gainroot'. The features above (e.g. sourcing of .bashrc) are only activated by typing 'root'. Thanks to fanoush for this suggestion. ----- Sample session [user@nokia ~]$ root [root@nokia ~]$ Download easyroot here: http://maemostuff.com (PS This works for me, but it may not work for you. Backup your files just in case :)) |
Re: [Announce] easyroot -- an even better way of becoming root
I'm all for the easy option.
Will try it. Thanks. Zuber |
Re: [Announce] easyroot -- an even better way of becoming root
Quote:
|
Re: [Announce] easyroot -- an even better way of becoming root
Quote:
I am not sure what you mean by 100% compatible with 'sudo gainroot'. The original 'sudo gainroot' had serious problems, so deviating from it was a design goal. Let me elaborate a bit more on what I think is wrong with the current 'sudo gainroot': - (this seems to be a bug with busybox) After 'sudo gainroot', "~" still resolves to /home/user instead of /root. Similarly, if you type 'cd' with no arguments, you end up in /home/user. - with /bin/sh, none of the startup scripts (.bashrc, .profile, etc) are sourced. So if you want to have a custom prompt for root, you can't. - 'sudo gainroot' always starts in busybox's sorry-*** shell, even if I become root from bash. - I wasn't very happy with tons of logging (7 lines?) when switching to root. If I need to copy-paste something, the extra logging pushes the interesting stuff above the fold. 'su -' in my version works around all of the above problems. Also, please note that typing 'sudo gainroot' still works. 'root' is just a convenient shortcut. You can add 'alias root="sudo gainroot"' to your .bashrc to avoid the extra shell instance, though in practice I think the overhead of an extra shell is negligible. I am not sure about your 'exec' suggestions. I would think a new shell would be started anyway for 'sudo gainroot' regardless of what I put in 'root', because it is 'gainroot' that starts a new shell (with #!/bin/sh). No? Finally, the original 'sudo gainroot' starts a new shell too, so this script is no worse than the original if you invoke it with 'sudo gainroot'. Thanks. |
Re: [Announce] easyroot -- an even better way of becoming root
'sudo gainroot' does not change current directory, does not read .<whatever>rc (and thus does not mess environment variables in unknown way) etc. and is here for more than 2 years. If you want something better/easier/incompatible with this, you (IMO) should put it to your 'root' shortcut so the old way (=running sudo gainroot) still works in same way. Especially if you force people to chose either becomeroot or your package. Design goal of breaking compatibility doesn't look like good goal to me.
One example of compatibility is launching sudo gainroot from scripts to relaunch itself as root like this Code:
#!/bin/sh as for using exec - this is really small thing but as I said try to see with htop what happens when you launch your 'root' script an how many different processes (mainly shells) are spawned, kept in memory and wait for its child to exit. Exec call replaces current process so this does not happen. |
Re: [Announce] easyroot -- an even better way of becoming root
I just use GNU tar and or add ALL=ALL to user in /etc/sudoers
|
Re: [Announce] easyroot -- an even better way of becoming root
fanoush -- I see your point. I will try the suggestions in your original post. If they work, I will update the script. Thanks once again for your feedback.
|
Re: [Announce] easyroot -- an even better way of becoming root
Quote:
|
Re: [Announce] easyroot -- an even better way of becoming root
Thanks for your work ag2. I must say that several of my scripts use Fanoush's gainroot trick and it would be a problem if it broke. However, it would be great to have .bashrc working.
|
Re: [Announce] easyroot -- an even better way of becoming root
Changing su - to su helps only a little bit:
- .bashrc is still sourced - the value of ~ changes to /root The only difference is that the current directory doesn't change I suppose I can put an if statement in gainroot so that it calls su when called from root and continues to call /bin/sh otherwise. Would this be acceptable? Can you think of other workarounds? |
All times are GMT. The time now is 01:17. |
vBulletin® Version 3.8.8