diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index c32aacef1446..f9b1b9fb5e5c 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -1613,11 +1613,6 @@ compare_ivcsw(const void *arg1, const void *arg2) /* * proc_owner(pid) - returns the uid that owns process "pid", or -1 if * the process does not exist. - * It is EXTREMELY IMPORTANT that this function work correctly. - * If top runs setuid root (as in SVR4), then this function - * is the only thing that stands in the way of a serious - * security problem. It validates requests for the "kill" - * and "renice" commands. */ int diff --git a/usr.bin/top/top.c b/usr.bin/top/top.c index b4f9bec5d7ae..ebbd2a5f2861 100644 --- a/usr.bin/top/top.c +++ b/usr.bin/top/top.c @@ -260,6 +260,15 @@ main(int argc, char *argv[]) #define CMD_order 26 #define CMD_pid 27 + /* + * Since top(1) is often long running and + * doesn't typically care about where its running from + * chdir to the root to allow unmounting of its + * originall wd. Failure is alright as this is + * just a courtesy for users. + */ + chdir("/"); + /* set the buffer for stdout */ #ifdef DEBUG extern FILE *debug;