]> arthur.barton.de Git - netatalk.git/blobdiff - etc/uams/uams_dhx_passwd.c
IPv6 support for afpd and cnid_metad
[netatalk.git] / etc / uams / uams_dhx_passwd.c
index c8e890ecf4432e544c8304d63ce148c7440b409f..6abbab0a88e3c4d9337e3e1af5c56fab366f9529 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uams_dhx_passwd.c,v 1.23 2005-04-28 20:49:50 bfernhomberg Exp $
+ * $Id: uams_dhx_passwd.c,v 1.27 2009-11-05 14:38:07 franklahm Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu) 
@@ -70,13 +70,13 @@ static u_int8_t randbuf[16];
 #include <sia.h>
 #include <siad.h>
 
-static char *clientname;
+static const char *clientname;
 #endif /* TRU64 */
 
 /* dhx passwd */
 static int pwd_login(void *obj, char *username, int ulen, struct passwd **uam_pwd _U_,
-                       char *ibuf, int ibuflen _U_,
-                       char *rbuf, int *rbuflen)
+                       char *ibuf, size_t ibuflen _U_,
+                       char *rbuf, size_t *rbuflen)
 {
     unsigned char iv[] = "CJalbert";
     u_int8_t p[] = {0xBA, 0x28, 0x73, 0xDF, 0xB0, 0x60, 0x57, 0xD4,
@@ -87,7 +87,7 @@ static int pwd_login(void *obj, char *username, int ulen, struct passwd **uam_pw
 #endif /* SHADOWPW */
     BIGNUM *bn, *gbn, *pbn;
     u_int16_t sessid;
-    int i;
+    size_t i;
     DH *dh;
 
 #ifdef TRU64
@@ -125,7 +125,7 @@ static int pwd_login(void *obj, char *username, int ulen, struct passwd **uam_pw
       return AFPERR_NOTAUTH;
 
     /* get the client's public key */
-    if (!(bn = BN_bin2bn(ibuf, KEYSIZE, NULL))) {
+    if (!(bn = BN_bin2bn((unsigned char *)ibuf, KEYSIZE, NULL))) {
       return AFPERR_PARAM;
     }
 
@@ -157,10 +157,10 @@ static int pwd_login(void *obj, char *username, int ulen, struct passwd **uam_pw
     }
 
     /* figure out the key. use rbuf as a temporary buffer. */
-    i = DH_compute_key(rbuf, bn, dh);
+    i = DH_compute_key((unsigned char *)rbuf, bn, dh);
     
     /* set the key */
-    CAST_set_key(&castkey, i, rbuf);
+    CAST_set_key(&castkey, i, (unsigned char *)rbuf);
     
     /* session id. it's just a hashed version of the object pointer. */
     sessid = dhxhash(obj);
@@ -169,7 +169,7 @@ static int pwd_login(void *obj, char *username, int ulen, struct passwd **uam_pw
     *rbuflen += sizeof(sessid);
     
     /* send our public key */
-    BN_bn2bin(dh->pub_key, rbuf); 
+    BN_bn2bin(dh->pub_key, (unsigned char *)rbuf); 
     rbuf += KEYSIZE;
     *rbuflen += KEYSIZE;
 
@@ -195,7 +195,7 @@ static int pwd_login(void *obj, char *username, int ulen, struct passwd **uam_pw
 #endif /* 0 */
 
     /* encrypt using cast */
-    CAST_cbc_encrypt(rbuf, rbuf, CRYPTBUFLEN, &castkey, iv, CAST_ENCRYPT);
+    CAST_cbc_encrypt((unsigned char *)rbuf, (unsigned char *)rbuf, CRYPTBUFLEN, &castkey, iv, CAST_ENCRYPT);
     *rbuflen += CRYPTBUFLEN;
     BN_free(bn);
     DH_free(dh);
@@ -209,11 +209,11 @@ passwd_fail:
 
 /* cleartxt login */
 static int passwd_login(void *obj, struct passwd **uam_pwd,
-                       char *ibuf, int ibuflen,
-                       char *rbuf, int *rbuflen)
+                       char *ibuf, size_t ibuflen,
+                       char *rbuf, size_t *rbuflen)
 {
     char *username;
-    int len, ulen;
+    size_t len, ulen;
 
     *rbuflen = 0;
 
@@ -221,7 +221,7 @@ static int passwd_login(void *obj, struct passwd **uam_pwd,
                             (void *) &username, &ulen) < 0)
        return AFPERR_MISC;
 
-    if (ibuflen <= 1) {
+    if (ibuflen < 2) {
        return( AFPERR_PARAM );
     }
 
@@ -250,11 +250,11 @@ static int passwd_login(void *obj, struct passwd **uam_pwd,
     len bytes utf8 name
 */
 static int passwd_login_ext(void *obj, char *uname, struct passwd **uam_pwd,
-                       char *ibuf, int ibuflen,
-                       char *rbuf, int *rbuflen)
+                       char *ibuf, size_t ibuflen,
+                       char *rbuf, size_t *rbuflen)
 {
     char       *username;
-    int        len, ulen;
+    size_t     len, ulen;
     u_int16_t  temp16;
 
     *rbuflen = 0;
@@ -277,8 +277,8 @@ static int passwd_login_ext(void *obj, char *uname, struct passwd **uam_pwd,
 }
                        
 static int passwd_logincont(void *obj, struct passwd **uam_pwd,
-                           char *ibuf, int ibuflen _U_, 
-                           char *rbuf, int *rbuflen)
+                           char *ibuf, size_t ibuflen _U_, 
+                           char *rbuf, size_t *rbuflen)
 {
 #ifdef SHADOWPW
     struct spwd *sp;
@@ -298,12 +298,12 @@ static int passwd_logincont(void *obj, struct passwd **uam_pwd,
     ibuf += sizeof(sessid);
    
     /* use rbuf as scratch space */
-    CAST_cbc_encrypt(ibuf, rbuf, CRYPT2BUFLEN, &castkey,
+    CAST_cbc_encrypt((unsigned char *)ibuf, (unsigned char *)rbuf, CRYPT2BUFLEN, &castkey,
                     iv, CAST_DECRYPT);
     
     /* check to make sure that the random number is the same. we
      * get sent back an incremented random number. */
-    if (!(bn1 = BN_bin2bn(rbuf, KEYSIZE, NULL)))
+    if (!(bn1 = BN_bin2bn((unsigned char *)rbuf, KEYSIZE, NULL)))
       return AFPERR_PARAM;
 
     if (!(bn2 = BN_bin2bn(randbuf, sizeof(randbuf), NULL))) {
@@ -403,3 +403,9 @@ UAM_MODULE_EXPORT struct uam_export uams_dhx = {
   UAM_MODULE_VERSION,
   uam_setup, uam_cleanup
 };
+
+UAM_MODULE_EXPORT struct uam_export uams_dhx_passwd = {
+  UAM_MODULE_SERVER,
+  UAM_MODULE_VERSION,
+  uam_setup, uam_cleanup
+};