Skip to contentSkip to conversation

iputils: ninfod minor changes

PATCH New Jan Synacek 1 participant 3 messages Jan 23, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover iputils: ninfod minor changes

Functions limiting capabilities as well as opening a socket could have been called needlessly if ninfod was invoked with -h.

Also, ninfod incorrectly kept running if invoked with -v.

Jan Synacek (2):
ninfod: Call limit/drop_capabilities() and open_sock() after checking
for -h or -v.
ninfod: Make -v exit correctly.

 ninfod/ninfod.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
Signature · 1 line
1.8.1
#1 lore raw

PATCH 1/2 ninfod: Call limit/drop_capabilities() and open_sock() after checking for -h or -v.

---
 ninfod/ninfod.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
ninfod/ninfod.c +8 -8
index d1b99d9..58b15aa 100644
@@ -637,16 +637,8 @@ int main (int argc, char **argv)
 
 	appname = argv[0];
 
-	limit_capabilities();
-
-	sock = open_sock();
-	if (sock < 0)
-		sock_errno = errno;
-
 	parse_args(argc, argv);
 
-	drop_capabilities();
-
 	if (opt_h || opt_v)
 		print_copying();
 	if (opt_h) {
@@ -654,6 +646,14 @@ int main (int argc, char **argv)
 		exit(1);
 	}
 
+	limit_capabilities();
+
+	sock = open_sock();
+	if (sock < 0)
+		sock_errno = errno;
+
+	drop_capabilities();
+
 	if (sock_errno) {
 		DEBUG(LOG_ERR, "socket: %s\n", strerror(sock_errno));
 		exit(1);
Signature · 1 line
1.8.1
#2 lore raw

PATCH 2/2 ninfod: Make -v exit correctly.

In reply to Jan Synacek
---
 ninfod/ninfod.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
ninfod/ninfod.c +5 -2
index 58b15aa..52cf446 100644
@@ -639,12 +639,15 @@ int main (int argc, char **argv)
 
 	parse_args(argc, argv);
 
-	if (opt_h || opt_v)
-		print_copying();
 	if (opt_h) {
+		print_copying();
 		print_usage();
 		exit(1);
 	}
+	if (opt_v) {
+		print_copying();
+		return 0;
+	}
 
 	limit_capabilities();
 
Signature · 1 line
1.8.1