From b29db956f345cab6331556dde97811257365123a Mon Sep 17 00:00:00 2001 From: didg Date: Tue, 15 Oct 2002 19:34:34 +0000 Subject: [PATCH] more AFP 3.0 changes --- etc/afpd/auth.c | 7 +++--- etc/afpd/directory.h | 3 ++- etc/afpd/enumerate.c | 54 ++++++++++++++++++++++++++++++++------------ 3 files changed, 45 insertions(+), 19 deletions(-) diff --git a/etc/afpd/auth.c b/etc/afpd/auth.c index e8343fab..7ab6db9a 100644 --- a/etc/afpd/auth.c +++ b/etc/afpd/auth.c @@ -1,5 +1,5 @@ /* - * $Id: auth.c,v 1.33 2002-10-12 16:42:31 didg Exp $ + * $Id: auth.c,v 1.34 2002-10-15 19:34:34 didg Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -298,14 +298,15 @@ static int login(AFPObj *obj, struct passwd *pwd, void (*logout)(void)) case 31: uam_afpserver_action(AFP_ENUMERATE_EXT2, UAM_AFPSERVER_POSTAUTH, afp_enumerate_ext2, NULL); case 30: + uam_afpserver_action(AFP_ENUMERATE_EXT, UAM_AFPSERVER_POSTAUTH, afp_enumerate_ext, NULL); uam_afpserver_action(AFP_BYTELOCK_EXT, UAM_AFPSERVER_POSTAUTH, afp_bytelock_ext, NULL); - /* enumerate_ext and catsearch_ext are using the same packet as no ext calls */ + /* catsearch_ext uses the same packet as catsearch FIXME double check this, it wasn't true for enue + enumerate_ext */ #ifdef WITH_CATSEARCH uam_afpserver_action(AFP_CATSEARCH_EXT, UAM_AFPSERVER_POSTAUTH, afp_catsearch, NULL); #endif uam_afpserver_action(AFP_GETSESSTOKEN, UAM_AFPSERVER_POSTAUTH, afp_getsession, NULL); uam_afpserver_action(AFP_DISCTOLDSESS, UAM_AFPSERVER_POSTAUTH, afp_disconnect, NULL); - uam_afpserver_action(AFP_ENUMERATE_EXT, UAM_AFPSERVER_POSTAUTH, afp_enumerate, NULL); uam_afpserver_action(AFP_READ_EXT, UAM_AFPSERVER_POSTAUTH, afp_read_ext, NULL); uam_afpserver_action(AFP_WRITE_EXT, UAM_AFPSERVER_POSTAUTH, afp_write_ext, NULL); break; diff --git a/etc/afpd/directory.h b/etc/afpd/directory.h index 8217fd30..80b73292 100644 --- a/etc/afpd/directory.h +++ b/etc/afpd/directory.h @@ -1,5 +1,5 @@ /* - * $Id: directory.h,v 1.6 2002-10-11 14:18:28 didg Exp $ + * $Id: directory.h,v 1.7 2002-10-15 19:34:34 didg Exp $ * * Copyright (c) 1990,1991 Regents of The University of Michigan. * All Rights Reserved. @@ -202,6 +202,7 @@ extern int afp_mapname __P((AFPObj *, char *, int, char *, int *)); /* from enumerate.c */ extern int afp_enumerate __P((AFPObj *, char *, unsigned int, char *, unsigned int *)); +extern int afp_enumerate_ext __P((AFPObj *, char *, unsigned int, char *, unsigned int *)); extern int afp_enumerate_ext2 __P((AFPObj *, char *, unsigned int, char *, unsigned int *)); extern int afp_catsearch __P((AFPObj *, char *, int, char *, int *)); diff --git a/etc/afpd/enumerate.c b/etc/afpd/enumerate.c index 66cfaa24..5a39943a 100644 --- a/etc/afpd/enumerate.c +++ b/etc/afpd/enumerate.c @@ -1,5 +1,5 @@ /* - * $Id: enumerate.c,v 1.24 2002-10-11 14:18:28 didg Exp $ + * $Id: enumerate.c,v 1.25 2002-10-15 19:34:34 didg Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -199,11 +199,11 @@ for_each_dirent(const struct vol *vol, char *name, dir_loop fn, void *data) } /* ----------------------------- */ -static int enumerate(obj, ibuf, ibuflen, rbuf, rbuflen, is64 ) +static int enumerate(obj, ibuf, ibuflen, rbuf, rbuflen, ext ) AFPObj *obj; char *ibuf, *rbuf; unsigned int ibuflen, *rbuflen; -int is64; +int ext; { static struct savedir sd = { 0, 0, 0, NULL, NULL, 0 }; struct vol *vol; @@ -215,7 +215,8 @@ int is64; u_int32_t sindex, maxsz, sz = 0; struct path *o_path; struct path s_path; - + int header; + if ( sd.sd_buflen == 0 ) { if (( sd.sd_buf = (char *)malloc( SDBUFBRK )) == NULL ) { LOG(log_error, logtype_afpd, "afp_enumerate: malloc: %s", strerror(errno) ); @@ -264,7 +265,7 @@ int is64; reqcnt = ntohs( reqcnt ); ibuf += sizeof( reqcnt ); - if (is64) { + if (ext == 2) { memcpy( &sindex, ibuf, sizeof( sindex )); sindex = ntohs( sindex ); ibuf += sizeof( sindex ); @@ -275,7 +276,7 @@ int is64; ibuf += sizeof( temp16 ); } - if (is64) { + if (ext == 2) { memcpy( &maxsz, ibuf, sizeof( maxsz )); maxsz = ntohs( maxsz ); ibuf += sizeof( maxsz ); @@ -286,6 +287,9 @@ int is64; ibuf += sizeof( temp16 ); } + header = (ext)?4:2; + header *=sizeof( u_char ); + maxsz = min(maxsz, *rbuflen); if (( o_path = cname( vol, dir, &ibuf )) == NULL) { @@ -299,7 +303,7 @@ int is64; } data = rbuf + 3 * sizeof( u_int16_t ); - sz = 3 * sizeof( u_int16_t ); + sz = 3 * sizeof( u_int16_t ); /* fbitmap, dbitmap, reqcount */ /* * Read the directory into a pre-malloced buffer, stored @@ -425,7 +429,7 @@ int is64; } if (( ret = getdirparams(vol, dbitmap, &s_path, dir, - data + 2 * sizeof( u_char ), &esz )) != AFP_OK ) { + data + header , &esz )) != AFP_OK ) { *rbuflen = 0; return( ret ); } @@ -437,7 +441,7 @@ int is64; } s_path.m_name = utompath(vol, s_path.u_name); if (( ret = getfilparams(vol, fbitmap, &s_path, curdir, - data + 2 * sizeof( u_char ), &esz )) != AFP_OK ) { + data + header , &esz )) != AFP_OK ) { *rbuflen = 0; return( ret ); } @@ -447,15 +451,15 @@ int is64; * Make sure entry is an even length, possibly with a null * byte on the end. */ - if ( esz & 1 ) { - *(data + 2 * sizeof( u_char ) + esz ) = '\0'; + if ( (esz + header) & 1 ) { + *(data + header + esz ) = '\0'; esz++; } /* * Check if we've exceeded the size limit. */ - if ( maxsz < sz + esz + 2 * sizeof( u_char )) { + if ( maxsz < sz + esz + header) { if (first) { /* maxsz can't hold a single reply */ *rbuflen = 0; return AFPERR_PARAM; @@ -467,9 +471,20 @@ int is64; if (first) first = 0; - sz += esz + 2 * sizeof( u_char ); - *data++ = esz + 2 * sizeof( u_char ); + sz += esz + header; + if (ext) { + temp16 = htons( esz + header ); + memcpy( data, &temp16, sizeof( temp16 )); + data += sizeof(temp16); + } + else { + *data++ = esz + header; + } + *data++ = S_ISDIR(s_path.st.st_mode) ? FILDIRBIT_ISDIR : FILDIRBIT_ISFILE; + if (ext) { + *data++ = 0; + } data += esz; actcnt++; sd.sd_last += len + 1; @@ -508,7 +523,7 @@ unsigned int ibuflen, *rbuflen; } /* ----------------------------- */ -int afp_enumerate_ext2(obj, ibuf, ibuflen, rbuf, rbuflen ) +int afp_enumerate_ext(obj, ibuf, ibuflen, rbuf, rbuflen ) AFPObj *obj; char *ibuf, *rbuf; unsigned int ibuflen, *rbuflen; @@ -516,3 +531,12 @@ unsigned int ibuflen, *rbuflen; return enumerate(obj, ibuf,ibuflen ,rbuf,rbuflen , 1); } +/* ----------------------------- */ +int afp_enumerate_ext2(obj, ibuf, ibuflen, rbuf, rbuflen ) +AFPObj *obj; +char *ibuf, *rbuf; +unsigned int ibuflen, *rbuflen; +{ + return enumerate(obj, ibuf,ibuflen ,rbuf,rbuflen , 2); +} + -- 2.39.2