diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-12-16 11:16:26 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-12-16 11:16:26 +0000 |
commit | ac109f65ead8ae7aa01a99b100bebfac39d25ffa (patch) | |
tree | 20c051e5dd01b73d523c27d84df49df19b8dafa4 /src/nat | |
parent | 336fac04f09040802dcea71558afa3b9d1eff07a (diff) | |
download | gnunet-ac109f65ead8ae7aa01a99b100bebfac39d25ffa.tar.gz gnunet-ac109f65ead8ae7aa01a99b100bebfac39d25ffa.zip |
some very minor stylistic changes to gnunet-helper-nat-server based on suggestions from Jacob Applebaum
Diffstat (limited to 'src/nat')
-rw-r--r-- | src/nat/gnunet-helper-nat-server.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/nat/gnunet-helper-nat-server.c b/src/nat/gnunet-helper-nat-server.c index 684fa9706..f71c37fa8 100644 --- a/src/nat/gnunet-helper-nat-server.c +++ b/src/nat/gnunet-helper-nat-server.c | |||
@@ -472,7 +472,7 @@ make_raw_socket () | |||
472 | 472 | ||
473 | 473 | ||
474 | /** | 474 | /** |
475 | * Create a UDP socket for writinging. | 475 | * Create a UDP socket for writing. |
476 | * | 476 | * |
477 | * @param my_ip source address (our ip address) | 477 | * @param my_ip source address (our ip address) |
478 | * @return -1 on error | 478 | * @return -1 on error |
@@ -501,7 +501,8 @@ make_udp_socket (const struct in_addr *my_ip) | |||
501 | { | 501 | { |
502 | fprintf (stderr, "Error binding UDP socket to port %u: %s\n", NAT_TRAV_PORT, | 502 | fprintf (stderr, "Error binding UDP socket to port %u: %s\n", NAT_TRAV_PORT, |
503 | strerror (errno)); | 503 | strerror (errno)); |
504 | /* likely problematic, but not certain, try to continue */ | 504 | close (ret); |
505 | return -1; | ||
505 | } | 506 | } |
506 | return ret; | 507 | return ret; |
507 | } | 508 | } |
@@ -539,19 +540,27 @@ main (int argc, char *const *argv) | |||
539 | if (-1 == (rawsock = make_raw_socket ())) | 540 | if (-1 == (rawsock = make_raw_socket ())) |
540 | { | 541 | { |
541 | close (icmpsock); | 542 | close (icmpsock); |
542 | return 3; | 543 | return 4; |
543 | } | 544 | } |
544 | uid = getuid (); | 545 | uid = getuid (); |
546 | #ifdef HAVE_SETRESUID | ||
545 | if (0 != setresuid (uid, uid, uid)) | 547 | if (0 != setresuid (uid, uid, uid)) |
546 | { | 548 | { |
547 | fprintf (stderr, "Failed to setresuid: %s\n", strerror (errno)); | 549 | fprintf (stderr, "Failed to setresuid: %s\n", strerror (errno)); |
548 | /* not critical, continue anyway */ | 550 | return 5; |
551 | } | ||
552 | #else | ||
553 | if (0 != (setuid (uid) | seteuid (uid))) | ||
554 | { | ||
555 | fprintf (stderr, "Failed to setuid: %s\n", strerror (errno)); | ||
556 | return 6; | ||
549 | } | 557 | } |
558 | #endif | ||
550 | if (-1 == (udpsock = make_udp_socket (&external))) | 559 | if (-1 == (udpsock = make_udp_socket (&external))) |
551 | { | 560 | { |
552 | close (icmpsock); | 561 | close (icmpsock); |
553 | close (rawsock); | 562 | close (rawsock); |
554 | return 3; | 563 | return 7; |
555 | } | 564 | } |
556 | alt = 0; | 565 | alt = 0; |
557 | while (1) | 566 | while (1) |
@@ -580,7 +589,7 @@ main (int argc, char *const *argv) | |||
580 | close (icmpsock); | 589 | close (icmpsock); |
581 | close (rawsock); | 590 | close (rawsock); |
582 | close (udpsock); | 591 | close (udpsock); |
583 | return 4; | 592 | return 8; |
584 | } | 593 | } |
585 | 594 | ||
586 | 595 | ||