From ad68ae150f17cf6e0b2c605c9331cf0aedfce1d0 Mon Sep 17 00:00:00 2001 From: Christian Fuchs Date: Mon, 15 Apr 2013 12:36:37 +0000 Subject: extended the GNUNET_OS_check_helper_binary parameters to do previlege checking in windows. To do so, tested binaries must still be supplied with valid commandline arguments, but on windows gnunet will utilize the -d flag to run the programs initialization phase or privileged operations only. In these modes, a program will not enter its mainloop or communicate with the outside. updated relevant function calls gnunet-wide to meet the extended function parameters. --- src/nat/gnunet-helper-nat-server-windows.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/nat/gnunet-helper-nat-server-windows.c') diff --git a/src/nat/gnunet-helper-nat-server-windows.c b/src/nat/gnunet-helper-nat-server-windows.c index d970ffd70..fb564a188 100644 --- a/src/nat/gnunet-helper-nat-server-windows.c +++ b/src/nat/gnunet-helper-nat-server-windows.c @@ -187,6 +187,11 @@ struct udp_header uint16_t crc; }; +/** + * Will this binary be run in permissions testing mode? + */ +static boolean privilege_testing = FALSE; + /** * Socket we use to receive "fake" ICMP replies. */ @@ -526,9 +531,15 @@ main (int argc, char *const *argv) fd_set rs; struct timeval tv; WSADATA wsaData; - unsigned int alt; + unsigned int alt = 0; - alt = 0; + if (argc > 1 && 0 != strcmp (argv[1], "-d")){ + privilege_testing = TRUE; + fprintf (stderr, "DEBUG: Running binary in privilege testing mode.", argv[0]); + argv++; + argc--; + } + if (2 != argc) { fprintf (stderr, @@ -566,7 +577,8 @@ main (int argc, char *const *argv) closesocket (rawsock); return 3; } - while (1) + + while ( ! privilege_testing) { FD_ZERO (&rs); FD_SET (icmpsock, &rs); @@ -591,6 +603,8 @@ main (int argc, char *const *argv) closesocket (rawsock); closesocket (udpsock); WSACleanup (); + if (privilege_testing) + return 0; return 4; } -- cgit v1.2.3