]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/afp_asp.c
Warning fixes.
[netatalk.git] / etc / afpd / afp_asp.c
index 57c25a7a400515beeb3ddbc6e81c26fc79269652..89641691cfaf181778e2358f70834f0f8d925eb8 100644 (file)
@@ -1,4 +1,6 @@
 /* 
+ * $Id: afp_asp.c,v 1.6 2001-07-31 19:50:14 srittau Exp $
+ *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -6,6 +8,10 @@
  * modified from main.c. this handles afp over asp. 
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
 #ifndef NO_DDP
 
 #include <stdio.h>
 #include <string.h>
 #include <signal.h>
 #include <syslog.h>
+#ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
+#endif /* HAVE_SYS_TIME_H */
+#ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
+#endif /* HAVE_SYS_STAT_H */
 
 #include <netatalk/endian.h>
 #include <atalk/atp.h>
 
 extern struct oforks   *writtenfork;
 
-/* for CAP style authenticated printing */
-#ifdef CAPDIR
-extern int addr_net, addr_node, addr_uid;
-#endif /* CAPDIR */
-
 static AFPObj *child;
 
 static __inline__ void afp_asp_close(AFPObj *obj)
@@ -98,11 +103,6 @@ void afp_over_asp(AFPObj *obj)
     struct sigaction  action;
     int                func, ccnt = 0, reply = 0;
 
-#ifdef CAPDIR
-    char addr_filename[256];
-    struct stat cap_st;
-#endif /* CAPDIR */
-
     obj->exit = afp_asp_die;
     obj->reply = (int (*)()) asp_cmdreply;
     obj->attention = (int (*)(void *, AFPUserBytes)) asp_attention;
@@ -127,11 +127,6 @@ void afp_over_asp(AFPObj *obj)
        afp_asp_die(1);
     }
 
-#ifdef CAPDIR
-    addr_net = ntohs( asp->asp_sat.sat_addr.s_net );
-    addr_node  = asp->asp_sat.sat_addr.s_node;
-#endif /* CAPDIR */
-
     syslog( LOG_INFO, "session from %u.%u:%u on %u.%u:%u",
            ntohs( asp->asp_sat.sat_addr.s_net ),
            asp->asp_sat.sat_addr.s_node, asp->asp_sat.sat_port,
@@ -142,21 +137,28 @@ void afp_over_asp(AFPObj *obj)
     while ((reply = asp_getrequest(asp))) {
       switch (reply) {
       case ASPFUNC_CLOSE :
-       afp_asp_close(obj);
-       syslog( LOG_INFO, "done" );
+       if (obj->options.authprintdir) {
+         char addr_filename[256];
+         struct stat cap_st;
 
-#ifdef CAPDIR
-       sprintf(addr_filename, "%s/net%d.%dnode%d", CAPDIR, addr_net/256, addr_net%256, addr_node);
-       if(stat(addr_filename, &cap_st) == 0) {
+         sprintf(addr_filename, "%s/net%d.%dnode%d", obj->options.authprintdir, 
+               ntohs( asp->asp_sat.sat_addr.s_net )/256, 
+               ntohs( asp->asp_sat.sat_addr.s_net )%256, 
+               asp->asp_sat.sat_addr.s_node );
+
+         if(stat(addr_filename, &cap_st) == 0) {
                if(unlink(addr_filename) == 0) {
                        syslog(LOG_INFO, "removed %s", addr_filename);
                } else {
                        syslog(LOG_INFO, "error removing %s: %m", addr_filename);
                }
-       } else {
+         } else {
                syslog(LOG_INFO, "error stat'ing %s: %m", addr_filename);
+         }
        }
-#endif /* CAPDIR */
+
+       afp_asp_close(obj);
+       syslog( LOG_INFO, "done" );
 
        if ( obj->options.flags & OPTION_DEBUG ) {
          printf( "done\n" );
@@ -172,7 +174,7 @@ void afp_over_asp(AFPObj *obj)
          }
          writtenfork = NULL;
        }
-#endif AFS
+#endif /* AFS */
        func = (u_char) asp->commands[0];
        if ( obj->options.flags & OPTION_DEBUG ) {
          printf( "command: %d\n", func );
@@ -242,7 +244,7 @@ void afp_over_asp(AFPObj *obj)
       if ( obj->options.flags & OPTION_DEBUG ) {
 #ifdef notdef
        pdesc( stdout );
-#endif notdef
+#endif /* notdef */
        of_pforkdesc( stdout );
        fflush( stdout );
       }