flyfire / droidsshd

Automatically exported from code.google.com/p/droidsshd
0 stars 0 forks source link

.pid file not readable when deamon runs as root (stopping the daemon thus fails) #32

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Try to stop Dropbear on Android 4.1.2 (where the process runs as root)
2.
3.

What is the expected output? What do you see instead?
It doesn't stop - it hangs.

What version of the product are you using? On what operating system?
Latest from SVN.

Please provide any additional information below.

It seems that on 4.1.2, when the daemon starts as root, the .pid file is 
actually created with rights 600 and uid/gid 0:0. When the application tries to 
read the .pid file so it can kill the server, it actually fails with error 
EACCESS (since the .pid file exists, but not readable by the UI application - 
its user has no rights).

-sh-4.2# ls -l /data/data/br.com.bott.droidsshd/files/run/dropbear.pid
-rw-------    1 0        0                6 Mar  4 21:52 
/data/data/br.com.bott.droidsshd/files/run/dropbear.pid

I've patched the code so that it also changes the owner to the UID of the 
application just before retrieving the .pid file.

                if (Base.runDaemonAsRoot()) {
                    int uid = android.os.Process.myUid();
                    Util.doRun("chown " + uid + " " + pidFile.getAbsolutePath(), Base.runDaemonAsRoot(), null);
                }

Original issue reported on code.google.com by viul...@gmail.com on 4 Mar 2013 at 10:30

GoogleCodeExporter commented 9 years ago
this might fix my issue #34, wish I had an apk or easy way to install the 
binary and test on 4.4...

Original comment by disc...@uw.edu on 3 Dec 2014 at 8:38