- if (ibuflen <= 4)
- return send_reply(obj, AFPERR_BADVERS );
-
- ibuf++;
- ibuf++; /* pad */
- ibuf +=2; /* flag */
-
- len = (unsigned char) *ibuf;
- ibuf++;
- ibuflen -= 5;
-
- i = get_version(obj, ibuf, ibuflen, len);
- if (i)
- return send_reply(obj, i );
-
- ibuf += len;
- ibuflen -= len;
-
- if (ibuflen <= 1)
- return send_reply(obj, AFPERR_BADUAM);
-
- len = (unsigned char) *ibuf;
- ibuf++;
- ibuflen--;
-
- if (!len || len > ibuflen)
- return send_reply(obj, AFPERR_BADUAM);
-
- if ((afp_uam = auth_uamfind(UAM_SERVER_LOGIN, ibuf, len)) == NULL)
- return send_reply(obj, AFPERR_BADUAM);
- ibuf += len;
- ibuflen -= len;
-
- if (!afp_uam->u.uam_login.login_ext) {
- LOG(log_error, logtype_afpd, "login_ext: uam %s not AFP 3 ready!", afp_uam->uam_name );
- return send_reply(obj, AFPERR_BADUAM);
- }
- /* user name */
- if (len <= 1 +sizeof(len16))
- return send_reply(obj, AFPERR_PARAM);
- type = *ibuf;
- username = ibuf;
- ibuf++;
- ibuflen--;
- if (type != 3)
- return send_reply(obj, AFPERR_PARAM);
-
- memcpy(&len16, ibuf, sizeof(len16));
- ibuf += sizeof(len16);
- ibuflen -= sizeof(len16);
- len = ntohs(len16);
- if (len > ibuflen)
- return send_reply(obj, AFPERR_PARAM);
- ibuf += len;
- ibuflen -= len;
-
- /* directory service name */
- if (!ibuflen)
- return send_reply(obj, AFPERR_PARAM);
- type = *ibuf;
- ibuf++;
- ibuflen--;
-
- switch(type) {
- case 1:
- case 2:
- if (!ibuflen)
- return send_reply(obj, AFPERR_PARAM);
- len = (unsigned char) *ibuf;
- ibuf++;
- ibuflen--;
- break;
- case 3:
- if (ibuflen <= sizeof(len16))
- return send_reply(obj, AFPERR_PARAM);
-
- memcpy(&len16, ibuf, sizeof(len16));
- ibuf += sizeof(len16);
- ibuflen -= sizeof(len16);
- len = ntohs(len16);
- break;
- default:
- return send_reply(obj, AFPERR_PARAM);
- }
- if (len != 0) {
- LOG(log_error, logtype_afpd, "login_ext: directory service path not null!" );
- return send_reply(obj, AFPERR_PARAM);
- }
- ibuf += len;
- ibuflen -= len;
-
- if (!ibuflen )
- return send_reply(obj, AFPERR_PARAM);
-
- /* Pad */
- ibuf++;
- ibuflen--;
-
- /* FIXME user name are in unicode */
- i = afp_uam->u.uam_login.login_ext(obj, username, &pwd, ibuf, ibuflen, rbuf, rbuflen);
- if (i || !pwd)
- return send_reply(obj, i);
-
- return send_reply(obj, login(obj, pwd, afp_uam->u.uam_login.logout));
-}
-
-/* ---------------------- */