X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=etc%2Fafpd%2Fuam.c;h=d99d381edd38cc4408a5076039ef47f53d4e7899;hb=84c3a8f52deced7429f9d72276232ee282b3b823;hp=18f57ea1eef7bfe0cecfc0211a6bc4c6e21faac5;hpb=ae97675aefb21e9e3039b759c688f5f1328cfa7e;p=netatalk.git diff --git a/etc/afpd/uam.c b/etc/afpd/uam.c index 18f57ea1..d99d381e 100644 --- a/etc/afpd/uam.c +++ b/etc/afpd/uam.c @@ -26,23 +26,16 @@ #include #include -#include -#include #include #include #include +#include +#include -#include "globals.h" #include "afp_config.h" #include "auth.h" #include "uam_auth.h" -#ifdef AFP3x -#define utf8_encoding() (afp_version >= 30) -#else -#define utf8_encoding() (0) -#endif - #ifdef TRU64 #include #include @@ -239,7 +232,7 @@ struct passwd *uam_getname(void *private, char *name, const int len) } #ifndef NO_REAL_USER_NAME - if ( (size_t) -1 == (namelen = convert_string((utf8_encoding())?CH_UTF8_MAC:obj->options.maccharset, + if ( (size_t) -1 == (namelen = convert_string((utf8_encoding(obj))?CH_UTF8_MAC:obj->options.maccharset, CH_UCS2, name, -1, username, sizeof(username)))) return NULL; @@ -248,11 +241,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; @@ -302,7 +295,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; @@ -317,7 +310,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)); @@ -370,11 +363,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; @@ -383,7 +371,7 @@ int uam_afpserver_option(void *private, const int what, void *option, break; case UAM_OPTION_SIGNATURE: - *buf = (void *) (((AFPConfig *)obj->config)->signature); + *buf = (void *)obj->dsi->signature; if (len) *len = 16; break; @@ -401,13 +389,9 @@ int uam_afpserver_option(void *private, const int what, void *option, *len = strlen(obj->options.hostname); break; - case UAM_OPTION_PROTOCOL: - *((int *) option) = obj->proto; - break; - case UAM_OPTION_CLIENTNAME: { - struct DSI *dsi = obj->handle; + struct DSI *dsi = obj->dsi; const struct sockaddr *sa; static char hbuf[NI_MAXHOST]; @@ -472,32 +456,18 @@ int uam_afp_read(void *handle, char *buf, size_t *buflen, if (!obj) return AFPERR_PARAM; -#ifndef NO_DDP - switch (obj->proto) { - case AFPPROTO_ASP: - if ((len = asp_wrtcont(obj->handle, buf, buflen )) < 0) - goto uam_afp_read_err; - return action(handle, buf, *buflen); - break; - - case AFPPROTO_DSI: -#endif - 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; } } -#ifndef NO_DDP - break; - } -#endif return 0; uam_afp_read_err: