upnpstun.c: TEST: Require root user

New version of /sbin/iptables binary prints nonsense error message when is
called by ordinary non-root user:

  iptables v1.8.2 (nf_tables): unknown option "--dport"

Under root user it works correctly and understands --dport argument.

/sbin/iptables binary obviously does not work without root user, so rather
print error message as debugging why /sbin/iptables printed that nonsense
error message about unknown option.
This commit is contained in:
Pali Rohár 2020-05-08 16:32:16 +02:00
parent 0cad5296c6
commit 9e41cad6a8
1 changed files with 5 additions and 0 deletions

View File

@ -576,6 +576,11 @@ int main(int argc, char *argv[])
return 1;
}
if (geteuid() != 0) {
printf("You need to run this application as root\n");
return 1;
}
if (argc == 2)
argv[2] = "0";