android - SELinux policy for running "ps" command from APP -


i wish run ps command find number of running processes in system. selinux violation in m

private int read_procs() {     int nprocs = 0;     string line = null;      // "ps" output     try {         process p = runtime.getruntime().exec("ps");         bufferedreader in = new bufferedreader(new inputstreamreader(p.getinputstream()));         if (in == null)  {             mlog.e("cmd output _in_ null");             return 1;         }          while ((line = in.readline()) != null) {             nprocs++;         }         in.close();         mlog.i("processes :" + (nprocs-1));     } catch (exception e) {         e.printstacktrace();     }      return nprocs; } 

how set policy allow "ps" command access :

 avc: denied { getattr } path="/proc/2" dev="proc" ino=9461 scontext=u:r:system_app:s0 tcontext=u:r:kernel:s0 tclass=dir       permissive=0 ppid=3853 pcomm="thread-52" tgid=3761 tgcomm="test:app" 

thanks

i solved adding rule below

allow  [source context] [target context object]:[type] [permission needed];  allow system_app kernel:dir getattr; 

-


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -