Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android regular user login loses group information when su to another user in an ssh session

Tags:

android

ssh

su

What I'm doing:

  • I've built GNU emacs for native use on an phone.
  • I run emacs in daemon mode on the phone, so I connect to it anytime with emacsclient, to continue working with regular files, run processes, etc.
  • When logging in from the terminal on the phone, I'm currently user 10157, everything works:

    $ id

    uid=10157(10157) gid=10157(10157) groups=10157(10157),1015(1015),1023(1023),1028(1028),3003(3003)

  • When I connect via ssh to the phone from a PC (I use DigiSSHd on the phone), it logs me in as a regular user 10282, everything works:

    $ id

    uid=10282 gid=10282 groups=1015(1015),1023(1023),1028(1028),3003(3003)

Emacs runs fine etc. However, this way I can't connect via emacsclient to the emacs process running under user 10157. This is desirable, since I don't want to start two emacs processes, since I want to continue working with files that I have open in emacs under user 10157.

Therefore: $ su - 10157

Fine, I can run emacs etc. However, I cannot access the web.

$ ping -c1 google.com
You must have internet permissions to use ping.  Aborting.
$ id

uid=10157(10157) gid=10157(10157) groups=10157(10157)

Thus I'm no longer in group 3003, necessary for internet access, besides other groups also.

Why does this group info get stripped, and how can I remedy this, so I can continue accessing the web when su as this user under ssh?

like image 646
白い熊 Avatar asked Jan 17 '13 07:01

白い熊


2 Answers

When i run the command:

busybox --list

I don't see su in the list.

su --help

shows Superuser.apk in the help text. It means su is provided by Superuser app.

I followed the steps described by you and i could su as another user and still have internet permission as shown below.

terminal

enter image description here

I have the following apps installed.

  • BusyBox v1.18.5-Stericson
  • Superuser v3.0.7
  • Terminal Emulator v1.0.45
  • SSHDroid v1.9.6

Suggestion: I think the issue is with su on your device. You may try this one. https://play.google.com/store/apps/details?id=com.noshufou.android.su

If i just use adb shell without running SSHDroid still i can su as another user with internet permission.

enter image description here

Note: The BusyBox id command doesn't show groups information always.

enter image description here

like image 113
appsroxcom Avatar answered Sep 17 '22 14:09

appsroxcom


According to the standard man page for su (from a linux box)

When - is used, it must be specified as the last su option. The other forms (-l and --login) do not have this restriction.

Based on that, try

$ su 10157 -
like image 42
drone.ah Avatar answered Sep 16 '22 14:09

drone.ah