]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/uam.c
New option parsing
[netatalk.git] / etc / afpd / uam.c
index 5ebf617cf84ab3933944cc0262eeae1d0a8e7312..8adfb3bbd9539a9e3daa1b9b9e6f4a871862a269 100644 (file)
@@ -29,8 +29,8 @@
 #include <atalk/dsi.h>
 #include <atalk/afp.h>
 #include <atalk/util.h>
+#include <atalk/globals.h>
 
-#include "globals.h"
 #include "afp_config.h"
 #include "auth.h"
 #include "uam_auth.h"
@@ -242,11 +242,11 @@ struct passwd *uam_getname(void *private, char *name, const int len)
         if ((p = strchr(pwent->pw_gecos, ',')))
             *p = '\0';
 
-       if ((size_t)-1 == ( gecoslen = convert_string(obj->options.unixcharset, CH_UCS2, 
-                               pwent->pw_gecos, -1, user, sizeof(username))) )
-               continue;
-       if ((size_t)-1 == ( pwnamelen = convert_string(obj->options.unixcharset, CH_UCS2, 
-                               pwent->pw_name, -1, pwname, sizeof(username))) )
+       gecoslen = convert_string(obj->options.unixcharset, CH_UCS2, 
+                               pwent->pw_gecos, -1, user, sizeof(username));
+       pwnamelen = convert_string(obj->options.unixcharset, CH_UCS2, 
+                               pwent->pw_name, -1, pwname, sizeof(username));
+       if ((size_t)-1 == gecoslen && (size_t)-1 == pwnamelen)
                continue;
 
 
@@ -296,7 +296,7 @@ int uam_checkuser(const struct passwd *pwd)
 
 int uam_random_string (AFPObj *obj, char *buf, int len)
 {
-    u_int32_t result;
+    uint32_t result;
     int ret;
     int fd;
 
@@ -311,7 +311,7 @@ int uam_random_string (AFPObj *obj, char *buf, int len)
 
         if (gettimeofday(&tv, &tz) < 0)
             return -1;
-        srandom(tv.tv_sec + (unsigned long) obj + (unsigned long) obj->handle);
+        srandom(tv.tv_sec + (unsigned long) obj + (unsigned long) obj->dsi);
         for (i = 0; i < len; i += sizeof(result)) {
             result = random();
             memcpy(buf + i, &result, sizeof(result));
@@ -364,11 +364,6 @@ int uam_afpserver_option(void *private, const int what, void *option,
             *len = sizeof(obj->options.passwdminlen);
             break;
 
-        case UAM_PASSWD_MAXFAIL:
-            *((int *) option) = obj->options.loginmaxfail;
-            *len = sizeof(obj->options.loginmaxfail);
-            break;
-
         case UAM_PASSWD_EXPIRETIME: /* not implemented */
         default:
             return -1;
@@ -401,7 +396,7 @@ int uam_afpserver_option(void *private, const int what, void *option,
         
     case UAM_OPTION_CLIENTNAME:
     {
-        struct DSI *dsi = obj->handle;
+        struct DSI *dsi = obj->dsi;
         const struct sockaddr *sa;
         static char hbuf[NI_MAXHOST];
         
@@ -466,15 +461,15 @@ int uam_afp_read(void *handle, char *buf, size_t *buflen,
     if (!obj)
         return AFPERR_PARAM;
 
-        len = dsi_writeinit(obj->handle, buf, *buflen);
+        len = dsi_writeinit(obj->dsi, buf, *buflen);
         if (!len || ((len = action(handle, buf, len)) < 0)) {
-            dsi_writeflush(obj->handle);
+            dsi_writeflush(obj->dsi);
             goto uam_afp_read_err;
         }
 
-        while ((len = (dsi_write(obj->handle, buf, *buflen)))) {
+        while ((len = (dsi_write(obj->dsi, buf, *buflen)))) {
             if ((len = action(handle, buf, len)) < 0) {
-                dsi_writeflush(obj->handle);
+                dsi_writeflush(obj->dsi);
                 goto uam_afp_read_err;
             }
         }