]> arthur.barton.de Git - netatalk.git/blobdiff - etc/atalkd/main.c
remove or mark as ok more gcc warnings.
[netatalk.git] / etc / atalkd / main.c
index d4c4480c3c288bd87d7bf0df02bb520b9afbf418..f43fb5e55359f5e53dc3a8640323964c417fe69c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: main.c,v 1.17.8.3 2004-01-21 00:20:57 lenneis Exp $
+ * $Id: main.c,v 1.17.8.6.2.1 2005-01-31 17:01:04 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved. See COPYRIGHT.
@@ -695,7 +695,7 @@ consistency()
        for ( lr = zt->zt_rt; lr; lr = lr->l_next ) {
            rtmp = (struct rtmptab *)lr->l_data;
            if ( rtmp->rt_iprev == 0 && rtmp->rt_gate != 0 ) {
-               LOG(log_error, logtype_atalkd, "%.*s has %u-%u (unused)\n",
+               LOG(log_error, logtype_atalkd, "%.*s has %u-%u (unused)",
                        zt->zt_len, zt->zt_name, ntohs( rtmp->rt_firstnet ),
                        ntohs( rtmp->rt_lastnet ));
                atalkd_exit(1);
@@ -706,7 +706,7 @@ consistency()
                }
            }
            if ( lz == 0 ) {
-               LOG(log_error, logtype_atalkd, "no map from %u-%u to %.*s\n", 
+               LOG(log_error, logtype_atalkd, "no map from %u-%u to %.*s", 
                        ntohs( rtmp->rt_firstnet ),
                        ntohs( rtmp->rt_lastnet ),
                        zt->zt_len, zt->zt_name );
@@ -867,14 +867,15 @@ int main( ac, av )
     struct sockaddr_at sat;
     struct sigaction   sv;
     struct itimerval   it;
+    sigset_t            signal_set, old_set;
+    
     struct interface   *iface;
     int                        status;
     struct atport      *ap;
     fd_set             readfds;
-    int                        i, mask, c;
+    int                        i, c;
     SOCKLEN_T          fromlen;
     char               *prog;
-;
 
     while (( c = getopt( ac, av, "12qsdtf:P:v" )) != EOF ) {
        switch ( c ) {
@@ -1029,6 +1030,12 @@ int main( ac, av )
        exit( 1 );
     }
 
+    /*
+     * Set process name for logging
+     */
+
+    set_processname("atalkd");
+
     /* do this here so that we can use ifconfig */
 #ifdef __svr4__
     if ( plumb() < 0 ) {
@@ -1161,6 +1168,14 @@ int main( ac, av )
        atalkd_exit( 1 );
     }
 
+    sigemptyset( &signal_set );
+    sigaddset(&signal_set, SIGALRM);
+#if 0
+    /* don't block SIGTERM */
+    sigaddset(&signal_set, SIGTERM);
+#endif
+    sigaddset(&signal_set, SIGUSR1);
+
     for (;;) {
        readfds = fds;
        if ( select( nfds, &readfds, NULL, NULL, NULL) < 0 ) {
@@ -1191,16 +1206,12 @@ int main( ac, av )
                                    iface->i_flags, ap->ap_port, ap->ap_fd );
                            bprint( Packet, c );
                        }
-#endif /* DEBUG */
-#ifdef __svr4__
-                       if ( sighold( SIGALRM ) || sighold( SIGUSR1 )) {
-                           LOG(log_error, logtype_atalkd, "sighold: %s", strerror(errno) );
+#endif 
+                       if (sigprocmask(SIG_BLOCK, &signal_set, &old_set) < 0) {
+                           LOG(log_error, logtype_atalkd, "sigprocmask: %s", strerror(errno) );
                            atalkd_exit( 1 );
                        }
-#else /* __svr4__ */
-                       mask = sigsetmask( sigmask( SIGALRM ) |
-                               sigmask( SIGUSR1 ));
-#endif /* __svr4__ */
+
                        if (( *ap->ap_packet )( ap, &sat, Packet, c ) < 0) {
                          LOG(log_error, logtype_atalkd, "ap->ap_packet: %s", strerror(errno));
                          atalkd_exit(1);
@@ -1208,15 +1219,12 @@ int main( ac, av )
 
 #ifdef DEBUG
                        consistency();
-#endif /* DEBUG */
-#ifdef __svr4__
-                       if ( sigrelse( SIGUSR1 ) || sigrelse( SIGALRM )) {
-                           LOG(log_error, logtype_atalkd, "sigrelse: %s", strerror(errno) );
+#endif 
+                       if (sigprocmask(SIG_SETMASK, &old_set, NULL) < 0) {
+                           LOG(log_error, logtype_atalkd, "sigprocmask old set: %s", strerror(errno) );
                            atalkd_exit( 1 );
                        }
-#else /* __svr4__ */
-                       sigsetmask( mask );
-#endif /* __svr4__ */
+
                    }
                }
            }
@@ -1346,7 +1354,8 @@ smaller net range.", iface->i_name, ntohs(first), ntohs(last), strerror(errno));
 
     /* open ports */
     i = 1; /* enable broadcasts */
-#ifdef __svr4__ 
+#if 0
+    /* useless message, no? */
     LOG(log_info, logtype_atalkd, "setsockopt incompatible w/ Solaris STREAMS module.");
 #endif /* __svr4__ */
     for ( ap = iface->i_ports; ap; ap = ap->ap_next ) {
@@ -1415,7 +1424,7 @@ int set;
     }
 
     /* get interface config */
-    strncpy(ifr.ifr_name, iname, sizeof(ifr.ifr_name));
+    strlcpy(ifr.ifr_name, iname, sizeof(ifr.ifr_name));
     if (ioctl(sock, SIOCGIFFLAGS, &ifr) < 0) {
         close(sock);
         return (-1);
@@ -1428,7 +1437,7 @@ int set;
            ifr.ifr_flags &= ~IFF_ALLMULTI;
 
     /* set interface config */
-    strncpy(ifr.ifr_name, iname, sizeof(ifr.ifr_name));
+    strlcpy(ifr.ifr_name, iname, sizeof(ifr.ifr_name));
     if (ioctl(sock, SIOCSIFFLAGS, &ifr) < 0) {
         close(sock);   
         return -1;