]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/afs.c
BIG commit to improve code style using astyle as well as fix up CNID DB
[netatalk.git] / etc / afpd / afs.c
index 169804f1cdbd370f701ab9caee2a9fc865bac2b6..7481825ef76f3dafb785ecdca97ce3763eb138c0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: afs.c,v 1.4 2001-06-20 18:33:04 rufustfirefly Exp $
+ * $Id: afs.c,v 1.5 2001-12-03 05:03:38 jmarcus Exp $
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
  */
@@ -28,9 +28,9 @@
 #include "misc.h"
 
 afs_getvolspace( vol, bfree, btotal, bsize )
-    struct vol *vol;
-    VolSpace   *bfree, *btotal;
-    u_int32_t   *bsize;
+struct vol     *vol;
+VolSpace       *bfree, *btotal;
+u_int32_t   *bsize;
 {
     struct ViceIoctl   vi;
     struct VolumeStatus        *vs;
@@ -41,26 +41,26 @@ afs_getvolspace( vol, bfree, btotal, bsize )
     vi.out_size = sizeof( venuspace );
     vi.out = venuspace;
     if ( pioctl( vol->v_path, VIOCGETVOLSTAT, &vi, 1 ) < 0 ) {
-       return( AFPERR_PARAM );
+        return( AFPERR_PARAM );
     }
 
     vs = (struct VolumeStatus *)venuspace;
 
     if ( vs->PartBlocksAvail > 0 ) {
-       if ( vs->MaxQuota != 0 ) {
+        if ( vs->MaxQuota != 0 ) {
 #define min(x,y)       (((x)<(y))?(x):(y))
-           free = min( vs->MaxQuota - vs->BlocksInUse, vs->PartBlocksAvail );
-       } else {
-           free = vs->PartBlocksAvail;
-       }
+            free = min( vs->MaxQuota - vs->BlocksInUse, vs->PartBlocksAvail );
+        } else {
+            free = vs->PartBlocksAvail;
+        }
     } else {
-       free = 0;
+        free = 0;
     }
 
     if ( vs->MaxQuota != 0 ) {
-       total = free + vs->BlocksInUse;
+        total = free + vs->BlocksInUse;
     } else {
-       total = vs->PartMaxBlocks;
+        total = vs->PartMaxBlocks;
     }
 
     *bsize = 1024;
@@ -71,9 +71,9 @@ afs_getvolspace( vol, bfree, btotal, bsize )
 }
 
 afp_getdiracl(obj, ibuf, ibuflen, rbuf, rbuflen )
-    AFPObj      *obj;
-    char       *ibuf, *rbuf;
-    int                ibuflen, *rbuflen;
+AFPObj      *obj;
+char   *ibuf, *rbuf;
+int            ibuflen, *rbuflen;
 {
     struct ViceIoctl   vi;
     struct vol         *vol;
@@ -86,32 +86,32 @@ afp_getdiracl(obj, ibuf, ibuflen, rbuf, rbuflen )
     memcpy( &vid, ibuf, sizeof( vid ));
     ibuf += sizeof( short );
     if (( vol = getvolbyvid( vid )) == NULL ) {
-       *rbuflen = 0;
-       return( AFPERR_PARAM );
+        *rbuflen = 0;
+        return( AFPERR_PARAM );
     }
 
     memcpy( &did, ibuf, sizeof( did ));
     ibuf += sizeof( int );
     if (( dir = dirsearch( vol, did )) == NULL ) {
-       *rbuflen = 0;
-       return( AFPERR_NOOBJ );
+        *rbuflen = 0;
+        return( AFPERR_NOOBJ );
     }
 
     if (( path = cname( vol, dir, &ibuf )) == NULL ) {
-       *rbuflen = 0;
-       return( AFPERR_NOOBJ );
+        *rbuflen = 0;
+        return( AFPERR_NOOBJ );
     }
     if ( *path != '\0' ) {
-       *rbuflen = 0;
-       return( AFPERR_BITMAP );
+        *rbuflen = 0;
+        return( AFPERR_BITMAP );
     }
 
     vi.in_size = 0;
     vi.out_size = *rbuflen;
     vi.out = rbuf;
     if ( pioctl( ".", VIOCGETAL, &vi, 1 ) < 0 ) {
-       *rbuflen = 0;
-       return( AFPERR_PARAM );
+        *rbuflen = 0;
+        return( AFPERR_PARAM );
     }
     *rbuflen = strlen( vi.out ) + 1;
     return( AFP_OK );
@@ -124,26 +124,26 @@ afp_getdiracl(obj, ibuf, ibuflen, rbuf, rbuflen )
  * estimate permission, a la mdw.
  */
 afsmode( path, ma, dir )
-    char               *path;
-    struct maccess     *ma;
-    struct dir         *dir;
+char           *path;
+struct maccess *ma;
+struct dir             *dir;
 {
     struct ViceIoctl   vi;
     char               buf[ 1024 ];
 
     if (( dir->d_flags & DIRF_FSMASK ) == DIRF_NOFS ) {
-       vi.in_size = 0;
-       vi.out_size = sizeof( buf );
-       vi.out = buf;
-       if ( pioctl( path, VIOCGETAL, &vi, 1 ) < 0 ) {
-           dir->d_flags |= DIRF_UFS;
-       } else {
-           dir->d_flags |= DIRF_AFS;
-       }
+        vi.in_size = 0;
+        vi.out_size = sizeof( buf );
+        vi.out = buf;
+        if ( pioctl( path, VIOCGETAL, &vi, 1 ) < 0 ) {
+            dir->d_flags |= DIRF_UFS;
+        } else {
+            dir->d_flags |= DIRF_AFS;
+        }
     }
 
     if (( dir->d_flags & DIRF_FSMASK ) != DIRF_AFS ) {
-       return;
+        return;
     }
 
     accessmode( upath, &ma, dir );
@@ -156,9 +156,9 @@ extern struct dir   *curdir;
  * cmd | 0 | vid | did | pathtype | pathname | 0 | acl
  */
 afp_setdiracl(obj, ibuf, ibuflen, rbuf, rbuflen )
-    AFPObj      *obj;
-    char       *ibuf, *rbuf;
-    int                ibuflen, *rbuflen;
+AFPObj      *obj;
+char   *ibuf, *rbuf;
+int            ibuflen, *rbuflen;
 {
     struct ViceIoctl   vi;
     struct vol         *vol;
@@ -173,28 +173,28 @@ afp_setdiracl(obj, ibuf, ibuflen, rbuf, rbuflen )
     memcpy( &vid, ibuf, sizeof( vid ));
     ibuf += sizeof( short );
     if (( vol = getvolbyvid( vid )) == NULL ) {
-       *rbuflen = 0;
-       return( AFPERR_PARAM );
+        *rbuflen = 0;
+        return( AFPERR_PARAM );
     }
 
     memcpy( &did, ibuf, sizeof( did ));
     ibuf += sizeof( int );
     if (( dir = dirsearch( vol, did )) == NULL ) {
-       *rbuflen = 0;
-       return( AFPERR_NOOBJ );
+        *rbuflen = 0;
+        return( AFPERR_NOOBJ );
     }
 
     if (( path = cname( vol, dir, &ibuf )) == NULL ) {
-       *rbuflen = 0;
-       return( AFPERR_NOOBJ );
+        *rbuflen = 0;
+        return( AFPERR_NOOBJ );
     }
     if ( *path != '\0' ) {
-       *rbuflen = 0;
-       return( AFPERR_BITMAP );
+        *rbuflen = 0;
+        return( AFPERR_BITMAP );
     }
 
     if ((int)ibuf & 1 ) {
-       ibuf++;
+        ibuf++;
     }
 
     vi.in_size = iend - ibuf;
@@ -202,12 +202,12 @@ afp_setdiracl(obj, ibuf, ibuflen, rbuf, rbuflen )
     vi.out_size = 0;
 
     if ( pioctl( ".", VIOCSETAL, &vi, 1 ) < 0 ) {
-       *rbuflen = 0;
-       return( AFPERR_PARAM );
+        *rbuflen = 0;
+        return( AFPERR_PARAM );
     }
     pioctl( ".AppleDouble", VIOCSETAL, &vi, 1 );
     if ( curdir->d_did  == DIRDID_ROOT ) {
-       pioctl( ".AppleDesktop", VIOCSETAL, &vi, 1 );
+        pioctl( ".AppleDesktop", VIOCSETAL, &vi, 1 );
     }
 
     return( AFP_OK );
@@ -225,9 +225,9 @@ extern C_Block              seskey;
 extern Key_schedule    seskeysched;
 
 afp_afschangepw(obj, ibuf, ibuflen, rbuf, rbuflen )
-    AFPObj      *obj;
-    char       *ibuf, *rbuf;
-    int                ibuflen, *rbuflen;
+AFPObj      *obj;
+char   *ibuf, *rbuf;
+int            ibuflen, *rbuflen;
 {
     char       name[ MAXKTCNAMELEN ], instance[ MAXKTCNAMELEN ];
     char       realm[ MAXKTCREALMLEN ];
@@ -246,30 +246,30 @@ afp_afschangepw(obj, ibuf, ibuflen, rbuf, rbuflen )
     ka_ParseLoginName( ibuf, name, instance, realm );
     ucase( realm );
     if ( *realm == '\0' ) {
-       if ( krb_get_lrealm( realm, 1 ) != KSUCCESS ) {
-           syslog( LOG_ERR, "krb_get_lrealm failed" );
-           return( AFPERR_BADUAM );
-       }
+        if ( krb_get_lrealm( realm, 1 ) != KSUCCESS ) {
+            syslog( LOG_ERR, "krb_get_lrealm failed" );
+            return( AFPERR_BADUAM );
+        }
     }
 
     if ( strlen( name ) < 2 || strlen( name ) > 18 ) {
-       return( AFPERR_PARAM );
+        return( AFPERR_PARAM );
     }
     ibuf += len;
 
     memcpy( &clen, ibuf, sizeof( clen ));
     clen = ntohs( clen );
     if ( clen % 8 != 0 ) {
-       return( AFPERR_PARAM );
+        return( AFPERR_PARAM );
     }
 
     ibuf += sizeof( short );
     pcbc_encrypt((C_Block *)ibuf, (C_Block *)ibuf,
-           clen, seskeysched, seskey, DES_DECRYPT );
+                 clen, seskeysched, seskey, DES_DECRYPT );
 
     len = (unsigned char) *ibuf++;
     if ( len > 8 ) {
-       return( AFPERR_PARAM );
+        return( AFPERR_PARAM );
     }
     memset( oldpw, 0, sizeof( oldpw ));
     memcpy( oldpw, ibuf, len );
@@ -278,7 +278,7 @@ afp_afschangepw(obj, ibuf, ibuflen, rbuf, rbuflen )
 
     len = (unsigned char) *ibuf++;
     if ( len > 8 ) {
-       return( AFPERR_PARAM );
+        return( AFPERR_PARAM );
     }
     memset( newpw, 0, sizeof( newpw ));
     memcpy( newpw, ibuf, len );
@@ -286,7 +286,7 @@ afp_afschangepw(obj, ibuf, ibuflen, rbuf, rbuflen )
     newpw[ len ] = '\0';
 
     syslog( LOG_INFO,
-       "changing password for <%s>.<%s>@<%s>", name, instance, realm );
+            "changing password for <%s>.<%s>@<%s>", name, instance, realm );
 
     ka_StringToKey( oldpw, realm, &oldkey );
     memset( oldpw, 0, sizeof( oldpw ));
@@ -296,25 +296,25 @@ afp_afschangepw(obj, ibuf, ibuflen, rbuf, rbuflen )
     rc = ka_GetAdminToken( name, instance, realm, &oldkey, 60, &adtok, 0 );
     memset( &oldkey, 0, sizeof( oldkey ));
     switch ( rc ) {
-       case 0:
-           break;
-       case KABADREQUEST:
-           memset( &newkey, 0, sizeof( newkey ));
-           return( AFPERR_NOTAUTH );
-       default:
-           memset( &newkey, 0, sizeof( newkey ));
-           return( AFPERR_BADUAM );
+    case 0:
+        break;
+    case KABADREQUEST:
+        memset( &newkey, 0, sizeof( newkey ));
+        return( AFPERR_NOTAUTH );
+    default:
+        memset( &newkey, 0, sizeof( newkey ));
+        return( AFPERR_BADUAM );
     }
     if ( ka_AuthServerConn( realm, KA_MAINTENANCE_SERVICE, &adtok, &conn )
-               != 0 ) {
-       memset( &newkey, 0, sizeof( newkey ));
-       return( AFPERR_BADUAM );
+            != 0 ) {
+        memset( &newkey, 0, sizeof( newkey ));
+        return( AFPERR_BADUAM );
     }
 
     rc = ka_ChangePassword( name, instance, conn, 0, &newkey );
     memset( &newkey, 0, sizeof( newkey ));
     if ( rc != 0 ) {
-       return( AFPERR_BADUAM );
+        return( AFPERR_BADUAM );
     }
 
     syslog( LOG_DEBUG, "password changed succeeded" );