]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/util/netatalk_conf.c
Merge remote branch 'netafp/master' into branch-allea
[netatalk.git] / libatalk / util / netatalk_conf.c
index 7dd5a1e73e7aa73f59996b6cc85ee50fd08b178c..8a4cfb2afe67ca42d3ee4e4eb837bd82ed843874 100644 (file)
@@ -46,6 +46,9 @@
 #include <atalk/netatalk_conf.h>
 
 #define VOLPASSLEN  8
+#ifndef UUID_PRINTABLE_STRING_LENGTH
+#define UUID_PRINTABLE_STRING_LENGTH 37
+#endif
 
 #define IS_VAR(a, b) (strncmp((a), (b), 2) == 0)
 
@@ -173,7 +176,7 @@ static int do_check_ea_support(const struct vol *vol)
 
     mktemp(eaname);
 
-//    become_root();
+    become_root();
 
     if ((sys_setxattr(vol->v_path, eaname, eacontent, 4, 0)) == 0) {
         sys_removexattr(vol->v_path, eaname);
@@ -184,7 +187,7 @@ static int do_check_ea_support(const struct vol *vol)
         haseas = 0;
     }
 
-//    unbecome_root();
+    unbecome_root();
 
     return haseas;
 }
@@ -437,7 +440,7 @@ static int hostaccessvol(const AFPObj *obj, const char *volname, const char *arg
     struct sockaddr_storage client;
     const DSI *dsi = obj->dsi;
 
-    if (!args)
+    if (!args || !dsi)
         return -1;
 
     strlcpy(buf, args, sizeof(buf));
@@ -953,8 +956,9 @@ static int readvolfile(AFPObj *obj, const struct passwd *pwent)
             continue;
         if (STRCMP(secname, ==, INISEC_HOMES)) {
             have_uservol = 1;
-            if (!obj->uid)
-                /* not an AFP session, but cnid daemon, dbd or ad util */
+            if (obj->username[0] == 0
+                || strcmp(obj->username, obj->options.guest) == 0)
+                /* not an AFP session, but cnid daemon, dbd or ad util, or guest login */
                 continue;
             strlcpy(tmp, pwent->pw_dir, MAXPATHLEN);
             strlcat(tmp, "/", MAXPATHLEN);
@@ -1191,10 +1195,10 @@ struct vol *getvolbyvid(const uint16_t vid )
  * (1) Search "normal" volume list 
  * (2) Check if theres a [Homes] section, load_volumes() remembers this for us
  * (3) If there is, match "path" with "basedir regex" to get the user home parent dir
- * (4) The next path element then is the username
- * (5) Built user home path by appending the basedir matched in (3) and appending the username
+ * (4) Built user home path by appending the basedir matched in (3) and appending the username
+ * (5) The next path element then is the username
  * (6) Append [Homes]->path subdirectory if defined
- * (6) Create volume
+ * (7) Create volume
  *
  * @param obj  (rw) handle
  * @param path (r)  path, may be relative or absolute
@@ -1264,6 +1268,7 @@ struct vol *getvolbypath(AFPObj *obj, const char *path)
     if (match[0].rm_eo - match[0].rm_so > MAXPATHLEN)
         EC_FAIL_LOG("getvolbypath(\"%s\"): path too long", path);
 
+    /* (4) */
     strncpy(tmpbuf, path + match[0].rm_so, match[0].rm_eo - match[0].rm_so);
     tmpbuf[match[0].rm_eo - match[0].rm_so] = 0;
 
@@ -1272,7 +1277,7 @@ struct vol *getvolbypath(AFPObj *obj, const char *path)
 
     strlcat(tmpbuf, "/", MAXPATHLEN);
 
-    /* (4) */
+    /* (5) */
     p = path + strlen(basedir);
     while (*p == '/')
         p++;
@@ -1283,18 +1288,19 @@ struct vol *getvolbypath(AFPObj *obj, const char *path)
     if (prw != 0)
         subpath = prw;
 
+    strlcpy(obj->username, user, MAXUSERLEN);
     strlcat(tmpbuf, user, MAXPATHLEN);
     strlcat(tmpbuf, "/", MAXPATHLEN);
 
-    /* (5) */
+    /* (6) */
     if (subpathconfig = iniparser_getstring(obj->iniconfig, INISEC_HOMES, "path", NULL)) {
         if (!subpath || strncmp(subpathconfig, subpath, strlen(subpathconfig)) != 0) {
             EC_FAIL;
         }
+        strlcat(tmpbuf, subpathconfig, MAXPATHLEN);
+        strlcat(tmpbuf, "/", MAXPATHLEN);
     }
 
-    strlcat(tmpbuf, subpathconfig, MAXPATHLEN);
-    strlcat(tmpbuf, "/", MAXPATHLEN);
 
     /* (7) */
     if (volxlate(obj, volpath, sizeof(volpath) - 1, tmpbuf, pw, NULL, NULL) == NULL)