commit 2fbfb8b474c0be90c13f10ef5317340c06bc8717
parent 24fa6b6d5dc38c48b5546bf5a709a6b262c8d470
Author: hhvn <dev@hhvn.uk>
Date: Sat, 5 Jun 2021 23:39:53 +0100
main.c handler.c: enable/disable "CGI"
Diffstat:
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/handler.c b/handler.c
@@ -10,6 +10,7 @@
#include "main.h"
extern char *planfile;
+extern int usecgi;
void
get_userlist(int fd) {
@@ -73,6 +74,11 @@ get_plan(int fd, char *user) {
}
if (access(path, X_OK) == 0) {
+ if (!usecgi) {
+ dprintf(fd, "Error: executable files disabled in daemon\n");
+ verbose("Ignoring executable: %s\n", path);
+ return;
+ }
/* executable */
switch (pid = fork()) {
case -1:
diff --git a/main.c b/main.c
@@ -21,12 +21,13 @@
char *host = "localhost",
*port = "79",
*planfile = ".plan";
+int usecgi = 1; /* except this bool */
char *argv0;
void
usage(void) {
- printf("usage: %s [-h host] [-p port] [-f planfile]\n", basename(argv0));
+ printf("usage: %s [-Cc] [-h host] [-p port] [-f planfile]\n", basename(argv0));
exit(EXIT_USAGE);
}
@@ -135,6 +136,12 @@ main(int argc, char *argv[]) {
case 'f':
planfile = EARGF(usage());
break;
+ case 'c':
+ usecgi = 1;
+ break;
+ case 'C':
+ usecgi = 0;
+ break;
} ARGEND;
memset(&hints, 0, sizeof(hints));