Skip to content

Commit 74f8c2a

Browse files
committed
orte-clean: fix bad username/uid usage, add orte-dvm
This fixes a mismatch between PS listing that returned USERNAME but code was pruning based on UID. This changes the OPAL_PS_FLAVOR_CHECK format to return 'uid' instead of 'user'. (Note: Avoiding call to getlogin_r() but assuming UID is uniform on system, same assumption exists for session dir anyway.) Note, still maintains behavior from man page for root running orte-clean on node (kills all orteds). Adds 'orte-dvm' to list of procnames that will be checked/killed. Signed-off-by: Thomas Naughton <[email protected]>
1 parent 581bff9 commit 74f8c2a

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

config/opal_check_ps.m4

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dnl All rights reserved.
1313
dnl Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
1414
dnl Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
1515
dnl Copyright (c) 2014 Intel, Inc. All rights reserved.
16+
dnl Copyright (c) 2017 UT-Battelle, LLC. All rights reserved.
1617
dnl $COPYRIGHT$
1718
dnl
1819
dnl Additional copyrights may follow
@@ -30,11 +31,11 @@ PS_FLAVOR="unknown"
3031
ps -A -o fname > /dev/null 2>&1
3132

3233
if test "$?" = "0"; then
33-
PS_FLAVOR="ps -A -o fname,pid,user"
34+
PS_FLAVOR="ps -A -o fname,pid,uid"
3435
else
3536
ps -A -o command > /dev/null 2>&1
3637
if test "$?" = "0"; then
37-
PS_FLAVOR="ps -A -o command,pid,user"
38+
PS_FLAVOR="ps -A -o command,pid,uid"
3839
fi
3940
fi
4041
AC_MSG_RESULT([$PS_FLAVOR])

orte/tools/orte-clean/orte-clean.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* Copyright (c) 2015 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
1919
* Copyright (c) 2015 Intel, Inc. All rights reserved.
20+
* Copyright (c) 2017 UT-Battelle, LLC. All rights reserved.
2021
* $COPYRIGHT$
2122
*
2223
* Additional copyrights may follow
@@ -275,12 +276,10 @@ void kill_procs(void) {
275276
* This is the command that is used to get the information about
276277
* all the processes that are running. The output looks like the
277278
* following:
278-
* COMMAND PID USER
279-
* tcsh 12556 rolfv
280-
* ps 14424 rolfv
279+
* COMMAND PID UID
280+
* tcsh 12556 1000
281+
* ps 14424 1000
281282
* etc.
282-
* Currently, we do not make use of the USER field, but we may later
283-
* on so we grab it also.
284283
*/
285284

286285
/*
@@ -301,7 +300,7 @@ void kill_procs(void) {
301300
*/
302301
ortedpid = getppid();
303302

304-
/* get the name of the user */
303+
/* get the userid of the user */
305304
uid = getuid();
306305
asprintf(&this_user, "%d", uid);
307306

@@ -322,8 +321,7 @@ void kill_procs(void) {
322321
psfile = popen(command, "r");
323322
/*
324323
* Read the first line of the output. We just throw it away
325-
* as it is the header consisting of the words COMMAND, PID and
326-
* USER.
324+
* as it is the header consisting of the words COMMAND, PID and UID.
327325
*/
328326
if (NULL == (inputline = orte_getline(psfile))) {
329327
free(this_user);
@@ -347,7 +345,7 @@ void kill_procs(void) {
347345
/* If the user is not us, and the user is not root, then skip
348346
* further checking. If the user is root, then continue on as
349347
* we want root to kill off everybody. */
350-
if ((0 != strcmp(user, this_user)) && (0 != strcmp("root", this_user))) {
348+
if ((0 != strcmp(user, this_user)) && (0 != strcmp("0", this_user))) {
351349
/* not us */
352350
free(inputline);
353351
continue;
@@ -371,11 +369,13 @@ void kill_procs(void) {
371369
* proc is sometimes reported that way
372370
*/
373371
if (0 == strncmp("orted", procname, strlen("orted")) ||
374-
0 == strncmp("(orted)", procname, strlen("(orted)"))) {
372+
0 == strncmp("(orted)", procname, strlen("(orted)")) ||
373+
0 == strncmp("orte-dvm", procname, strlen("orte-dvm")) ||
374+
0 == strncmp("(orte-dvm)", procname, strlen("(orte-dvm)"))) {
375375
if (procpid != ortedpid) {
376376
if (orte_clean_globals.verbose) {
377377
fprintf(stderr, "orte-clean: found potential rogue orted process"
378-
" (pid=%d,user=%s), sending SIGKILL...\n",
378+
" (pid=%d,uid=%s), sending SIGKILL...\n",
379379
procpid, user);
380380
}
381381
/*
@@ -397,7 +397,7 @@ void kill_procs(void) {
397397
if (procpid != ortedpid) {
398398
if (orte_clean_globals.verbose) {
399399
fprintf(stderr, "orte-clean: found potential rogue orterun process"
400-
" (pid=%d,user=%s), sending SIGKILL...\n",
400+
" (pid=%d,uid=%s), sending SIGKILL...\n",
401401
procpid, user);
402402

403403
}

0 commit comments

Comments
 (0)