]> arthur.barton.de Git - netatalk.git/commitdiff
Completely disable all AppleTalk stuff if not enabled
authorFrank Lahm <franklahm@googlemail.com>
Mon, 5 Sep 2011 14:53:30 +0000 (16:53 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Mon, 5 Sep 2011 14:53:30 +0000 (16:53 +0200)
20 files changed:
etc/afpd/afp_options.c
etc/afpd/auth.c
etc/afpd/status.c
etc/afpd/status.h
etc/afpd/uam.c
etc/afpd/volume.c
include/atalk/aep.h
include/atalk/asp.h
include/atalk/atp.h
include/atalk/ddp.h
include/atalk/globals.h
include/atalk/nbp.h
include/atalk/netddp.h
include/atalk/pap.h
include/atalk/rtmp.h
include/atalk/util.h
include/atalk/zip.h
libatalk/Makefile.am
libatalk/util/atalk_addr.c
sys/netatalk/at.h

index aa4014096bbe85a3dc68806e2e0ea9244bcede15..f2d73cd3cc8ee71a665fe988ee9e285f20ca67d5 100644 (file)
@@ -428,8 +428,10 @@ int afp_options_parseline(char *buf, struct afp_options *options)
 
     if ((c = getoption(buf, "-port")))
         options->port = strdup(c);
+#ifndef NO_DDP
     if ((c = getoption(buf, "-ddpaddr")))
         atalk_aton(c, &options->ddpaddr);
+#endif
     if ((c = getoption(buf, "-signature")) && (opt = strdup(c)))
         options->signatureopt = opt;
 
index 9d8fbf78aeb7b0fbb2c13b9336dcc8ef126687f9..5220493e09d00632285a63a9fba1c413148ee76f 100644 (file)
@@ -78,7 +78,11 @@ static struct uam_obj uam_changepw = {"", "", 0, {{NULL, NULL, NULL, NULL}}, &ua
 static struct uam_obj *afp_uam = NULL;
 
 
-void status_versions( char *data, const ASP asp, const DSI *dsi)
+void status_versions(char *data,
+#ifndef NO_DDP
+                     const ASP asp,
+#endif
+                     const DSI *dsi)
 {
     char                *start = data;
     u_int16_t           status;
index 62f8e246ab4046f3cfdb435e19c74ca710b98aa2..acb363a3e9d4ef8ecb9076e79ab93894b0ffce2e 100644 (file)
@@ -85,14 +85,16 @@ static int status_server(char *data, const char *server, const struct afp_option
 
     /* extract the obj part of the server */
     Obj = (char *) server;
+#ifndef NO_DDP
     nbp_name(server, &Obj, &Type, &Zone);
+#endif
     if ((size_t)-1 == (len = convert_string( 
-                       options->unixcharset, options->maccharset, 
-                       Obj, -1, buf, sizeof(buf))) ) {
-       len = MIN(strlen(Obj), 31);
+                           options->unixcharset, options->maccharset, 
+                           Obj, -1, buf, sizeof(buf))) ) {
+        len = MIN(strlen(Obj), 31);
        *data++ = len;
        memcpy( data, Obj, len );
-       LOG ( log_error, logtype_afpd, "Could not set servername, using fallback");
+        LOG ( log_error, logtype_afpd, "Could not set servername, using fallback");
     } else {
        *data++ = len;
        memcpy( data, buf, len );
@@ -185,8 +187,11 @@ static u_int16_t status_signature(char *data, int *servoffset,
 }
 
 static size_t status_netaddress(char *data, int *servoffset,
-                             const ASP asp, const DSI *dsi,
-                             const struct afp_options *options)
+#ifndef NO_DDP
+                                const ASP asp,
+#endif
+                                const DSI *dsi,
+                                const struct afp_options *options)
 {
     char               *begin;
     u_int16_t          offset;
@@ -209,7 +214,10 @@ static size_t status_netaddress(char *data, int *servoffset,
     /* number of addresses. this currently screws up if we have a dsi
        connection, but we don't have the ip address. to get around this,
        we turn off the status flag for tcp/ip. */
-    *data++ = ((options->fqdn && dsi)? 1 : 0) + (dsi ? 1 : 0) + (asp ? 1 : 0) +
+    *data++ = ((options->fqdn && dsi)? 1 : 0) + (dsi ? 1 : 0) +
+#ifndef NO_DDP
+        (asp ? 1 : 0) +
+#endif
               (((options->flags & OPTION_ANNOUNCESSH) && options->fqdn && dsi)? 1 : 0);
 
     /* ip address */
@@ -386,8 +394,9 @@ static size_t status_utf8servername(char *data, int *nameoffset,
 
     /* extract the obj part of the server */
     Obj = (char *) (options->server ? options->server : options->hostname);
+#ifndef NO_DDP
     nbp_name(options->server ? options->server : options->hostname, &Obj, &Type, &Zone);
-
+#endif
     if ((size_t) -1 == (len = convert_string (
                                        options->unixcharset, CH_UTF8_MAC, 
                                        Obj, -1, data+sizeof(namelen), maxstatuslen-offset )) ) {
@@ -440,7 +449,9 @@ static void status_icon(char *data, const unsigned char *icondata,
 void status_init(AFPConfig *aspconfig, AFPConfig *dsiconfig,
                  const struct afp_options *options)
 {
+#ifndef NO_DDP
     ASP asp;
+#endif
     DSI *dsi;
     char *status = NULL;
     size_t statuslen;
@@ -449,12 +460,14 @@ void status_init(AFPConfig *aspconfig, AFPConfig *dsiconfig,
     if (!(aspconfig || dsiconfig) || !options)
         return;
 
+#ifndef NO_DDP
     if (aspconfig) {
         status = aspconfig->status;
         maxstatuslen=sizeof(aspconfig->status);
         asp = aspconfig->obj.handle;
     } else
         asp = NULL;
+#endif
        
     ipok = 0;
     if (dsiconfig) {
@@ -506,7 +519,11 @@ void status_init(AFPConfig *aspconfig, AFPConfig *dsiconfig,
     c = status_server(status, options->server ? options->server :
                       options->hostname, options);
     status_machine(status);
-    status_versions(status, asp, dsi);
+    status_versions(status,
+#ifndef NO_DDP
+                    asp,
+#endif
+                    dsi);
     status_uams(status, options->uamlist);
     if (options->flags & OPTION_CUSTOMICON)
         status_icon(status, icon, sizeof(icon), c);
@@ -516,7 +533,11 @@ void status_init(AFPConfig *aspconfig, AFPConfig *dsiconfig,
     sigoff = status_signature(status, &c, options);
     /* c now contains the offset where the netaddress offset lives */
 
-    status_netaddress(status, &c, asp, dsi, options);
+    status_netaddress(status, &c,
+#ifndef NO_DDP
+                      asp,
+#endif
+                      dsi, options);
     /* c now contains the offset where the Directory Names Count offset lives */
 
     statuslen = status_directorynames(status, &c, dsi, options);
index c4ee50e44aa3569cf0be060ba62f19ac870626af..17753f95c77211a78a987f3621101272ee5cd3e2 100644 (file)
 #define PASSWD_NOSAVE  (1 << 1)
 #define PASSWD_ALL     (PASSWD_SET | PASSWD_NOSAVE)
 
-extern void status_versions (char * /*status*/, const ASP, const DSI *);
+extern void status_versions (char * /*status*/,
+#ifndef NO_DDP
+                             const ASP,
+#endif
+                             const DSI *);
 extern void status_uams (char * /*status*/, const char * /*authlist*/);
 extern void status_init (AFPConfig *, AFPConfig *,
                                  const struct afp_options *);
index 5001bfc51d2eb7420cbd8817554a2948eaab5a3b..7a1c034e317ab6119042f405650ab9678f2d36bf 100644 (file)
@@ -488,12 +488,13 @@ int uam_afp_read(void *handle, char *buf, size_t *buflen,
         return AFPERR_PARAM;
 
     switch (obj->proto) {
+#ifndef NO_DDP
     case AFPPROTO_ASP:
         if ((len = asp_wrtcont(obj->handle, buf, buflen )) < 0)
             goto uam_afp_read_err;
         return action(handle, buf, *buflen);
         break;
-
+#endif
     case AFPPROTO_DSI:
         len = dsi_writeinit(obj->handle, buf, *buflen);
         if (!len || ((len = action(handle, buf, len)) < 0)) {
@@ -508,6 +509,8 @@ int uam_afp_read(void *handle, char *buf, size_t *buflen,
             }
         }
         break;
+    default:
+        return -1;
     }
     return 0;
 
index fafdb8bd4ba67f30a653205df2a61c8cca2e1147..573639009dfe7425bed3c1cb8a6d1dd6d71afa6a 100644 (file)
@@ -265,6 +265,7 @@ static char *volxlate(AFPObj *obj,
         } else if (is_var(p, "$c")) {
             if (afpmaster && xlatevolname)
                 return NULL;
+#ifndef NO_DDP
             if (obj->proto == AFPPROTO_ASP) {
                 ASP asp = obj->handle;
 
@@ -273,7 +274,9 @@ static char *volxlate(AFPObj *obj,
                 dest += len;
                 destlen -= len;
 
-            } else if (obj->proto == AFPPROTO_DSI) {
+            }
+#endif
+            if (obj->proto == AFPPROTO_DSI) {
                 DSI *dsi = obj->handle;
                 len = sprintf(dest, "%s:%u",
                               getip_string((struct sockaddr *)&dsi->client),
@@ -302,14 +305,16 @@ static char *volxlate(AFPObj *obj,
         } else if (is_var(p, "$i")) {
             if (afpmaster && xlatevolname)
                 return NULL;
+#ifndef NO_DDP
             if (obj->proto == AFPPROTO_ASP) {
                 ASP asp = obj->handle;
-
                 len = sprintf(dest, "%u", ntohs(asp->asp_sat.sat_addr.s_net));
                 dest += len;
                 destlen -= len;
 
-            } else if (obj->proto == AFPPROTO_DSI) {
+            }
+#endif
+            if (obj->proto == AFPPROTO_DSI) {
                 DSI *dsi = obj->handle;
                 q = getip_string((struct sockaddr *)&dsi->client);
             }
index 69a419aff5401f04414981521fcaa0f9d8b6347a..11176ab47b55af8bf374bb4d8fc5ea71d88a0ed6 100644 (file)
 #ifndef _ATALK_AEP_H
 #define _ATALK_AEP_H 1
 
+#ifndef NO_DDP
+
 #define AEPOP_REQUEST  1
 #define AEPOP_REPLY    2
 
+#endif  /* NO_DDP */
 #endif
index 44b2388d991773622868cec7aafc118b20d32ee1..3c7252d4e2d6ccb49bbd0ca16318968d0ecfcd41 100644 (file)
@@ -24,6 +24,8 @@
 #ifndef _ATALK_ASP_H
 #define _ATALK_ASP_H 1
 
+#ifndef NO_DDP
+
 #include <sys/types.h>
 #include <sys/cdefs.h>
 #include <netatalk/endian.h>
@@ -101,4 +103,5 @@ extern void asp_kill        (int);
 extern int asp_tickle      (ASP, const u_int8_t, struct sockaddr_at *);
 extern void asp_stop_tickle (void);
 
+#endif  /* NO_DDP */
 #endif
index 48e5dfdd0edccb2b3b2e31317a8479d324763547..9618e75e0a71a145779b4734951bb5380e4bb984 100644 (file)
@@ -25,6 +25,8 @@
 
 #ifndef _ATALK_ATP_H
 #define _ATALK_ATP_H 1
+
+#ifndef NO_DDP
  
 #include <sys/cdefs.h>
 #include <sys/types.h>
@@ -190,4 +192,5 @@ extern int          atp_rsel  (ATP, struct sockaddr_at *, int);
 extern int             atp_rreq  (ATP, struct atp_block *);
 extern int             atp_sresp (ATP, struct atp_block *);
 
+#endif  /* NO_DDP */
 #endif
index 1c3fff1cc074da7578d0ccb2c8c22d8685bdd585..f4ecd55cae0d612fbe327248ce2eebdb087f8f08 100644 (file)
@@ -24,6 +24,8 @@
 #ifndef _ATALK_DDP_H
 #define _ATALK_DDP_H 1
 
+#ifndef NO_DDP
+
 #define DDPTYPE_RTMPRD 1
 #define DDPTYPE_NBP    2
 #define DDPTYPE_ATP    3
@@ -32,4 +34,5 @@
 #define DDPTYPE_ZIP    6
 #define DDPTYPE_ADSP   7
 
+#endif /* NO_DDP */
 #endif
index 299a5bf5d99748c69ac299a1aed3fa3c91c001f2..7aba7e70ecc112a74f2f0804afb0313f6d9d95dc 100644 (file)
@@ -72,7 +72,9 @@ struct afp_options {
     u_int32_t server_quantum;
     int dsireadbuf; /* scale factor for sizefof(dsi->buffer) = server_quantum * dsireadbuf */
     char hostname[MAXHOSTNAMELEN + 1], *server, *ipaddr, *port, *configfile;
+#ifndef NO_DDP
     struct at_addr ddpaddr;
+#endif
     char *uampath, *fqdn;
     char *pidfile;
     char *sigconffile;
index aa4190446a355b3938caa6eeb120e8e5743b3b99..45bae00d6e7802fc109d5ae479a049b7edca4353 100644 (file)
@@ -23,6 +23,9 @@
 
 #ifndef _ATALK_NBP_H
 #define _ATALK_NBP_H 1
+
+#ifndef NO_DDP
+
 #define NBP_UNRGSTR_4ARGS 1
 #define ATP_OPEN_2ARGS 1
 
@@ -93,4 +96,5 @@ extern int nbp_rgstr (struct sockaddr_at *,
 extern int nbp_unrgstr (const char *, const char *, const char *,
                            const struct at_addr *);
 
+#endif  /* NO_DDP */
 #endif
index bf1c9bd3a8007407c8a3739597ab3f9835432830..e6bccd433ea8cb2974ece789403b0ab0b410c283 100644 (file)
@@ -13,6 +13,8 @@
 #ifndef _ATALK_NETDDP_H
 #define _ATALK_NETDDP_H 1
 
+#ifndef NO_DDP
+
 #include <sys/types.h>
 #include <sys/cdefs.h>
 #include <sys/socket.h>
@@ -35,5 +37,6 @@ extern int netddp_recvfrom (int, void *, int, unsigned int,
 #define netddp_recvfrom  recvfrom
 #endif
 
+#endif  /* NO_DDP */
 #endif /* netddp.h */
 
index 4b0e7a8e75b4910175681cf7f319a21051d0d9b9..3d40082bdff351ec2040fd80b4d8a9398e4f4227 100644 (file)
@@ -24,6 +24,8 @@
 #ifndef _ATALK_PAP_H
 #define _ATALK_PAP_H 1
 
+#ifndef NO_DDP
+
 #define PAP_OPEN       1
 #define PAP_OPENREPLY  2
 #define PAP_READ       3
@@ -37,4 +39,5 @@
 #define PAP_MAXDATA    512
 #define PAP_MAXQUANTUM 8
 
+#endif  /* NO_DDP */
 #endif
index e5921c26acf4e1cf0d1225666d75189764f00474..474bd5a181180fee6784aa85f7e0964862cceb8a 100644 (file)
@@ -24,6 +24,8 @@
 #ifndef _ATALK_RTMP_H
 #define _ATALK_RTMP_H 1
 
+#ifndef NO_DDP
+
 #include <netatalk/endian.h>
 
 #define RTMPROP_REQUEST        1
@@ -42,4 +44,5 @@ struct rtmprdhdr {
     u_int8_t    rrdh_id;
 };
 
+#endif  /* NO_DDP */
 #endif
index bcf7e70816b461d0869b0646ad16011eb82719c7..21b47b3408fce4f0d2d933e119820112c2d94e45 100644 (file)
@@ -68,7 +68,9 @@ extern void freeifacelist(char **);
 
 #define diatolower(x)     _dialowermap[(unsigned char) (x)]
 #define diatoupper(x)     _diacasemap[(unsigned char) (x)]
+#ifndef NO_DDP
 extern int atalk_aton     (char *, struct at_addr *);
+#endif
 extern void bprint        (char *, int);
 extern int strdiacasecmp  (const char *, const char *);
 extern int strndiacasecmp (const char *, const char *, size_t);
index 9079fc1ded403cf6fe9267f109f6cb56db247b77..42a7d648d032636c583cb2e1c055bbe2548cae62 100644 (file)
@@ -25,6 +25,8 @@
 #ifndef _ATALK_ZIP_H
 #define _ATALK_ZIP_H 1
 
+#ifndef NO_DDP
+
 #include <netatalk/endian.h>
 
 struct ziphdr {
@@ -55,4 +57,5 @@ struct zipreplent {
 #define ZIPGNI_INVALID 0x80
 #define ZIPGNI_ONEZONE 0x20
 
+#endif  /* NO_DDP */
 #endif
index 4c7500d6dd033db505b49ddc9114e2c403a55473..2e7155aa084670c439bd8ad37ee50281ed145a12 100644 (file)
@@ -1,7 +1,7 @@
 
 # Makefile.am for libatalk/
 
-SUBDIRS = acl adouble asp atp bstring compat cnid dsi nbp netddp tdb util unicode vfs
+SUBDIRS = acl adouble bstring compat cnid dsi tdb util unicode vfs
 
 lib_LTLIBRARIES = libatalk.la
 
@@ -10,13 +10,9 @@ libatalk_la_SOURCES = dummy.c
 libatalk_la_LIBADD  = \
        acl/libacl.la \
        adouble/libadouble.la   \
-       asp/libasp.la           \
-       atp/libatp.la           \
        bstring/libbstring.la \
        compat/libcompat.la     \
        dsi/libdsi.la           \
-       nbp/libnbp.la           \
-       netddp/libnetddp.la     \
        util/libutil.la         \
        tdb/libtdb.la       \
        unicode/libunicode.la \
@@ -39,3 +35,16 @@ libatalk_la_DEPENDENCIES = \
 
 libatalk_la_LDFLAGS = -static
 
+if USE_APPLETALK
+SUBDIRS +=  asp atp nbp netddp
+libatalk_la_LIBADD += \
+       asp/libasp.la           \
+       atp/libatp.la           \
+       nbp/libnbp.la           \
+       netddp/libnetddp.la
+libatalk_la_DEPENDENCIES += \
+       asp/libasp.la           \
+       atp/libatp.la           \
+       nbp/libnbp.la           \
+       netddp/libnetddp.la
+endif
index 751c68e007b5c9f6ffc66671f5ea99e0949e0490..e151441a4bcda0d2175c9c0d5bc225a81daa4d87 100644 (file)
@@ -2,6 +2,8 @@
 #include "config.h"
 #endif
 
+#ifndef NO_DDP
+
 #include <sys/types.h>
 #include <netatalk/at.h>
 #include <netatalk/endian.h>
@@ -112,3 +114,5 @@ int atalk_aton(char *cp, struct at_addr *addr)
     }
     return (1);
 }
+
+#endif  /* NO_DDP */
index 9c9dceb70c0a1f003a5d9104563255f43fb66647..f544c40f833fc8e63fa86052b56124628e607197 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: at.h,v 1.6 2008-12-18 17:31:31 morgana Exp $
- *
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
  *
  * All Rights Reserved.  See COPYRIGHT.
@@ -9,6 +7,12 @@
 #ifndef __AT_HEADER__
 #define __AT_HEADER__
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#ifndef NO_DDP
+
 #if defined(linux) /* pull in the linux header */
 #include <sys/socket.h>
 #include <asm/types.h>
@@ -130,5 +134,6 @@ extern struct protosw       atalksw[];
 #endif /* KERNEL */
 
 #endif /* linux */
+#endif /* NO_DDP */
 #endif /* __AT_HEADER__ */