Fix a typo. Port numbers are in network order now, so don't change them.
authormdw <mdw>
Wed, 17 Sep 1997 10:23:23 +0000 (10:23 +0000)
committermdw <mdw>
Wed, 17 Sep 1997 10:23:23 +0000 (10:23 +0000)
src/daemon.c

index f79d76b..317a7fb 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: daemon.c,v 1.6 1997/09/09 18:17:06 mdw Exp $
+ * $Id: daemon.c,v 1.7 1997/09/17 10:23:23 mdw Exp $
  *
  * Running a `become' daemon
  *
@@ -29,6 +29,9 @@
 /*----- Revision history --------------------------------------------------*
  *
  * $Log: daemon.c,v $
+ * Revision 1.7  1997/09/17 10:23:23  mdw
+ * Fix a typo.  Port numbers are in network order now, so don't change them.
+ *
  * Revision 1.6  1997/09/09 18:17:06  mdw
  * Allow default port to be given as a service name or port number.
  *
@@ -322,7 +325,7 @@ void daemon_init(const char *cf, int port)
    * look it up in /etc/services under whatever name I was started as.
    */
 
-  if (daemon__port <= 0) {
+  if (daemon__port == 0) {
     struct servent *se = getservbyname(quis(), "udp");
     if (!se)
       die("no idea which port to use");
@@ -337,10 +340,12 @@ void daemon_init(const char *cf, int port)
     if ((s = socket(PF_INET, SOCK_DGRAM, 0)) == -1)
       die("couldn't create socket: %s", strerror(errno));
     sin.sin_family = AF_INET;
-    sin.sin_port = htons(daemon__port);
+    sin.sin_port = daemon__port;
     sin.sin_addr.s_addr = htonl(INADDR_ANY);
-    if (bind(s, (struct sockaddr *)&sin, sizeof(sin)))
-      die("couldn't bind socket to port: %s", strerror(errno));
+    if (bind(s, (struct sockaddr *)&sin, sizeof(sin))) {
+      die("couldn't bind socket to port %i: %s",
+         ntohs(daemon__port), strerror(errno));
+    }
   }
 
   /* --- Fork off into the sunset --- */