]> arthur.barton.de Git - netatalk.git/commitdiff
First patch import
authorFrank Lahm <franklahm@googlemail.com>
Sun, 20 Jun 2010 09:06:38 +0000 (11:06 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Sun, 20 Jun 2010 09:06:38 +0000 (11:06 +0200)
config/afpd.conf.tmpl
configure.in
etc/afpd/Makefile.am
etc/afpd/afp_config.c
etc/afpd/afp_options.c
etc/afpd/globals.h
include/atalk/dsi.h
macros/summary.m4

index 4c9ea98dbfa9243565069cdb968bfa0204c8d58f..377592120173b11d26a6d580bf016042fa5f9c19 100644 (file)
@@ -69,6 +69,8 @@
 #                         string.
 #     -slp                Register this server with the Service Location
 #                         Protocol (if SLP support was compiled in).
+#     -nozeroconf         Don't register this server with the Multicats
+#                         DNS Protocol.
 #     -advertise_ssh      Allows Mac OS X clients (10.3.3-10.4) to
 #                         automagically establish a tunneled AFP connection
 #                         through SSH. This option is not so significant
index 69a81edb986255726383571b599f995d686ead8d..4222a2221eb9d19701d3922d93a4aea36f6173e3 100644 (file)
@@ -390,6 +390,9 @@ AC_CHECK_QUOTA
 dnl Check for optional server location protocol support (used by MacOS X)
 NETATALK_SRVLOC
 
+dnl Check for optional Zeroconf support
+NETATALK_ZEROCONF
+
 dnl Check for PAM libs
 netatalk_cv_use_pam=no
 AC_PATH_PAM([
index 431437ef06a365182d6e63729fcfec6f5ec35863..f539d899d7a5506ca0f136ccc539e7e75be89efc 100644 (file)
@@ -9,14 +9,15 @@ afpd_SOURCES = unix.c ofork.c main.c switch.c auth.c volume.c directory.c \
         file.c enumerate.c desktop.c filedir.c fork.c appl.c gettok.c \
         mangle.c status.c afp_options.c afp_asp.c afp_dsi.c messages.c  \
         afp_config.c nfsquota.c quota.c uam.c afs.c uid.c afp_util.c \
-       catsearch.c afprun.c hash.c extattrs.c dircache.c
+       catsearch.c afprun.c hash.c extattrs.c dircache.c \
+       afp_zeroconf.c afp_avahi.c
 
 afpd_LDADD =  $(top_builddir)/libatalk/cnid/libcnid.la \
        $(top_builddir)/libatalk/libatalk.la \
-       @QUOTA_LIBS@ @SLP_LIBS@ @WRAP_LIBS@ @LIBADD_DL@ @ACL_LIBS@
+       @QUOTA_LIBS@ @SLP_LIBS@ @WRAP_LIBS@ @LIBADD_DL@ @ACL_LIBS@ @ZEROCONF_LIBS@
 afpd_LDFLAGS = -export-dynamic 
 afpd_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/sys \
-        @SLP_CFLAGS@ \
+        @SLP_CFLAGS@ @ZEROCONF_CFLAGS@ \
         -D_PATH_AFPDDEFVOL=\"$(pkgconfdir)/AppleVolumes.default\" \
         -D_PATH_AFPDSYSVOL=\"$(pkgconfdir)/AppleVolumes.system\" \
         -D_PATH_AFPDPWFILE=\"$(pkgconfdir)/afppasswd\" \
index 12ebe3c00880fa63b70fc82b4bb6af47a520cdbd..7f982c3341a1765dbdb3a99066148187209671ac 100644 (file)
@@ -154,10 +154,13 @@ static char * srvloc_encode(const struct afp_options *options, const char *name)
        return buf;
 }
 #endif /* USE_SRVLOC */
+#ifdef USE_ZEROCONF
+#include "afp_zeroconf.h"
+#endif /* USE_ZEROCONF */
 
-#ifdef USE_SRVLOC
 static void dsi_cleanup(const AFPConfig *config)
 {
+#ifdef USE_SRVLOC
     SLPError err;
     SLPError callbackerr;
     SLPHandle hslp;
@@ -190,8 +193,16 @@ static void dsi_cleanup(const AFPConfig *config)
 srvloc_dereg_err:
     dsi->srvloc_url[0] = '\0';
     SLPClose(hslp);
-}
+#elif defined (USE_ZEROCONF)
+    DSI *dsi = (DSI *)config->obj.handle;
+
+    /*  Do nothing if we didn't register.  */
+    if (!dsi || dsi->zeroconf_registered == 0)
+        return;
+
+    zeroconf_deregister();
 #endif /* USE_SRVLOC */
+}
 
 #ifndef NO_DDP
 static void asp_cleanup(const AFPConfig *config)
@@ -453,6 +464,41 @@ srvloc_reg_err:
     }
 #endif /* USE_SRVLOC */
 
+#ifdef USE_ZEROCONF
+     struct servent *afpovertcp;
+     int afp_port = 548;
+     char *hostname = NULL;
+
+    dsi->zeroconf_registered = 0; /*  Mark that we haven't registered.  */
+
+    if (!(options->flags & OPTION_NOZEROCONF)) {
+        /* XXX We don't want to tack on the port number if we don't have to.
+          * Why?
+          * Well, this seems to break MacOS < 10.  If the user _really_ wants to
+          * use a non-default port, they can, but be aware, this server might
+          * not show up int the Network Browser.
+          */
+        afpovertcp = getservbyname("afpovertcp", "tcp");
+        if (afpovertcp != NULL) {
+             afp_port = ntohs(afpovertcp->s_port);
+        }
+
+        /* If specified use the FQDN to register with srvloc, otherwise use IP. */
+        p = NULL;
+        if (options->fqdn) {
+            hostname = options->fqdn;
+            p = strchr(hostname, ':');
+        }      
+        else 
+            hostname = inet_ntoa(dsi->server.sin_addr);
+
+        if (!(options->flags & OPTION_NOSLP)) {
+            zeroconf_register(afp_port, hostname);
+            dsi->zeroconf_registered = 1; /*  Mark that we have registered.  */
+        }
+    }
+    config->server_cleanup = dsi_cleanup;
+#endif /* USE_ZEROCONF */
 
     config->fd = dsi->serversock;
     config->obj.handle = dsi;
index cc7c42416510a21df1c39ea0346cb420369b18b1..40955be7dcdbc5f43f57db7a41c3f380a23cd074 100644 (file)
@@ -221,7 +221,10 @@ int afp_options_parseline(char *buf, struct afp_options *options)
     if (strstr(buf, " -slp"))
         options->flags &= ~OPTION_NOSLP;
 #endif
-
+#ifdef USE_ZEROCONF
+    if (strstr(buf, " -nozeroconf"))
+        options->flags |= OPTION_NOZEROCONF;
+#endif
     if (strstr(buf, " -nouservolfirst"))
         options->flags &= ~OPTION_USERVOLFIRST;
     if (strstr(buf, " -uservolfirst"))
@@ -531,6 +534,12 @@ static void show_version_extended(void )
        puts( "No" );
 #endif
 
+#ifdef USE_ZEROCONF
+       puts( "Yes" );
+#else
+       puts( "No" );
+#endif
+
        printf( "  TCP wrappers support:\t" );
 #ifdef TCPWRAP
        puts( "Yes" );
index d2f86136837640439116fa66d3a4ddbdffc04d0a..40c9601be635ec38e07ea13b3489b5d4ef8fdb09 100644 (file)
@@ -36,6 +36,7 @@
 #define OPTION_ANNOUNCESSH   (1 << 6)
 #define OPTION_UUID          (1 << 7)
 #define OPTION_ACL2OS9MODE   (1 << 8)
+#define OPTION_NOZEROCONF    (1 << 9)
 
 #ifdef FORCE_UIDGID
 /* set up a structure for this */
index 82da7a1595e517b0b0eea4ad761b4cb68d9dbd43..0616774da18da49e2afb74ccc971bd13d40b6d19 100644 (file)
@@ -94,6 +94,10 @@ typedef struct DSI {
   char srvloc_url[512];
 #endif 
 
+#ifdef USE_ZEROCONF
+  int zeroconf_registered;
+#endif
+
   /* buffer for OSX deadlock */
   char *buffer;
   char *start;
index a14d22f573b33b4fd9cafb692ed5193ce853a1d6..4b970845e87c3422125532ae813a8079278e1853 100644 (file)
@@ -50,6 +50,7 @@ AC_DEFUN([AC_NETATALK_CONFIG_SUMMARY], [
        AC_MSG_RESULT([    Options:])
        AC_MSG_RESULT([         CUPS support:           $netatalk_cv_use_cups])
        AC_MSG_RESULT([         SLP support:            $netatalk_cv_srvloc])
+       AC_MSG_RESULT([         Zeroconf support:       $netatalk_cv_zeroconf])
        AC_MSG_RESULT([         tcp wrapper support:    $netatalk_cv_tcpwrap])
 dnl    if test x"$netatalk_cv_linux_sendfile" != x; then
 dnl            AC_MSG_RESULT([         Linux sendfile support: $netatalk_cv_linux_sendfile])