Use different port if running without privileges

This commit is contained in:
Lucas 2021-01-21 02:06:23 +00:00
parent aa8afceb84
commit bfc0028755
1 changed files with 4 additions and 1 deletions

View File

@ -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)