]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/passwd.c
cnid_t is a unsigned variable, Joe! Thanks to Didier for pointing this out.
[netatalk.git] / etc / afpd / passwd.c
index 99a2af6b3cb2366348d3efb723c1aea257b475e1..66b72a68bab0e76c60bf87b9fd7a7a04d870c21c 100644 (file)
@@ -1,4 +1,6 @@
 /*
+ * $Id: passwd.c,v 1.5 2001-12-03 05:03:38 jmarcus Exp $
+ *
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
  * All Rights Reserved.
  *
  *     netatalk@itd.umich.edu
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
 #include <itc.h>
 #include <stdio.h>
+
+/* STDC check */
+#if STDC_HEADERS
 #include <string.h>
+#else /* STDC_HEADERS */
+#ifndef HAVE_STRCHR
+#define strchr index
+#define strrchr index
+#endif /* HAVE_STRCHR */
+char *strchr (), *strrchr ();
+#ifndef HAVE_MEMCPY
+#define memcpy(d,s,n) bcopy ((s), (d), (n))
+#define memmove(d,s,n) bcopy ((s), (d), (n))
+#endif /* ! HAVE_MEMCPY */
+#endif /* STDC_HEADERS */
+
 #include <r/xdr.h>
 #include <r/r.h>
 #include <afs/comauth.h>
@@ -36,8 +57,8 @@
 extern int r_errno;
 
 afs_changepw( ibuf, ibuflen, rbuf, rbuflen )
-    char       *ibuf, *rbuf;
-    int                ibuflen, *rbuflen;
+char   *ibuf, *rbuf;
+int            ibuflen, *rbuflen;
 {
     char       cell[ MAXCELLCHARS ], name[ 20 ], oldpw[ 10 ], newpw[ 10 ];
     char       *p;
@@ -47,61 +68,61 @@ afs_changepw( ibuf, ibuflen, rbuf, rbuflen )
     len = (unsigned char )*ibuf++;
     ibuf[ len ] = '\0';
     if (( p = strchr( ibuf, '@' )) != NULL ) {
-       *p++ = '\0';
-       strcpy( cell, p );
-       ucase( cell );
+        *p++ = '\0';
+        strcpy( cell, p );
+        ucase( cell );
     } else {
-       if ( GetLocalCellName() != CCONF_SUCCESS ) {
-           *rbuflen = 0;
-           return( AFPERR_BADUAM );
-       }
-       strcpy( cell, LclCellName );
+        if ( GetLocalCellName() != CCONF_SUCCESS ) {
+            *rbuflen = 0;
+            return( AFPERR_BADUAM );
+        }
+        strcpy( cell, LclCellName );
     }
 
     if ( strlen( ibuf ) > 20 ) {
-       *rbuflen = 0;
-       return( AFPERR_PARAM );
+        *rbuflen = 0;
+        return( AFPERR_PARAM );
     }
     strcpy( name, ibuf );
     ibuf += len;
 
 
     if (U_InitRPC() != 0) {
-       *rbuflen = 0;
-       return( AFPERR_BADUAM );
+        *rbuflen = 0;
+        return( AFPERR_BADUAM );
     }
 
     memcpy( &clen, ibuf, sizeof( clen ));
     ibuf += sizeof( short );
     pcbc_encrypt((C_Block *)ibuf, (C_Block *)ibuf,
-           clen, seskeysched, seskey, 0 );
+                 clen, seskeysched, seskey, 0 );
 
     len = (unsigned char) *ibuf++;
     if ( len > 9 ) {
-       *rbuflen = 0;
-       return( AFPERR_PARAM );
+        *rbuflen = 0;
+        return( AFPERR_PARAM );
     }
     memcpy( oldpw, ibuf, len );
     oldpw[ len ] = '\0';
 
     len = (unsigned char) *ibuf++;
     if ( len > 9 ) {
-       *rbuflen = 0;
-       return( AFPERR_PARAM );
+        *rbuflen = 0;
+        return( AFPERR_PARAM );
     }
     memcpy( newpw, ibuf, len );
     newpw[ len ] = '\0';
 
     rc = U_CellChangePassword( name, newpw, name, oldpw, cell ) != 0 ) {
 
-    if ( rc != 0 ) {
-       *rbuflen = 0;
-       if ( rc < 0 && r_errno = R_ERROR ) {
-           return( AFPERR_NOTAUTH );
-       } else {
-           return( AFPERR_BADUAM );
-       }
-    }
+        if ( rc != 0 ) {
+            *rbuflen = 0;
+            if ( rc < 0 && r_errno = R_ERROR ) {
+                return( AFPERR_NOTAUTH );
+            } else {
+                return( AFPERR_BADUAM );
+            }
+        }
 
-    return( AFP_OK );
-}
+        return( AFP_OK );
+    }