]> arthur.barton.de Git - netatalk.git/commitdiff
Advertise adisk with port 9.
authorFrank Lahm <franklahm@googlemail.com>
Wed, 23 Jun 2010 11:33:43 +0000 (13:33 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Wed, 23 Jun 2010 11:33:43 +0000 (13:33 +0200)
Don't advertise adisk at all if no TM volumes are configured.
Ensure child processes find a clean volumes config.

etc/afpd/afp_avahi.c
etc/afpd/afp_config.c
etc/afpd/volume.c
etc/afpd/volume.h

index de4126ecb770c2feef64c4fcaf4ed1139cf4cba8..55fd6e96bffbcb4fe8ced82ba7a7a37200475a52 100644 (file)
@@ -104,16 +104,16 @@ static void register_stuff(void) {
                                goto fail;
                        }
 
-                       if (avahi_entry_group_add_service_strlst(ctx->group,
-                                                                                                                                                                                        AVAHI_IF_UNSPEC,
-                                                                                                                                                                                        AVAHI_PROTO_UNSPEC,
-                                                                                                                                                                                        0,
-                                                                                                                                                                                        name,
-                                                                                                                                                                                        "_adisk._tcp",
-                                                                                                                                                                                        NULL,
-                                                                                                                                                                                        NULL,
-                                                                                                                                                                                        311, /* serveradmin, peaked from os x 10.6 server */
-                                                                                                                                                                                        strlist) < 0) {
+                       if (i && avahi_entry_group_add_service_strlst(ctx->group,
+                                                                                                                                                                                                               AVAHI_IF_UNSPEC,
+                                                                                                                                                                                                               AVAHI_PROTO_UNSPEC,
+                                                                                                                                                                                                               0,
+                                                                                                                                                                                                               name,
+                                                                                                                                                                                                               "_adisk._tcp",
+                                                                                                                                                                                                               NULL,
+                                                                                                                                                                                                               NULL,
+                                                                                                                                                                                                               9, /* discard */
+                                                                                                                                                                                                               strlist) < 0) {
                                LOG(log_error, logtype_afpd, "Failed to add service: %s",
                                                avahi_strerror(avahi_client_errno(ctx->client)));
                                goto fail;
index 07fb8d2c27c4dd5b4d2578d53fbc64077ef8abae..cb836b81a7a19e7a760fbc1e77df1bf3cf077bf4 100644 (file)
@@ -96,6 +96,9 @@ void configfree(AFPConfig *configs, const AFPConfig *config)
         }
         free(p);
     }
+
+    /* the master loaded the volumes for zeroconf, get rid of that */
+    unload_volumes_and_extmap();
 }
 
 #ifdef USE_SRVLOC
index d9cba5d731c815c0fa84481e3ad8e478719c6157..ff17a315fe92b71ccb8aedab46e025baee0381c9 100644 (file)
@@ -1107,12 +1107,16 @@ int readvolfile(AFPObj *obj, struct afp_volume_name *p1, char *p2, int user, str
     char        buf[BUFSIZ];
     char        type[5], creator[5];
     char        *u, *p;
+    int         fd;
+    int         afpmaster = 0;
+    int         i;
     struct passwd   *pw;
     struct vol_option   save_options[VOLOPT_NUM];
     struct vol_option   options[VOLOPT_NUM];
-    int                 i;
     struct stat         st;
-    int                 fd;
+
+    if (! ((DSI *)obj->handle)->child)
+        afpmaster = 1;
 
     if (!p1->name)
         return -1;
@@ -1191,7 +1195,11 @@ int readvolfile(AFPObj *obj, struct afp_volume_name *p1, char *p2, int user, str
                 strcpy(tmp, path);
             if (!pwent && obj->username)
                 pwent = getpwnam(obj->username);
-            volxlate(obj, path, sizeof(path) - 1, tmp, pwent, NULL, NULL);
+
+            if (! afpmaster)
+                strcpy(tmp, path);
+            else
+                volxlate(obj, path, sizeof(path) - 1, tmp, pwent, NULL, NULL);
 
             /* this is sort of braindead. basically, i want to be
              * able to specify things in any order, but i don't want to
@@ -1243,7 +1251,11 @@ int readvolfile(AFPObj *obj, struct afp_volume_name *p1, char *p2, int user, str
                     options[VOLOPT_FLAGS].i_value |= AFPVOL_RO;
 
                 /* do variable substitution for volname */
-                volxlate(obj, tmp, sizeof(tmp) - 1, volname, pwent, path, NULL);
+                if (!afpmaster)
+                    strcpy(volname, tmp);
+                else
+                    volxlate(obj, tmp, sizeof(tmp) - 1, volname, pwent, path, NULL);
+
                 creatvol(obj, pwent, path, tmp, options, p2 != NULL);
             }
             volfree(options, save_options);
@@ -1684,6 +1696,12 @@ void load_volumes(AFPObj *obj)
         free_volumes();
     }
 
+    if (! ((DSI *)obj->handle)->child) {
+        LOG(log_debug, logtype_afpd, "load_volumes: AFP MASTER");
+    } else {
+        LOG(log_debug, logtype_afpd, "load_volumes: user: %s", obj->username);
+    }
+
     pwent = getpwnam(obj->username);
     if ( (obj->options.flags & OPTION_USERVOLFIRST) == 0 ) {
         readvolfile(obj, &obj->options.systemvol, NULL, 0, pwent);
@@ -1713,7 +1731,7 @@ void load_volumes(AFPObj *obj)
     if ( obj->options.flags & OPTION_USERVOLFIRST ) {
         readvolfile(obj, &obj->options.systemvol, NULL, 0, pwent );
     }
-
+    
     if ( obj->options.closevol ) {
         struct vol *vol;
 
@@ -2582,3 +2600,10 @@ const struct vol *getvolumes(void)
 {
     return Volumes;
 }
+
+void unload_volumes_and_extmap(void)
+{
+    LOG(log_debug, logtype_afpd, "unload_volumes_and_extmap");
+    free_extmap();
+    free_volumes();
+}
index 38ba59a879218104ee65197ba39beeede9a9a038..58dae44dc0d4eab5f0f0b8c66d534d6ba45b9740 100644 (file)
@@ -34,6 +34,7 @@ extern int              readvolfile(AFPObj *obj,
                                     int user,
                                     struct passwd *pwent);
 extern const struct vol *getvolumes(void);
+extern void             unload_volumes_and_extmap(void);
 
 /* FP functions */
 int afp_openvol      (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);