]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/auth.c
Merge 2-1
[netatalk.git] / etc / afpd / auth.c
index 77e946ce3f02ff165f847e0c86d0c11f83107df3..6027b8515850760ec8f4274907ae3be95b70e19a 100644 (file)
@@ -26,9 +26,6 @@
 #include <time.h>
 #include <pwd.h>
 #include <grp.h>
-#include <atalk/logger.h>
-#include <atalk/server_ipc.h>
-#include <atalk/uuid.h>
 
 #ifdef TRU64
 #include <netdb.h>
 extern void afp_get_cmdline( int *ac, char ***av );
 #endif /* TRU64 */
 
+#include <atalk/logger.h>
+#include <atalk/server_ipc.h>
+#include <atalk/uuid.h>
+
 #include "globals.h"
 #include "auth.h"
 #include "uam_auth.h"
@@ -46,7 +47,7 @@ extern void afp_get_cmdline( int *ac, char ***av );
 #include "status.h"
 #include "fork.h"
 #include "extattrs.h"
-#ifdef HAVE_NFSv4_ACLS
+#ifdef HAVE_ACLS
 #include "acls.h"
 #endif
 
@@ -208,11 +209,11 @@ static int set_auth_switch(int expired)
         afp_switch = postauth_switch;
         switch (afp_version) {
         case 32:
-#ifdef HAVE_NFSv4_ACLS
+#ifdef HAVE_ACLS
             uam_afpserver_action(AFP_GETACL, UAM_AFPSERVER_POSTAUTH, afp_getacl, NULL);
             uam_afpserver_action(AFP_SETACL, UAM_AFPSERVER_POSTAUTH, afp_setacl, NULL);
             uam_afpserver_action(AFP_ACCESS, UAM_AFPSERVER_POSTAUTH, afp_access, NULL);
-#endif
+#endif /* HAVE_ACLS */
             uam_afpserver_action(AFP_GETEXTATTR, UAM_AFPSERVER_POSTAUTH, afp_getextattr, NULL);
             uam_afpserver_action(AFP_SETEXTATTR, UAM_AFPSERVER_POSTAUTH, afp_setextattr, NULL);
             uam_afpserver_action(AFP_REMOVEATTR, UAM_AFPSERVER_POSTAUTH, afp_remextattr, NULL);
@@ -959,6 +960,7 @@ int afp_getuserinfo(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf,
     u_int8_t  thisuser;
     u_int32_t id;
     u_int16_t bitmap;
+    char *bitmapp;
 
     LOG(log_debug, logtype_afpd, "begin afp_getuserinfo:");
 
@@ -977,8 +979,9 @@ int afp_getuserinfo(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf,
     if ((bitmap & USERIBIT_ALL) != bitmap)
         return AFPERR_BITMAP;
 
-    /* copy the bitmap back to reply buffer */
+    /* remember place where we store the possibly modified bitmap later */
     memcpy(rbuf, ibuf, sizeof(bitmap));
+    bitmapp = rbuf;
     rbuf += sizeof(bitmap);
     *rbuflen = sizeof(bitmap);
 
@@ -997,29 +1000,27 @@ int afp_getuserinfo(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf,
         *rbuflen += sizeof(id);
     }
 
-#ifdef HAVE_NFSv4_ACLS
     if (bitmap & USERIBIT_UUID) {
-        int ret;
-        uuid_t uuid;
-        char *uuidstring;
-
-        if ( ! (obj->options.flags & OPTION_UUID))
-            return AFPERR_BITMAP;
-        LOG(log_debug, logtype_afpd, "afp_getuserinfo: get UUID for \'%s\'", obj->username);
-        ret = getuuidfromname( obj->username, UUID_USER, uuid);
-        if (ret != 0) {
-            LOG(log_info, logtype_afpd, "afp_getuserinfo: error getting UUID !");
-            return AFPERR_NOITEM;
-        }
-        if (0 == (uuid_bin2string( uuid, &uuidstring))) {
-            LOG(log_debug, logtype_afpd, "afp_getuserinfo: got UUID: %s", uuidstring);
-            free(uuidstring);
+        if ( ! (obj->options.flags & OPTION_UUID)) {
+            bitmap &= ~USERIBIT_UUID;
+            bitmap = htons(bitmap);
+            memcpy(bitmapp, &bitmap, sizeof(bitmap));
+        } else {
+            LOG(log_debug, logtype_afpd, "afp_getuserinfo: get UUID for \'%s\'", obj->username);
+            int ret;
+            atalk_uuid_t uuid;
+            ret = getuuidfromname( obj->username, UUID_USER, uuid);
+            if (ret != 0) {
+                LOG(log_info, logtype_afpd, "afp_getuserinfo: error getting UUID !");
+                return AFPERR_NOITEM;
+            }
+            LOG(log_debug, logtype_afpd, "afp_getuserinfo: got UUID: %s", uuid_bin2string(uuid));
+
+            memcpy(rbuf, uuid, UUID_BINSIZE);
+            rbuf += UUID_BINSIZE;
+            *rbuflen += UUID_BINSIZE;
         }
-        memcpy(rbuf, uuid, UUID_BINSIZE);
-        rbuf += UUID_BINSIZE;
-        *rbuflen += UUID_BINSIZE;
     }
-#endif
 
     LOG(log_debug, logtype_afpd, "END afp_getuserinfo:");
     return AFP_OK;