From bfc002875503e0891aa55b91c2f20e19cfbe80c4 Mon Sep 17 00:00:00 2001 From: Lucas Date: Thu, 21 Jan 2021 02:06:23 +0000 Subject: [PATCH] Use different port if running without privileges --- discardd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/discardd.c b/discardd.c index 3297c92..01b2e1b 100644 --- a/discardd.c +++ b/discardd.c @@ -1,6 +1,6 @@ /* * discard - * Written in 2020 by Lucas + * Written in 2020-2021 by Lucas * CC0 1.0 Universal/Public domain - No rights reserved * * To the extent possible under law, the author(s) have dedicated all @@ -26,6 +26,7 @@ usage(void) int main(int argc, char *argv[]) { + const char *port = NULL; int ch, do_tcp, do_udp; do_tcp = do_udp = 0; @@ -44,6 +45,8 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; + port = geteuid() == 0 ? "discard" : "9999"; + if (argc > 0) usage(); if (!do_tcp && !do_udp)