]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/auth.c
Reworked logger
[netatalk.git] / etc / afpd / auth.c
index a0b05b48d788da63a444d1216d2340f026bd60e3..836cd375bd9ae36074a46fff2d012270f1cbd1dd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: auth.c,v 1.51 2007-12-03 14:50:38 didg Exp $
+ * $Id: auth.c,v 1.61 2009-02-27 09:14:40 franklahm Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -30,6 +30,7 @@
 #include <grp.h>
 #include <atalk/logger.h>
 #include <atalk/server_ipc.h>
+#include <atalk/uuid.h>
 
 #ifdef TRU64
 #include <netdb.h>
@@ -45,8 +46,13 @@ extern void afp_get_cmdline( int *ac, char ***av );
 #include "uam_auth.h"
 #include "switch.h"
 #include "status.h"
-
 #include "fork.h"
+#ifdef HAVE_NFSv4_ACLS
+#include "acls.h"
+#endif
+#ifdef HAVE_EXT_ATTRS
+#include "extattrs.h"
+#endif
 
 int    afp_version = 11;
 static int afp_version_index;
@@ -76,7 +82,8 @@ static struct afp_versions    afp_versions[] = {
             { "AFP2.2",        22 },
 #ifdef AFP3x
             { "AFPX03", 30 },
-            { "AFP3.1", 31 }
+            { "AFP3.1", 31 },
+            { "AFP3.2", 32 }
 #endif            
         };
 
@@ -163,6 +170,14 @@ int        ibuflen _U_, *rbuflen;
     return AFPERR_PWDEXPR;
 }
 
+static int afp_null_nolog(obj, ibuf, ibuflen, rbuf, rbuflen )
+AFPObj  *obj _U_;
+char   *ibuf _U_, *rbuf _U_;
+int    ibuflen _U_, *rbuflen;
+{
+    *rbuflen = 0;
+    return( AFPERR_NOOP );
+}
 
 static int set_auth_switch(int expired)
 {
@@ -186,8 +201,23 @@ static int set_auth_switch(int expired)
     else {
         afp_switch = postauth_switch;
         switch (afp_version) {
+        case 32:
+           uam_afpserver_action(AFP_SPOTLIGHT_PRIVATE, UAM_AFPSERVER_POSTAUTH, afp_null_nolog, NULL);
+           uam_afpserver_action(AFP_SYNCDIR, UAM_AFPSERVER_POSTAUTH, afp_syncdir, NULL);
+           uam_afpserver_action(AFP_SYNCFORK, UAM_AFPSERVER_POSTAUTH, afp_syncfork, NULL);
+#ifdef HAVE_NFSv4_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
+#ifdef HAVE_EXT_ATTRS
+           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);
+           uam_afpserver_action(AFP_LISTEXTATTR, UAM_AFPSERVER_POSTAUTH, afp_listextattr, NULL);
+#endif
         case 31:
-           uam_afpserver_action(AFP_ENUMERATE_EXT2, UAM_AFPSERVER_POSTAUTH, afp_enumerate_ext2, NULL); 
+           uam_afpserver_action(AFP_ENUMERATE_EXT2, UAM_AFPSERVER_POSTAUTH, afp_enumerate_ext2, NULL);
         case 30:
            uam_afpserver_action(AFP_ENUMERATE_EXT, UAM_AFPSERVER_POSTAUTH, afp_enumerate_ext, NULL); 
            uam_afpserver_action(AFP_BYTELOCK_EXT,  UAM_AFPSERVER_POSTAUTH, afp_bytelock_ext, NULL); 
@@ -218,9 +248,9 @@ static int login(AFPObj *obj, struct passwd *pwd, void (*logout)(void), int expi
     int admin = 0;
 #endif /* ADMIN_GRP */
 
-    /* UAM had syslog control; afpd needs to reassert itself */
+#if 0
     set_processname("afpd");
-    syslog_setup(log_debug, logtype_default, logoption_ndelay|logoption_pid, logfacility_daemon);
+#endif
 
     if ( pwd->pw_uid == 0 ) {  /* don't allow root login */
         LOG(log_error, logtype_afpd, "login: root login denied!" );
@@ -921,6 +951,8 @@ int ibuflen _U_, *rbuflen;
     u_int32_t id;
     u_int16_t bitmap;
 
+    LOG(log_debug, logtype_afpd, "begin afp_getuserinfo:");
+
     *rbuflen = 0;
     ibuf++;
     thisuser = *ibuf++;
@@ -956,7 +988,30 @@ int        ibuflen _U_, *rbuflen;
         *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;
+       }
+       uuid_bin2string( uuid, &uuidstring);
+       LOG(log_debug, logtype_afpd, "afp_getuserinfo: got UUID: %s", uuidstring);
+       free(uuidstring);
+       memcpy(rbuf, uuid, UUID_BINSIZE);
+       rbuf += UUID_BINSIZE;
+       *rbuflen += UUID_BINSIZE;
+    }
+#endif
     return AFP_OK;
+    LOG(log_debug, logtype_afpd, "END afp_getuserinfo:");
 }
 
 #define UAM_LIST(type) (((type) == UAM_SERVER_LOGIN || (type) == UAM_SERVER_LOGIN_EXT) ? &uam_login : \