su interview questions
Top su frequently asked interview questions
I'm writing an app that will use su
to execute some commands in the linux kernel. I was wondering how SuperUser figures out that the application is asking for root privileges ? Also, are there any known ways (through obfuscation) in which this check can be bypassed ?
In other words:
How does Android/(SuperUser) know that an app requires root privileges despite the fact that there are no permissions explicitly requested in the android manifest file.
I'm asking this question from a security standpoint. I want to know the details of how this works in order to be sure that a malicious app cannot bypass SuperUser.
Source: (StackOverflow)
Both commands:
sudo -i -u username
sudo su - username
Will log me in as username
if I enter my password. Is there actually any difference between these commands?
Source: (StackOverflow)
I'm trying to run the following command:
ssh -i FILENAME.pem ec2-user@ec2-00-000-00-00.eu-west-1.compute.amazonaws.com su --session-command="./update.sh"
I keep getting the error message:
standard in must be a tty
How can I SSH
on to the server then run the file called ./update.sh
?
Source: (StackOverflow)
I'm trying to root my ICS AVD, and have tried this:
adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock03 /system
adb push su /system/xbin/su
adb shell chmod 06755 /system
adb shell chmod 06755 /system/xbin/su
It fails with the following error:
failed to copy 'su' to '/system/xbin/su': Out of memory
How can I fix this?
Source: (StackOverflow)
I'm Developing an Android Application where it requireds 3 things:-
- To keep the App up an running for specific time and then phone will be off (Working Fine)
- When phone get charging from outlet, I want phone to power up automatically without hitting any power button. (Not Working with wall Socket, but working when connected to USB cable via Laptop).
- After boot my app should start working Automatically (Working Fine)
You Must know :-
My phone is Moto E (rooted) and want 2nd step to be done. Tried some codes but that does not work on moto E.
When Connected with USB it gives 2 as response and when connected with Wall socket charger it says 1
Any help will be Appreciated
P.S :- Auto Boot working with USB cable connected with Laptop but not with Socket Charger
Update-1: 1- Found fastboot oem off-mode-charge 0
working with Nexus 7 but not on Moto e.
2- Moto e boots when connected to Router (USB Dongle Port)
Source: (StackOverflow)
Possible Duplicate : what does the su mean: process = Runtime.getRuntime().exec("su");
I am tired trying all the different things yet i am still unsuccessful in understanding when will su work. What is rooting a device in Android? Someone please please help me with this.
I replied to the following question. The solution i posted there, i tested and also it worked.
Adding full permission for a image file in android.
Here is my question :
I tried Following.
Copied su.
Installed SuperUser.apk,
From program i called su and then using the newly created process i performed the required operations.
This has 2 results.
1) When the device is rooted(like executing Permanent root option in z4root), It works, it changes the system file permissions.
2) When device is not rooted, It doesnot work.
Kindly explain what extra thing does z4root performs which makes the task possible. Explain in brief please.
Let me know if my question is not clear. Thanks a ton..
Source: (StackOverflow)
I have an arch linux setup and installed neo4j through the arch user repository (yaourt -S neo4j
), and I'm able to run the web console fine (sudo neo4j console
with seemingly normal output and full functionality), however when trying to start the server (sudo neo4j start
), I encounter the following error message:
/usr/share/neo4j/bin/utils: line 345: [: -lt: unary operator expected
Using additional JVM arguments: -server -XX:+DisableExplicitGC -Dorg.neo4j.server.properties=/etc/neo4j/neo4j-server.properties -Djava.util.logging.config.file=/etc/neo4j/logging.properties -Dlog4j.configuration=file:/etc/neo4j/log4j.properties -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled
Starting Neo4j Server...cat: /run/neo4j/neo4j-service.pid: No such file or directory
process []... waiting for server to be ready. Failed to start within 120 seconds.
Neo4j Server may have failed to start, please check the logs.
rm: cannot remove ‘/run/neo4j/neo4j-service.pid’: No such file or directory
There's no delay before the error message is printed, so it seems to be something other than the timeout. I'm quite new to neo4j (I worked through a fair bit of the user manual using the web console, but no development or server config experience), so I'm not really sure what else might be relevant. I tried looking through the utils script and the error appears to be where it attempts to su neo4j
, but it also seems to proceed to attempt to start the server. I also tried changing the port it's starting on as in this question, but no change. The only log I can find just has this over and over (with appropriate timestamps):
Oct 15, 2014 1:33:49 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.9 09/02/2011 11:17 AM'
Any help at all would be appreciated!
EDIT:
The line 345 that it's failing on is the end of this snippet:
if [ $UID == 0 ] ; then
OPEN_FILES=`su $NEO4J_USER -c "ulimit -n"`
else
OPEN_FILES=`ulimit -n`
fi
if [ $OPEN_FILES -lt 40000 ]; then
From doing some echo debugging, it seems that su $NEO4J_USER
is failing, probably because $NEO4J_USER is set to neo4j, a user that does not exist on my system. I tried setting that to root in one of the config files, but evidently that's not working properly. Arch is a continual learning experience for me, but I've not had to add a new user before to get software working.
Source: (StackOverflow)
So I cant get su
command to work on a terminal. All I do is type "su" and press enter, it asks for the password and I enter my currently logged in user password. It always gives this error. I swear this used to work earlier, not sure what happened.
su: Sorry
I am running a Mac OSX 10.7.1 (Lion). Anyone know what could be wrong? I am entering the right password.
Source: (StackOverflow)
I'm trying to write a wrapper around su
to make it more like sudo
, so that su_wrapper foo bar baz
== su -c "foo bar baz"
.
However, I'm not sure how to approach this problem. I came up with this:
su_wrapper ()
{
su -c "$@"
}
However, in the above, only a single argument can be there; this fails with multiple arguments (as su
sees them as its own arguments).
There's also another problem: since the argument is passed through the shell, I think I must explicitly specify the shell to avoid other problems. Perhaps what I want to do could be expressed in pseudo-bash(!) as su -c 'bash -c "$@"'
.
So, how could I make it accept multiple arguments?
Source: (StackOverflow)
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?
Source: (StackOverflow)
I'm trying to figure out how to a send chain of multiple net-ssh commands after a sudo su - #{su_user}
in Ruby.
My current code is below, and hangs with the sudo su
command, even after the send_data "#{password}\n"
.
Meanwhile, on the system, a manual execution of sudo su - admin2
does not require a password entry.
Any help would be appreciated!
require 'rubygems'
require 'net/ssh'
host = 'hostA'
user = 'admin'
password = 'hostA_pwd'
su_user = 'Admin2'
Net::SSH.start(host, user, :password => password) do |ssh|
ssh.open_channel do |channel|
channel.request_pty do |c, success|
raise "could not request pty" unless success
channel.exec "pwd; whoami; sudo su - #{su_user} ; pwd ; whoami"
channel.on_data do |c_, data|
if data =~ /\[sudo\]/ || data =~ /Password/i
channel.send_data "#{password}\n"
else
result << data
end
end
puts result
end
end
ssh.loop
end
Source: (StackOverflow)
I am trying to install a system app from my java code, and so far, I haven't had any success.
Following is what I have done so far:
- My device is rooted.
- My "installer" app is installed as a system app. (copied it manually to /system/app)
- I have signed the installer apk with platform key, and I have
android:sharedUserId="android.uid.system"
in the Manifest.
I have been trying (and trying, and then some more) for Runtime.getRuntime.exec("su")
. I intend to mount the system partition as rw
, do a cat
for the apk, and then make system partition ro
. Following is the list of commands:
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system<br>
cat /sdcard/application.apk > /system/app/application.apk<br>
mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system<br><br>The application.apk here is the app being installed from the installer app. This app is also signed with platform key, and has the sharedUserId configured.
- I have requested for the
INSTALL_PACKAGES
permission in the manifest.
I have tried a number of variations of the exec("") format, including using 'su -c'
with every command. I have gotten the Broken Pipe exception and Security exception. Sometimes, I don't get an exception, but the file isn't copied.
Please let me know what I am missing here. Has anyone got this working?
Thanks!
Source: (StackOverflow)
I have an program which I run as root. I would like the program to execute another application as a normal user. I tried setgid()
and it works, but I can't then go back to root or another user. The program for the time being is very simple;
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
int main(int argc, char *argv[] )
{
if ( argc != 2) {
printf("usage: %s command\n",argv[0]);
exit(1);
}
setgid(100);
setuid(1000);
putenv("HOME=/home/caroline");
putenv("DISPLAY=:0");
system(argv[1]);
seteuid(1001);
putenv("HOME=/home/john");
putenv("DISPLAY=:1");
system(argv[1]);
return 0;
}
How can I do this? It's like the action of command su $user-c $command
Source: (StackOverflow)
I'm writing a bash script which calls a lot of other scripts.
Several scripts have to be executed as user_1 but several ones as user_2.
The scripts should be called in strict sequence. I start my script as user_1 and use su many times to become user_2. These times su requires a password so I have to retype it many times.
I'd like to avoid that, but su has no password parameter.
sudo and expect are not installed.
Source: (StackOverflow)
This is the simplest fork bomb
:() { :|: & }; :
I executed it on many linux distros and all of them crashed.
But when I executed this in an android terminal there was no effect even after granting Super user permissions.
Any Explanations why it did not crash the android system?
Source: (StackOverflow)