mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-02 12:20:51 +00:00
top(1): permit sub-second delay times
This removes the getuid check for delay==0. It didn't prevent users from writing similar programs in the general case. In theory, if top(1) is among one of the few restricted programs you're allowed to run, it may have helped a little, but there are better ways of handling that case.
This commit is contained in:
parent
be9d155ff4
commit
468910cd7a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=334906
@ -235,7 +235,7 @@ main(int argc, char *argv[])
|
||||
static char tempbuf2[50];
|
||||
int old_sigmask; /* only used for BSD-style signals */
|
||||
int topn = Infinity;
|
||||
int delay = Default_DELAY;
|
||||
double delay = 2;
|
||||
int displays = 0; /* indicates unspecified */
|
||||
int sel_ret = 0;
|
||||
time_t curr_time;
|
||||
@ -426,15 +426,16 @@ _Static_assert(sizeof(command_chars) == CMD_toggletid + 2, "command chars size")
|
||||
break;
|
||||
}
|
||||
|
||||
case 's':
|
||||
if ((delay = atoi(optarg)) < 0 || (delay == 0 && getuid() != 0))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: warning: seconds delay should be positive -- using default\n",
|
||||
myname);
|
||||
delay = Default_DELAY;
|
||||
warnings++;
|
||||
}
|
||||
case 's':
|
||||
delay = strtod(optarg, NULL);
|
||||
if (delay < 0) {
|
||||
fprintf(stderr,
|
||||
"%s: warning: seconds delay should be positive -- using default\n",
|
||||
myname);
|
||||
delay = 2;
|
||||
warnings++;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'q': /* be quick about it */
|
||||
@ -781,7 +782,7 @@ _Static_assert(sizeof(command_chars) == CMD_toggletid + 2, "command chars size")
|
||||
no_command = true;
|
||||
if (!interactive)
|
||||
{
|
||||
sleep(delay);
|
||||
usleep(delay * 1e6);
|
||||
if (leaveflag) {
|
||||
end_screen();
|
||||
exit(0);
|
||||
|
@ -1,10 +1,8 @@
|
||||
/*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
/*
|
||||
* Top - a top users display for Berkeley Unix
|
||||
/*-
|
||||
* Top - a top users display for Berkeley Unix
|
||||
*
|
||||
* General (global) definitions
|
||||
* General (global) definitions
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef TOP_H
|
||||
@ -12,8 +10,6 @@
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#define Default_DELAY 2
|
||||
|
||||
/* Number of lines of header information on the standard screen */
|
||||
extern int Header_lines; /* 7 */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user