EzDevInfo.com

root interview questions

Top root frequently asked interview questions

Determine if running on a rooted device

My app has a certain piece of functionality that will only work on a device where root is available. Rather than having this feature fail when it is used (and then show an appropriate error message to the user), I'd prefer an ability to silently check if root is available first, and if not,hide the respective options in the first place.

Is there a way to do this?


Source: (StackOverflow)

Root user/sudo equivalent in Cygwin?

I'm trying to run a bash script in Cygwin.

I get Must run as root, i.e. sudo ./scriptname errors.

chmod 777 scriptname does nothing to help.

I've looked for ways to imitate sudo on Cygwin, to add a root user, since calling "su" renders the error su: user root does not exist, anything useful, and have found nothing.

Anyone have any suggestions?


Source: (StackOverflow)

Advertisements

Get APK of installed app

I am looking for a possibility to extract the apk files of an installed android app WITHOUT root permission. Until 5 min ago I thought that this is not possible, since all app apks are located in /data/app (non-system-apps) and accessing this folder is just possible with root permission.

Then I found the virus.total Android app in the google play store (https://play.google.com/store/apps/details?id=com.virustotal) and they seem to have access to the apks even on non rooted devices.

Can someone tell me how this is possible ? Aren't there backup apps which backup the apks without root ???

Thank you very much


Source: (StackOverflow)

Is there a way for non-root processes to bind to "privileged" ports (<1024) on Linux?

It's very annoying to have this limitation on my development box, when there won't ever be any users other than me.

I'm aware of the standard workarounds, but none of them do exactly what I want:

  1. authbind (The version in Debian testing, 1.0, only supports IPv4)
  2. Using the iptables REDIRECT target to redirect a low port to a high port (the "nat" table is not yet implemented for ip6tables, the IPv6 version of iptables)
  3. sudo (Running as root is what I'm trying to avoid)
  4. SELinux (or similar). (This is just my dev box, I don't want to introduce a lot of extra complexity.)

So is there some simple sysctl variable for this, or am I just out of luck?

EDIT: In some cases, you can use capabilities to do this.


Source: (StackOverflow)

HOWTO set the context path of a web application in Tomcat 7.0

I know that I can rename my webapp (or it's WAR file) to ROOT but this is a terrible way to do it, IMHO. Now I checked out the tomcat doc & it says

It is NOT recommended to place elements directly in the server.xml file

So I tried doing it another method that it suggested.

Individual Context elements may be explicitly defined: In an individual file at /META-INF/context.xml inside the application files.

So I created a /META-INF/context.xml with the following code,

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/"/>

But after deploying when I restarted the server it still failed to load the context at "/", it still loaded it with the "/<WEB_APP_NAME>"

Any pointers helpful.


Source: (StackOverflow)

Can not perform `pod install` under el capitan (15A279b)

I ran pod install with El Capitan and got this error:

Errno::EPERM - Operation not permitted - /Users/../Pods/Pods.xcodeproj/xcuserdata/root.xcuserdatad

Here's my environment: El Capitan (15A279b), Xcode Version 7.0 (7A220), cocoapod 0.38.2. Any ideas? Thanks!!!

The reason I use xcode7 (and not 6.4) is that I need to target an existing project to iOS9 for testing. And the reason I am using El Capitan is that xcode7 doesn't run under Yosemite. And I need to replace a library (managed by cocoapod) that no longer works under iOS9.

Here's how I install cocoapods in El Capitan sudo gem install -n /usr/local/bin cocoapods as suggested by this link Cannot install cocoa pods after uninstalling, results in error

pod --version

returns

0.38.2


Source: (StackOverflow)

Dropping root privileges

I have a daemon which gets started as root (so it can bind to low ports). After initialisation I'd very much like to have it drop root privileges for safety reasons.

Can anyone point me at a known correct piece of code in C which will do this?

I've read the man pages, I've looked at various implementations of this in different applications, and they're all different, and some of them are really complex. This is security-related code, and I really don't want to reinvent the same mistakes that other people are making. What I'm looking for is a best practice, known good, portable library function that I can use in the knowledge that it's going to get it right. Does such a thing exist?

For reference: I'm starting as root; I need to change to run under a different uid and gid; I need to have the supplementary groups set up correctly; I don't need to change back to root privileges afterwards.


Source: (StackOverflow)

vagrant login as root by default

Problem: frequently the first command I type to my boxes is su -.

Question: how do I make vagrant ssh use the root user by default?

Version: vagrant 1.6.5


Source: (StackOverflow)

A terminal command for a rooted Android to remount /System as read/write

I'm writing an android app that needs to copy a file to the "/system" partition at runtime. I've got the commands to run "su" and can successfully request SuperUser permissions and run commands as root. But I don't know how to make this app universal across multiple devices, because the mount command can differ depending on where the /system is actually mounted. Here's the command that's used most offen:

mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system

But I know that mtdblock3 could be different on some devices (and for that matter, i guess so could yaffs2). So, my question is: Is there a universal command that will work on all phones? Or is there a way to find out at runtime what the correct parameters are?


Source: (StackOverflow)

Dropping Root Permissions In Python

I'd like to have a Python program start listening on port 80, but after that execute without root permissions. Is there a way to drop root or to get port 80 without it?


Source: (StackOverflow)

root path doesnt work with php include

/ in the beginning of a link to get to the root folder doesnt work in php include.

for example "/example/example.php"

What is the solution?


Source: (StackOverflow)

adb remount permission denied, but able to access super user in shell -- android

so, i'm trying to push some files to /system on android device (zte) I've rooted, connected with ADB,

adb remount -> I get permission denied adb shell su -> I'm able to access shell and create folders etc and edit filesystem

(but in shell I can't copy a file from my computer to device)

Any help please


Source: (StackOverflow)

Execute root commands via PHP

I have a CentOS 5.7 linux server and use php5.3.x.

On a pfSense system, you can restart services-that required root permissions using a php web page.

I'm trying to do something similar, I have written some php code to execute shell commands. For example, to restart the sshd service:

<?php
exec('/sbin/service sshd restart');
?>

and I tried to execute that command via exec function, but it needs root permission, but we have a apache user authority.

I have come across a few solutions:

  1. "run apache with root user" really unsafe. I do not want to do that.
  2. "apache ALL=NOPASSWD:/sbin/service to /etc/sudoers" I tried but and still have a problem.

Any other solutions? Thanks for answers.


now.. it's interesting. i tried @refp post and it worked my local ubuntu server. But when i tried same at my cenOS vps server. It's not working.and that is apache's error log "rm: cannot remove `/var/lock/subsys/vsftpd': Permission denied"


Source: (StackOverflow)

How can get dtrace to run the traced command with non-root priviledges?

OS X lacks linux's strace, but it has dtrace which is supposed to be so much better.

However, I miss the ability to do simple tracing on individual commands. For example, on linux I can write strace -f gcc hello.c to caputre all system calls, which gives me the list of all the filenames needed by the compiler to compile my program (the excellent memoize script is built upon this trick)

I want to port memoize on the mac, so I need some kind of strace. What I actually need is the list of files gcc reads and writes into, so what I need is more of a truss. Sure enough can I say dtruss -f gcc hello.c and get somewhat the same functionality, but then the compiler is run with root priviledges, which is obviously undesirable (apart from the massive security risk, one issue is that the a.out file is now owned by root :-)

I then tried dtruss -f sudo -u myusername gcc hello.c, but this feels a bit wrong, and does not work anyway (I get no a.out file at all this time, not sure why)

All that long story tries to motivate my original question: how do I get dtrace to run my command with normal user privileges, just like strace does in linux ?

Edit: is seems that I'm not the only one wondering how to do this: question #1204256 is pretty much the same as mine (and has the same suboptimal sudo answer :-)


Source: (StackOverflow)

Drop database return "Error dropping database errno: 66" in MySQL

Consider:

DROP DATABASE db_name;
ERROR 1010 (HY000): Error dropping database (can't rmdir './db_name', errno: 66)

The problem is that I don't know where the file/directory is located - this file is missing in /usr/local/mysql/bin/...

How do I fix this issue?


Source: (StackOverflow)