aboutsummaryrefslogtreecommitdiff
path: root/src/nat
diff options
context:
space:
mode:
authorgrothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96>2011-12-16 11:16:26 +0000
committergrothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96>2011-12-16 11:16:26 +0000
commit138e4c55707e080944397c060896616622508a82 (patch)
tree20c051e5dd01b73d523c27d84df49df19b8dafa4 /src/nat
parentbabb8c91528b28767672d3a179ac2c48e7e29c52 (diff)
some very minor stylistic changes to gnunet-helper-nat-server based on suggestions from Jacob Applebaum
git-svn-id: https://gnunet.org/svn/gnunet@18624 140774ce-b5e7-0310-ab8b-a85725594a96
Diffstat (limited to 'src/nat')
-rw-r--r--src/nat/gnunet-helper-nat-server.c21
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 684fa97066..f71c37fa87 100644
--- a/src/nat/gnunet-helper-nat-server.c
+++ b/src/nat/gnunet-helper-nat-server.c
@@ -472,7 +472,7 @@ make_raw_socket ()
/**
- * Create a UDP socket for writinging.
+ * Create a UDP socket for writing.
*
* @param my_ip source address (our ip address)
* @return -1 on error
@@ -501,7 +501,8 @@ make_udp_socket (const struct in_addr *my_ip)
{
fprintf (stderr, "Error binding UDP socket to port %u: %s\n", NAT_TRAV_PORT,
strerror (errno));
- /* likely problematic, but not certain, try to continue */
+ close (ret);
+ return -1;
}
return ret;
}
@@ -539,19 +540,27 @@ main (int argc, char *const *argv)
if (-1 == (rawsock = make_raw_socket ()))
{
close (icmpsock);
- return 3;
+ return 4;
}
uid = getuid ();
+#ifdef HAVE_SETRESUID
if (0 != setresuid (uid, uid, uid))
{
fprintf (stderr, "Failed to setresuid: %s\n", strerror (errno));
- /* not critical, continue anyway */
+ return 5;
+ }
+#else
+ if (0 != (setuid (uid) | seteuid (uid)))
+ {
+ fprintf (stderr, "Failed to setuid: %s\n", strerror (errno));
+ return 6;
}
+#endif
if (-1 == (udpsock = make_udp_socket (&external)))
{
close (icmpsock);
close (rawsock);
- return 3;
+ return 7;
}
alt = 0;
while (1)
@@ -580,7 +589,7 @@ main (int argc, char *const *argv)
close (icmpsock);
close (rawsock);
close (udpsock);
- return 4;
+ return 8;
}