maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   an already "gainrooted" xterm (https://talk.maemo.org/showthread.php?t=40698)

Matjaz 2010-01-15 13:11

an already "gainrooted" xterm
 
Just an idea.
I was bored to type "sudo gainroot" every time I opened the xterm. So I made a shortcut on the desktop, which links to a xterm, which is already "gainrooted", that means: the "sudo gainroot" command has already been typed.
I've found the idea here, a thread about desktop command-shortcuts.
My code is:
Code:

[Desktop Entry]
Encoding=UTF-8
Version=0.1
Type=Application
Terminal=true
Name=su-xterm
Exec=/usr/bin/osso-xterm 'sudo gainroot'
Icon=
X-Osso-Type=application/x-executable

just put it into a file called NAMEOFTHEFILE.desktop in /usr/share/applications/hildon/.

This add an application in the menu called su-xterm. You can make a shortcut to this application on the desktop. After running it, verify if you are root by typing:
Code:

whoami
If you want a nice shortcut's icon, check this post.

I suggest to delete the shortcut to the normal xterm (if you have one), so you can't choose the wrong one. Remember: if you open a new terminal by tapping the upper bar in an opened xterm and then "new" button, you will be USER, not root. Just type "sudo gainroot" again and have fun!

(Obviously you need the rootsh package. ;) )

Note: I'm not an expert and this is just a simple idea. Please comment!

chainreaction 2010-01-15 13:13

Re: an already "gainrooted" xterm
 
Umm.. the first comment would be that you should not use this if you happen to use x-terminal in other ways than root. Might not be that bad if you just use the terminal to crack things up, but otherwise this is not the safest idea if you just accidentally forget that you're always automatically root.

codeMonkey 2010-01-15 13:23

Re: an already "gainrooted" xterm
 
Agreed - the extra step to switch to root is imho a good idea - so you're aware of what you're doing.

Matjaz 2010-01-15 13:24

Re: an already "gainrooted" xterm
 
Quote:

Originally Posted by chainreaction (Post 473994)
Umm.. the first comment would be that you should not use this if you happen to use x-terminal in other ways than root. Might not be that bad if you just use the terminal to crack things up, but otherwise this is not the safest idea if you just accidentally forget that you're always automatically root.

That's true.
But I've not yet used the xterminal as user. I need beeing root for the most of the things I set by command-line. :o
For the other things I will use the normal xterminal.

codeMonkey 2010-01-15 13:37

Re: an already "gainrooted" xterm
 
As long as you're aware of the risks :) Happy learning!

dalonso 2010-01-15 13:39

Re: an already "gainrooted" xterm
 
Quote:

Originally Posted by Matjaz (Post 474013)
That's true.
But I've not yet used the xterminal as user. I need beeing root for the most of the things I set by command-line. :o
For the other things I will use the normal xterminal.

If you happen to almost use your xterm as a root, you could also add the gainroot command to your .profile rather than creating two different shortcuts.

Look here:

http://lists.maemo.org/pipermail//ma...ry/000450.html

Matjaz 2010-01-15 13:41

Re: an already "gainrooted" xterm
 
Quote:

Originally Posted by codeMonkey (Post 474042)
As long as you're aware of the risks :) Happy learning!

Thanks!
I know that if you are root and you don't know what are you doing your N900 can explode in your hands :D, but at the moment I'm still a N900b and don't know how to change some complex configuration files or the kernel or something like that....

Thanks again!

Bec 2010-01-17 19:35

Re: an already "gainrooted" xterm
 
How can I launch an app directly after registering as root?

Exec=/usr/bin/osso-xterm 'sudo gainroot' emelfm2
Exec=/usr/bin/osso-xterm 'sudo gainroot emelfm2'
Doesn't seem to work...

Matan 2010-01-17 20:10

Re: an already "gainrooted" xterm
 
Add the application to sudoers by creating a file called
/etc/sudoers.d/emelfm2.sudoers containing:
user ALL = NOPASSWD: /usr/bin/emelfm2
Then use Exec = /usr/bin/sudo /usr/bin/emelfm2
or Exec = osso-xterm "sudo emelfm2"

Bec 2010-01-17 21:01

Re: an already "gainrooted" xterm
 
I have no idea what I'm doing wrong:
/etc/sudoers.d/emelfm2.sudoers

with
user ALL = NOPASSWD: /usr/bin/emelfm2 also tried with (%) in front and with the line in "01sudo"

and the emelfm.desktop with:
Exec = /usr/bin/sudo /usr/bin/emelfm2 => the app processes for a little while than it just quits.
Exec = osso-xterm "sudo emelfm2" => it asks for a password...

i tried sudo gainroot, passwd, set a new password and then replaced the "NOPASSWD" ... didn't work.

What am I doing wrong?

Matan 2010-01-17 21:04

Re: an already "gainrooted" xterm
 
I forgot a step. Run update-sudoers (as root) after creating the .sudoers file.

Bec 2010-01-17 21:21

Re: an already "gainrooted" xterm
 
ok, now this looks interesting:

Quote:

>>>sudoers file: syntax error, line 2 <<<
>>>sudoers file: syntax error, line 3 <<<
>>>sudoers file: syntax error, line 4 <<<
/etc/sudoers.d/01sudo changes break sudoers
I have no idea what "01sudo" is and I have undone any changes I made to it:
Quote:

Defaults env_check+="HOME DISPLAY"
Defaults env_keep+="HOME DISPLAY"
Defaults env_reset
user ALL = NOPASSWD: /usr/sbin/gainroot
user ALL = NOPASSWD: /usr/sbin/mmc-mount /dev/mmcblk0 /media/mmc1
user ALL = NOPASSWD: /usr/sbin/mmc-mount /dev/mmcblk0p1 /media/mmc1
user ALL = NOPASSWD: /bin/umount /media/mmc1,/bin/umount -l /media/mmc1
user ALL = NOPASSWD: /usr/sbin/osso-usb-mass-storage-enable.sh, /usr/sbin/osso-usb-mass-storage-disable.sh
user ALL = NOPASSWD: /sbin/mkdosfs /dev/mmcblk0*, /usr/sbin/mmc-rename /dev/mmcblk0*
user ALL = NOPASSWD: /etc/init.d/af-base-apps stop , /etc/osso-af-init/gconf-daemon.sh stop
user ALL = NOPASSWD: /etc/init.d/af-base-apps start , /etc/osso-af-init/gconf-daemon.sh start
user ALL = NOPASSWD: /etc/init.d/osso-systemui restart
user ALL = NOPASSWD: /usr/sbin/gconf-clean.sh
user ALL = NOPASSWD: /usr/sbin/chroot /mnt/initfs /usr/bin/retutime *
user ALL = NOPASSWD: /sbin/insmod /mnt/initfs/lib/modules/current/g_file_storage.ko stall=0 file=/dev/mmcblk0
user ALL = NOPASSWD: /sbin/insmod /mnt/initfs/lib/modules/current/g_ether.ko
user ALL = NOPASSWD: /sbin/rmmod g_file_storage
user ALL = NOPASSWD: /sbin/rmmod g_ether
user ALL = NOPASSWD: /usr/sbin/osso-backup-restore-locale
user ALL = (install) NOPASSWD: /usr/bin/app-installer-tool
I removed that file to update and then put it back.
Thanks

fatalsaint 2010-01-17 21:26

Re: an already "gainrooted" xterm
 
Editing the sudoers file is very difficult to use anything but VI. (I don't know what you use)

The actual recommended way is using "visudo".. I don't know if the N900 has that or not.

Essentially even wrong end of line characters can cause sudo to stop working.

Just some thoughts... in vi if you use ":set list" you can see the end of line characters... ^M == bad.

Matan 2010-01-17 21:34

Re: an already "gainrooted" xterm
 
Just don't reboot, Bec, as you might need to reflash your system if you do. Copy a working 01sudo file (for example, from here: http://my.arava.co.il/~matan/770/n900/01sudo ) and run update-sudoers.

YoDude 2010-01-17 21:36

Re: an already "gainrooted" xterm
 
Quote:

Originally Posted by Matan (Post 478547)
Add the application to sudoers by creating a file called
/etc/sudoers.d/emelfm2.sudoers containing:
user ALL = NOPASSWD: /usr/bin/emelfm2
Then use Exec = /usr/bin/sudo /usr/bin/emelfm2
or Exec = osso-xterm "sudo emelfm2"

Now that^ can FUBAR your device if you don't know what you are doing. :eek:

Quote:

Originally Posted by qwerty12 (Post 453247)
...
For future reference: Use visudo instead of editing sudoers directly. visudo tells you if a line will **** up the entire sudo system when exiting the editor.

The simple addition of an extra space in a line while editing with a plain ol' text editor will screw things up...

Bec 2010-01-17 21:48

Re: an already "gainrooted" xterm
 
Quote:

Originally Posted by Matan (Post 478678)
Just don't reboot, Bec, as you might need to reflash your system if you do. Copy a working 01sudo file (for example, from here: http://my.arava.co.il/~matan/770/n900/01sudo ) and run update-sudoers.

Now for the best part...
sudo gainroot asks for a password...

For the first time I use it, no matter how many times I've tried to set one (always the same) it didn't seem to work...

Problem is that the usual password doesn't work...

Matan 2010-01-17 21:54

Re: an already "gainrooted" xterm
 
It asks for user's password, not root password. Did you install openssh server? If so, ssh directly to root.

Bec 2010-01-17 21:59

Re: an already "gainrooted" xterm
 
I've ssh-ited it... surprisingly it stopped asking for a password... awkward

Bec 2010-01-17 22:09

Re: an already "gainrooted" xterm
 
Quote:

Originally Posted by YoDude (Post 478682)
The simple addition of an extra space in a line while editing with a plain ol' text editor will screw things up...

As I do realize how close my ignorance brought me to a re-flash I'd apreaciate some details about visudo.

Thanks

Matan 2010-01-17 22:17

Re: an already "gainrooted" xterm
 
visudo is an editor that checks the file has the corrext syntax for a sudoers file before overwriting the original.

Bec 2010-01-17 22:25

Re: an already "gainrooted" xterm
 
Ok, but is it compatible/ported for maemo or is is x86 linux only?
And the stupid question... anything similar for us windows users?

fatalsaint 2010-01-17 23:19

Re: an already "gainrooted" xterm
 
As a rule of thumb.. *never* use a windows text editor to edit linux files. Windows uses different end of line characters by default than Linux. Causes many weird things.

I believe visudo is already on the device - or at least available in the repo's (can't check atm).

The sudoers file is very very sensitive.

geneven 2010-01-17 23:40

Re: an already "gainrooted" xterm
 
On my N900, visudo tells me no editor is set. I guess I have to make a symbolic link to /bin/vi however I do that.

fatalsaint 2010-01-17 23:49

Re: an already "gainrooted" xterm
 
Code:

export EDITOR=/bin/vi
I think should work..

Bec 2010-01-18 12:47

Re: an already "gainrooted" xterm
 
Ok, after this nice experiment I suddenly got awful battery issues. I need to investigate further...

EDIT1: something is "stuck" in the memory and pushes the cpu to 100%
EDIT2: tried to run visudo and although "nothing happened", I got myself a nice running app called "vi" that was using my cpu 90-100%. The battery lasted 8 hours this way.

ruskie 2010-01-18 12:56

Re: an already "gainrooted" xterm
 
Maybe add a red colourized xterm icon as well :)

eitama 2010-03-12 21:07

Re: an already "gainrooted" xterm
 
2 Attachment(s)
Trying to follow the steps in this thread for a rooted xterm resulted in nothing. So I found a different way to do it.

Gain root access to a terminal : ssh / terminal + sudo gainroot

1.1. vi /usr/share/rootedXterm.sh
1.2. This command will create a file named rootedXterm.sh and open an editor named vi to edit it. VI is not an easy editor to work with if you don't know what you are doing, so please pay attention to the steps.

2.1. Now we will insert a line into out newly created file :
2.2. Press "i" > Type > sudo gainroot > Press ESC > Type :wq!
2.3. Press Enter.

3.1. Now we give our new file run permissions.
3.2. Type "chmod 755 /usr/share/rootedXterm.sh" press Enter.

4.1. Now we create a "desktop shortcut" for our new script.
4.2. Type : "vi /usr/share/applications/hildon/rooted_xterm.desktop"
4.3. Press "i" to enter "insert" mode, and insert or paste the following code into your file :
Code:

[Desktop Entry]
Type=Application
Name=Rooted Xterm
Exec=/usr/bin/osso-xterm /usr/share/rootedXterm.sh
Icon=terminal

4.4. To exit edit mode press ESC.
4.5. type ":wq!" And press enter, to save and exit the file.

5.1. We are done editing files, close the ssh or terminal window.
5.2. In your phone, go into your application manager, wait for it to refresh, and close it.
5.3. The new Rooted Xterm should now appear in you applications.
5.4. Create a desktop shortcut for it if you want as you normally do for other apps. GL.

Beware, root is a dangerous mode, you can do whatever you want, including messing up your device.

Eitam.
Attachment 8063
Attachment 8064

lma 2010-03-13 07:31

Re: an already "gainrooted" xterm
 
Quote:

Originally Posted by fatalsaint (Post 478874)
Code:

export EDITOR=/bin/vi
I think should work..

That's the default (and broken, just filed bug 9516 about it), use /usr/bin/vi (or another editor of your choice) instead.

les_garten 2010-03-13 08:15

Re: an already "gainrooted" xterm
 
1 Attachment(s)
Quote:

Originally Posted by ruskie (Post 479782)
Maybe add a red colourized xterm icon as well :)

Like this one I made?

It is the correct size BTW.

DangerZone 2010-09-01 13:54

Re: an already "gainrooted" xterm
 
Quote:

Originally Posted by eitama (Post 565483)
Trying to follow the steps in this thread for a rooted xterm resulted in nothing. So I found a different way to do it.

Gain root access to a terminal : ssh / terminal + sudo gainroot

1.1. vi /usr/share/rootedXterm.sh
1.2. This command will create a file named rootedXterm.sh and open an editor named vi to edit it. VI is not an easy editor to work with if you don't know what you are doing, so please pay attention to the steps.

2.1. Now we will insert a line into out newly created file :
2.2. Press "i" > Type > sudo gainroot > Press ESC > Type :wq!
2.3. Press Enter.

3.1. Now we give our new file run permissions.
3.2. Type "chmod 755 /usr/share/rootedXterm.sh" press Enter.

4.1. Now we create a "desktop shortcut" for our new script.
4.2. Type : "vi /usr/share/applications/hildon/rooted_xterm.desktop"
4.3. Press "i" to enter "insert" mode, and insert or paste the following code into your file :
Code:

[Desktop Entry]
Type=Application
Name=Rooted Xterm
Exec=/usr/bin/osso-xterm /usr/share/rootedXterm.sh
Icon=terminal

4.4. To exit edit mode press ESC.
4.5. type ":wq!" And press enter, to save and exit the file.

5.1. We are done editing files, close the ssh or terminal window.
5.2. In your phone, go into your application manager, wait for it to refresh, and close it.
5.3. The new Rooted Xterm should now appear in you applications.
5.4. Create a desktop shortcut for it if you want as you normally do for other apps. GL.

Beware, root is a dangerous mode, you can do whatever you want, including messing up your device.

Eitam.
Attachment 8063
Attachment 8064

I was looking for something like this for a while now, thanks!


All times are GMT. The time now is 20:22.

vBulletin® Version 3.8.8