mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-17 23:08:40 +02:00
Add --max-execution-time option
This commit is contained in:
17
src/init.c
17
src/init.c
@@ -30,6 +30,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
#ifdef HAVE_INITGROUPS
|
#ifdef HAVE_INITGROUPS
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
@@ -1013,14 +1014,30 @@ AddTrustedUser(char const *username)
|
|||||||
TrustedUsers[NumTrustedUsers] = pwent->pw_uid;
|
TrustedUsers[NumTrustedUsers] = pwent->pw_uid;
|
||||||
NumTrustedUsers++;
|
NumTrustedUsers++;
|
||||||
}
|
}
|
||||||
|
static void
|
||||||
|
sigalarm(int)
|
||||||
|
{
|
||||||
|
write(STDOUT_FILENO, "\nExecution time exceeded.\n", 26);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ProcessLongOption(char const *arg)
|
ProcessLongOption(char const *arg)
|
||||||
{
|
{
|
||||||
|
int t;
|
||||||
if (!strcmp(arg, "version")) {
|
if (!strcmp(arg, "version")) {
|
||||||
printf("%s\n", VERSION);
|
printf("%s\n", VERSION);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
if (sscanf(arg, "max-execution-time=%d", &t) == 1) {
|
||||||
|
if (t <= 0) {
|
||||||
|
fprintf(ErrFp, "%s: Value of --max-execution-time must be positive\n", ArgV[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
signal(SIGALRM, sigalarm);
|
||||||
|
alarm(t);
|
||||||
|
return;
|
||||||
|
}
|
||||||
fprintf(ErrFp, "%s: Unknown long option --%s\n", ArgV[0], arg);
|
fprintf(ErrFp, "%s: Unknown long option --%s\n", ArgV[0], arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user