maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N900 (https://talk.maemo.org/forumdisplay.php?f=44)
-   -   How to disable root access? (https://talk.maemo.org/showthread.php?t=36345)

smage 2009-12-08 22:06

How to disable root access?
 
Hey everyone,

I've installed rootsh to mess around a bit. However, I realized that its been more than 6 years since I've used linux extensively, and I don't want to make my n900 a test device for that.

I tried to uninstall rootsh, but the uninstall does not work.

The quetion is how can I disable the root access now?

I've searched extensively but was unable to find an answer.

Alex Atkin UK 2009-12-08 22:13

Re: How to disable root access?
 
Just dont use it. Its not like it permanently locks you in a root shell, you have to explicitly ask to become root.

smage 2009-12-08 22:16

Re: How to disable root access?
 
yeah that's true, until a curious friend or relative bricks it :P

cpitchford 2009-12-08 22:27

Re: How to disable root access?
 
To be fair, a non-root user could still cause some nasty damage..

Assuming the rootsh package was used. The postinst script (which is run as part of the package installation) is:

#!/bin/sh -e

cp /usr/sbin/gainroot /usr/sbin/gainroot.old
echo '
#!/bin/sh
#From Andrey Gubarev easyroot.
trap exit SIGHUP SIGINT SIGTERM
PATH=/bin:/usr/bin:/sbin:/usr/sbin
if [ "$1" = "--use-su" ]
then
exec su -
else
echo "Root shell enabled"
/bin/sh
fi
' > /usr/sbin/gainroot
chmod 4755 /usr/bin/rootsh
exit 0

It seems that the package replaces the gainroot file in /usr/sbin
But the prerm script (which is called when the package is removed) does:

mv /usr/sbin/gainroot.old /usr/sbin/gainroot


But only if /usr/sbin/gainroot is executable..

try the following:

[ -x /usr/sbin/gainroot.old ] && echo "yeah, it is"

If it is executable, removing the package should remove root access.. If it isn't executable, the cp line in the postinst script is wrong.. it should be cp -p to ensure executable flags are copied too..

long and short, removing the rootsh package should remove root access via sudo gainroot

smage 2009-12-08 23:34

Re: How to disable root access?
 
I wasn't able to execute the script any other suggestions?

cpitchford 2009-12-08 23:48

Re: How to disable root access?
 
Quote:

Originally Posted by smage (Post 417670)
I wasn't able to execute the script any other suggestions?

That is a bit freaky!

On my device, the gainroot.old file (created with rootsh is installed) is executable..

Try this..
uninstall rootsh using package manager

sudo gainroot
(which is apparently still working, if not.. job done! :) )

dpkg -l |grep rootsh
(make sure it isn't installed anymore)

chmod 755 /usr/sbin/gainroot.old
chown root:root /usr/sbin/gainroot.old
mv /usr/sbin/gainroot.old /usr/sbin/gainroot

exit

that'll probably do it!

Can't see a reason why it wouldn't uninstall sucessfully! I still think the cp in the install script should be cp -p, but there you go!

Devil 2009-12-08 23:54

Re: How to disable root access?
 
OT: is it me or is this programming language and stuff major boring *****?

i mean i am not dumb but seriously. its just friggin letters and symbols and combinations of it. i study math, which is quite the same actually. just dont see why i am doing that. and reading the coding stuff. cant get there with my mind.

smage 2009-12-08 23:55

Re: How to disable root access?
 
using the package manager I get the message: Unable to uninstall 'rootsh'

mikkov 2009-12-09 00:20

Re: How to disable root access?
 
Post the log from application manager here. And what does "I wasn't able to execute the script" mean anyway?

smage 2009-12-09 00:22

Re: How to disable root access?
 
ok

sudo gainroot
(which is apparently still working, if not.. job done! )
- this one still works

dpkg -l |grep rootsh
(make sure it isn't installed anymore)
- it's still installed

chmod 755 /usr/sbin/gainroot.old
chown root:root /usr/sbin/gainroot.old
mv /usr/sbin/gainroot.old /usr/sbin/gainroot
I run these and the old file is replaced. However, rootsh is still installed and even after a device restart I'm still able to gain root. Also in the package manager, rootsh is still shown as installe.

mikkov 2009-12-09 00:35

Re: How to disable root access?
 
Quote:

Originally Posted by smage (Post 417763)
ok
I run these and the old file is replaced. However, rootsh is still installed and even after a device restart I'm still able to gain root. Also in the package manager, rootsh is still shown as installe.

That's because you didn't remove it at any point. Try to remove it as root from command line:
dpkg -r rootsh

If it doesn't work, copy&paste the output here.

smage 2009-12-09 00:46

Re: How to disable root access?
 
it didn't work.

The output is below:
(reading database ... 25649 files and directories currently installed)
Removing rootsh ...
/var/lib/dpkg/info/rootsh.prerm: line 5: syntax error: "fi" unexpected (expecting "then")
dpkg: error processing rootsh (--remove):
subprocess pre-removal script returned error exit status 2 Errors were encountered while processing:
rootsh

/home/user # ..............

ok any suggestions now? :P

mikkov 2009-12-09 01:01

Re: How to disable root access?
 
OK, rootsh package is broken, unbelievable.

But because you already manually did prerm script command, you can just delete it.

rm /var/lib/dpkg/info/rootsh.prerm

and then remove rooths package

smage 2009-12-09 01:05

Re: How to disable root access?
 
rm /var/lib/dpkg/info/rootsh.prerm worked.

finally rootsh succesfully uninstalled, thanks everyone :)

smage 2009-12-09 01:15

Re: How to disable root access?
 
Ok it's uninstalled now but I'm stil able to gain root access

mikkov 2009-12-09 01:36

Re: How to disable root access?
 
What is the content of gainroot files?

cat /usr/sbin/gainroot.old
cat /usr/sbin/gainroot

smage 2009-12-09 07:30

Re: How to disable root access?
 
The two files are identical.

Their content is below:


#!bin/sh
#From Andrey Gubarev easyroot
trap exit SIGHUP SIGINT SIGTERM
PATH=/bin:/usr/bin:/sbin:/usr/sbin
if [ "$1" = "--use-su" ]
then
exec su -
else
echo "Root shell enabled"
/bin/sh
fi

Lazarpandar 2009-12-09 07:43

Re: How to disable root access?
 
Quote:

Originally Posted by Devil (Post 417708)
OT: is it me or is this programming language and stuff major boring *****?

Somebody bought the wrong phone.

funpig 2009-12-09 08:07

Re: How to disable root access?
 
mark it. and waiting for study more.

myk 2009-12-09 09:01

Re: How to disable root access?
 
Quote:

Originally Posted by Devil (Post 417708)
i mean i am not dumb but seriously. its just friggin letters and symbols and combinations of it. i study math, which is quite the same actually. just dont see why i am doing that. and reading the coding stuff. cant get there with my mind.

It sounds like there is a problem with your first premise. Unless there is a joke we missed??

mikkov 2009-12-09 10:03

Re: How to disable root access?
 
Quote:

Originally Posted by smage (Post 418239)
The two files are identical.

Their content is below:


#!bin/sh
#From Andrey Gubarev easyroot
trap exit SIGHUP SIGINT SIGTERM
PATH=/bin:/usr/bin:/sbin:/usr/sbin
if [ "$1" = "--use-su" ]
then
exec su -
else
echo "Root shell enabled"
/bin/sh
fi

You should get the original file somewhere and copy it there. and remove gainroot.old. Unfortunately I have the same situation so I don't know the original file.

You coulld just place empty file as gainroot too.

cpitchford 2009-12-09 10:35

Re: How to disable root access?
 
http://chris.intrepid.cx/N900/gainroot.old

Just scp'd from my phone :)

If you download it, remember to set it chmod 755

You can use it to replace /usr/sbin/gainroot (which appears to be the rootsh version! rootsh package needs some work :)

Before you copy it over, it might be worth pasting a copy of the file into a post here.. someone independent can verify I've not put something malicious in it :)

The md5 hash of the file can be verified using md5sum gainroot.old

8d30ec03fc1b8e6009b2e25c78fbc339

use md5sum gainroot.old to check your downloaded file matches this post

smage 2009-12-09 16:13

Re: How to disable root access?
 
haven't tried but this should work :P

#!/bin/sh -e
trap exit SIGHUP SIGINT SIGTERM
PATH=/bin:/usr/bin:/sbin:/usr/sbin

if [ -x /mnt/initfs/usr/bin/cal-tool ]; then
CALTOOL="/usr/sbin/chroot /mnt/initfs cal-tool"
else
CALTOOL="cal-tool"
fi

MODE=`$CALTOOL --get-rd-mode`
if [ x$MODE = xenabled ]
then
echo "Root shell enabled"
/bin/sh
else
echo "Enable RD mode if you want to break your device"
fi

smage 2009-12-14 16:10

Re: How to disable root access?
 
ok this worked last week perfectly and rootsh was uninstalled + root access disabled.

today i tried to reinstall rootsh, it installed but sudo gainroot is still asking for a password and just like last time the uninstaller through the app manager failed.

RshaoKh 2010-02-03 00:53

Re: How to disable root access?
 
Quote:

Originally Posted by smage (Post 417880)
Ok it's uninstalled now but I'm stil able to gain root access

Did you figure out how to disable it? I got it to uninstall the same way you did but I still have root access...


All times are GMT. The time now is 15:24.

vBulletin® Version 3.8.8