Skip to content

Commit 40d273a

Browse files
committed
Use psinfo as fallback [gu]id source on Solaris 10
fixes giampaolo#1193
1 parent 75ad6a1 commit 40d273a

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

psutil/_pssunos.py

+21-4
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@
7979
nice=4,
8080
num_threads=5,
8181
status=6,
82-
ttynr=7)
82+
ttynr=7,
83+
uid=8,
84+
euid=9,
85+
gid=10,
86+
egid=11)
8387

8488

8589
# =====================================================================
@@ -394,7 +398,10 @@ def _proc_basic_info(self):
394398

395399
@memoize_when_activated
396400
def _proc_cred(self):
397-
return cext.proc_cred(self.pid, self._procfs_path)
401+
@wrap_exceptions
402+
def proc_cred(self):
403+
return cext.proc_cred(self.pid, self._procfs_path)
404+
return proc_cred(self)
398405

399406
@wrap_exceptions
400407
def name(self):
@@ -454,12 +461,22 @@ def ppid(self):
454461

455462
@wrap_exceptions
456463
def uids(self):
457-
real, effective, saved, _, _, _ = self._proc_cred()
464+
try:
465+
real, effective, saved, _, _, _ = self._proc_cred()
466+
except AccessDenied:
467+
real = self._proc_basic_info()[proc_info_map['uid']]
468+
effective = self._proc_basic_info()[proc_info_map['euid']]
469+
saved = None
458470
return _common.puids(real, effective, saved)
459471

460472
@wrap_exceptions
461473
def gids(self):
462-
_, _, _, real, effective, saved = self._proc_cred()
474+
try:
475+
_, _, _, real, effective, saved = self._proc_cred()
476+
except AccessDenied:
477+
real = self._proc_basic_info()[proc_info_map['gid']]
478+
effective = self._proc_basic_info()[proc_info_map['egid']]
479+
saved = None
463480
return _common.puids(real, effective, saved)
464481

465482
@wrap_exceptions

psutil/_psutil_sunos.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,19 @@ psutil_proc_basic_info(PyObject *self, PyObject *args) {
102102
if (! psutil_file_to_struct(path, (void *)&info, sizeof(info)))
103103
return NULL;
104104
return Py_BuildValue(
105-
"ikkdiiik",
105+
"ikkdiiikiiii",
106106
info.pr_ppid, // parent pid
107107
info.pr_rssize, // rss
108108
info.pr_size, // vms
109109
PSUTIL_TV2DOUBLE(info.pr_start), // create time
110-
// XXX - niceness is wrong (20 instead of 0), see:
111-
// https://github.com/giampaolo/psutil/issues/1082
112110
info.pr_lwp.pr_nice, // nice
113111
info.pr_nlwp, // no. of threads
114112
info.pr_lwp.pr_state, // status code
115-
info.pr_ttydev // tty nr
113+
info.pr_ttydev, // tty nr
114+
(int)info.pr_uid, // real user id
115+
(int)info.pr_euid, // effective user id
116+
(int)info.pr_gid, // real group id
117+
(int)info.pr_egid // effective group id
116118
);
117119
}
118120

0 commit comments

Comments
 (0)