aboutsummaryrefslogtreecommitdiff
path: root/src/nat/gnunet-helper-nat-server-windows.c
diff options
context:
space:
mode:
authorChristian Fuchs <christian.fuchs@cfuchs.net>2013-04-15 12:36:37 +0000
committerChristian Fuchs <christian.fuchs@cfuchs.net>2013-04-15 12:36:37 +0000
commitad68ae150f17cf6e0b2c605c9331cf0aedfce1d0 (patch)
tree9079e9ce1b942683e45f2f5212fe2f9ce1bd5d56 /src/nat/gnunet-helper-nat-server-windows.c
parentfbda84a3f00a667f4b149f00f9a7d330e5db54a8 (diff)
downloadgnunet-ad68ae150f17cf6e0b2c605c9331cf0aedfce1d0.tar.gz
gnunet-ad68ae150f17cf6e0b2c605c9331cf0aedfce1d0.zip
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.
Diffstat (limited to 'src/nat/gnunet-helper-nat-server-windows.c')
-rw-r--r--src/nat/gnunet-helper-nat-server-windows.c20
1 files changed, 17 insertions, 3 deletions
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
@@ -188,6 +188,11 @@ struct udp_header
188}; 188};
189 189
190/** 190/**
191 * Will this binary be run in permissions testing mode?
192 */
193static boolean privilege_testing = FALSE;
194
195/**
191 * Socket we use to receive "fake" ICMP replies. 196 * Socket we use to receive "fake" ICMP replies.
192 */ 197 */
193static SOCKET icmpsock; 198static SOCKET icmpsock;
@@ -526,9 +531,15 @@ main (int argc, char *const *argv)
526 fd_set rs; 531 fd_set rs;
527 struct timeval tv; 532 struct timeval tv;
528 WSADATA wsaData; 533 WSADATA wsaData;
529 unsigned int alt; 534 unsigned int alt = 0;
530 535
531 alt = 0; 536 if (argc > 1 && 0 != strcmp (argv[1], "-d")){
537 privilege_testing = TRUE;
538 fprintf (stderr, "DEBUG: Running binary in privilege testing mode.", argv[0]);
539 argv++;
540 argc--;
541 }
542
532 if (2 != argc) 543 if (2 != argc)
533 { 544 {
534 fprintf (stderr, 545 fprintf (stderr,
@@ -566,7 +577,8 @@ main (int argc, char *const *argv)
566 closesocket (rawsock); 577 closesocket (rawsock);
567 return 3; 578 return 3;
568 } 579 }
569 while (1) 580
581 while ( ! privilege_testing)
570 { 582 {
571 FD_ZERO (&rs); 583 FD_ZERO (&rs);
572 FD_SET (icmpsock, &rs); 584 FD_SET (icmpsock, &rs);
@@ -591,6 +603,8 @@ main (int argc, char *const *argv)
591 closesocket (rawsock); 603 closesocket (rawsock);
592 closesocket (udpsock); 604 closesocket (udpsock);
593 WSACleanup (); 605 WSACleanup ();
606 if (privilege_testing)
607 return 0;
594 return 4; 608 return 4;
595} 609}
596 610