diff options
-rw-r--r-- | procps/ps.c | 6 | ||||
-rw-r--r-- | win32/process.c | 11 |
2 files changed, 11 insertions, 6 deletions
diff --git a/procps/ps.c b/procps/ps.c index 4e6dc1ef9..1f14844e6 100644 --- a/procps/ps.c +++ b/procps/ps.c | |||
@@ -210,7 +210,6 @@ struct globals { | |||
210 | 210 | ||
211 | /* Print value to buf, max size+1 chars (including trailing '\0') */ | 211 | /* Print value to buf, max size+1 chars (including trailing '\0') */ |
212 | 212 | ||
213 | #if !ENABLE_PLATFORM_MINGW32 | ||
214 | static void func_user(char *buf, int size, const procps_status_t *ps) | 213 | static void func_user(char *buf, int size, const procps_status_t *ps) |
215 | { | 214 | { |
216 | #if 1 | 215 | #if 1 |
@@ -234,7 +233,6 @@ static void func_group(char *buf, int size, const procps_status_t *ps) | |||
234 | { | 233 | { |
235 | safe_strncpy(buf, get_cached_groupname(ps->gid), size+1); | 234 | safe_strncpy(buf, get_cached_groupname(ps->gid), size+1); |
236 | } | 235 | } |
237 | #endif | ||
238 | 236 | ||
239 | static void func_comm(char *buf, int size, const procps_status_t *ps) | 237 | static void func_comm(char *buf, int size, const procps_status_t *ps) |
240 | { | 238 | { |
@@ -385,10 +383,8 @@ static void func_pcpu(char *buf, int size, const procps_status_t *ps) | |||
385 | 383 | ||
386 | static const ps_out_t out_spec[] = { | 384 | static const ps_out_t out_spec[] = { |
387 | /* Mandated by http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html: */ | 385 | /* Mandated by http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html: */ |
388 | #if !ENABLE_PLATFORM_MINGW32 | ||
389 | { 8 , "user" ,"USER" ,func_user ,PSSCAN_UIDGID }, | 386 | { 8 , "user" ,"USER" ,func_user ,PSSCAN_UIDGID }, |
390 | { 8 , "group" ,"GROUP" ,func_group ,PSSCAN_UIDGID }, | 387 | { 8 , "group" ,"GROUP" ,func_group ,PSSCAN_UIDGID }, |
391 | #endif | ||
392 | { 16 , "comm" ,"COMMAND",func_comm ,PSSCAN_COMM }, | 388 | { 16 , "comm" ,"COMMAND",func_comm ,PSSCAN_COMM }, |
393 | #if !ENABLE_PLATFORM_MINGW32 | 389 | #if !ENABLE_PLATFORM_MINGW32 |
394 | { MAX_WIDTH , "args" ,"COMMAND",func_args ,PSSCAN_COMM }, | 390 | { MAX_WIDTH , "args" ,"COMMAND",func_args ,PSSCAN_COMM }, |
@@ -557,7 +553,7 @@ static void format_process(const procps_status_t *ps) | |||
557 | # define SELINUX_O_PREFIX "label," | 553 | # define SELINUX_O_PREFIX "label," |
558 | # define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args") | 554 | # define DEFAULT_O_STR (SELINUX_O_PREFIX "pid,user" IF_FEATURE_PS_TIME(",time") ",args") |
559 | #elif ENABLE_PLATFORM_MINGW32 | 555 | #elif ENABLE_PLATFORM_MINGW32 |
560 | # define DEFAULT_O_STR ("pid,ppid" IF_FEATURE_PS_TIME(",time,etime") ",comm") | 556 | # define DEFAULT_O_STR ("pid,ppid,user" IF_FEATURE_PS_TIME(",time,etime") ",comm") |
561 | #else | 557 | #else |
562 | # define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args") | 558 | # define DEFAULT_O_STR ("pid,user" IF_FEATURE_PS_TIME(",time") ",args") |
563 | #endif | 559 | #endif |
diff --git a/win32/process.c b/win32/process.c index 37496db7b..b29780be8 100644 --- a/win32/process.c +++ b/win32/process.c | |||
@@ -457,6 +457,7 @@ UNUSED_PARAM | |||
457 | ) | 457 | ) |
458 | { | 458 | { |
459 | PROCESSENTRY32 pe; | 459 | PROCESSENTRY32 pe; |
460 | HANDLE proc; | ||
460 | const char *comm, *name; | 461 | const char *comm, *name; |
461 | BOOL ret; | 462 | BOOL ret; |
462 | 463 | ||
@@ -484,7 +485,6 @@ UNUSED_PARAM | |||
484 | 485 | ||
485 | #if ENABLE_FEATURE_PS_TIME || ENABLE_FEATURE_PS_LONG | 486 | #if ENABLE_FEATURE_PS_TIME || ENABLE_FEATURE_PS_LONG |
486 | if (flags & (PSSCAN_STIME|PSSCAN_UTIME|PSSCAN_START_TIME)) { | 487 | if (flags & (PSSCAN_STIME|PSSCAN_UTIME|PSSCAN_START_TIME)) { |
487 | HANDLE proc; | ||
488 | FILETIME crTime, exTime, keTime, usTime; | 488 | FILETIME crTime, exTime, keTime, usTime; |
489 | 489 | ||
490 | if ((proc=OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, | 490 | if ((proc=OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, |
@@ -507,6 +507,15 @@ UNUSED_PARAM | |||
507 | } | 507 | } |
508 | #endif | 508 | #endif |
509 | 509 | ||
510 | if (flags & PSSCAN_UIDGID) { | ||
511 | /* if we can open the process it belongs to us */ | ||
512 | if ((proc=OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe.th32ProcessID))) { | ||
513 | sp->uid = DEFAULT_UID; | ||
514 | sp->gid = DEFAULT_GID; | ||
515 | CloseHandle(proc); | ||
516 | } | ||
517 | } | ||
518 | |||
510 | sp->pid = pe.th32ProcessID; | 519 | sp->pid = pe.th32ProcessID; |
511 | sp->ppid = pe.th32ParentProcessID; | 520 | sp->ppid = pe.th32ParentProcessID; |
512 | 521 | ||