Skip to content

Commit

Permalink
Use psinfo as fallback [gu]id source on Solaris 10
Browse files Browse the repository at this point in the history
  • Loading branch information
gsauthof committed Mar 15, 2018
1 parent 75ad6a1 commit 0e15cdd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
25 changes: 21 additions & 4 deletions psutil/_pssunos.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@
nice=4,
num_threads=5,
status=6,
ttynr=7)
ttynr=7,
uid=8,
euid=9,
gid=10,
egid=11)


# =====================================================================
Expand Down Expand Up @@ -394,7 +398,10 @@ def _proc_basic_info(self):

@memoize_when_activated
def _proc_cred(self):
return cext.proc_cred(self.pid, self._procfs_path)
@wrap_exceptions
def proc_cred(self):
return cext.proc_cred(self.pid, self._procfs_path)
return proc_cred(self)

@wrap_exceptions
def name(self):
Expand Down Expand Up @@ -454,12 +461,22 @@ def ppid(self):

@wrap_exceptions
def uids(self):
real, effective, saved, _, _, _ = self._proc_cred()
try:
real, effective, saved, _, _, _ = self._proc_cred()
except AccessDenied:
real = self._proc_basic_info()[proc_info_map['uid']]
effective = self._proc_basic_info()[proc_info_map['euid']]
saved = None
return _common.puids(real, effective, saved)

@wrap_exceptions
def gids(self):
_, _, _, real, effective, saved = self._proc_cred()
try:
_, _, _, real, effective, saved = self._proc_cred()
except AccessDenied:
real = self._proc_basic_info()[proc_info_map['gid']]
effective = self._proc_basic_info()[proc_info_map['egid']]
saved = None
return _common.puids(real, effective, saved)

@wrap_exceptions
Expand Down
10 changes: 6 additions & 4 deletions psutil/_psutil_sunos.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,19 @@ psutil_proc_basic_info(PyObject *self, PyObject *args) {
if (! psutil_file_to_struct(path, (void *)&info, sizeof(info)))
return NULL;
return Py_BuildValue(
"ikkdiiik",
"ikkdiiikiiii",
info.pr_ppid, // parent pid
info.pr_rssize, // rss
info.pr_size, // vms
PSUTIL_TV2DOUBLE(info.pr_start), // create time
// XXX - niceness is wrong (20 instead of 0), see:
// https://github.com/giampaolo/psutil/issues/1082
info.pr_lwp.pr_nice, // nice
info.pr_nlwp, // no. of threads
info.pr_lwp.pr_state, // status code
info.pr_ttydev // tty nr
info.pr_ttydev, // tty nr
(int)info.pr_uid, // real user id
(int)info.pr_euid, // effective user id
(int)info.pr_gid, // real group id
(int)info.pr_egid // effective group id
);
}

Expand Down

0 comments on commit 0e15cdd

Please sign in to comment.