]> arthur.barton.de Git - netatalk.git/blob - etc/afpd/filedir.c
missing include file
[netatalk.git] / etc / afpd / filedir.c
1 /*
2  * $Id: filedir.c,v 1.59 2009-10-16 00:15:53 didg Exp $
3  *
4  * Copyright (c) 1990,1993 Regents of The University of Michigan.
5  * All Rights Reserved.  See COPYRIGHT.
6  */
7
8 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif /* HAVE_CONFIG_H */
11
12 #include <stdio.h>
13 #include <stdlib.h>
14 /* STDC check */
15 #if STDC_HEADERS
16 #include <string.h>
17 #else /* STDC_HEADERS */
18 #ifndef HAVE_STRCHR
19 #define strchr index
20 #define strrchr index
21 #endif /* HAVE_STRCHR */
22 char *strchr (), *strrchr ();
23 #ifndef HAVE_MEMCPY
24 #define memcpy(d,s,n) bcopy ((s), (d), (n))
25 #define memmove(d,s,n) bcopy ((s), (d), (n))
26 #endif /* ! HAVE_MEMCPY */
27 #endif /* STDC_HEADERS */
28
29 #ifdef HAVE_STRINGS_H
30 #include <strings.h>
31 #endif
32 #include <dirent.h>
33 #include <errno.h>
34 #include <sys/param.h>
35
36 #include <atalk/adouble.h>
37 #include <atalk/vfs.h>
38 #include <atalk/afp.h>
39 #include <atalk/util.h>
40 #include <atalk/cnid.h>
41 #include <atalk/logger.h>
42 #include <atalk/unix.h>
43
44 #include "directory.h"
45 #include "desktop.h"
46 #include "volume.h"
47 #include "fork.h"
48 #include "file.h"
49 #include "globals.h"
50 #include "filedir.h"
51 #include "unix.h"
52
53 #ifdef DROPKLUDGE
54 int matchfile2dirperms(
55 /* Since it's kinda' big; I decided against an
56 inline function */
57     char        *upath,
58     struct vol  *vol,
59     int         did)
60 /* The below code changes the way file ownership is determined in the name of
61 fixing dropboxes.  It has known security problem.  See the netatalk FAQ for
62 more information */
63 {
64     struct stat st, sb;
65     struct dir  *dir;
66     char        *adpath;
67     uid_t       uid;
68     int         ret = AFP_OK;
69 #ifdef DEBUG
70     LOG(log_info, logtype_afpd, "begin matchfile2dirperms:");
71 #endif /* DEBUG */
72
73     if (stat(upath, &st ) < 0) {
74         LOG(log_error, logtype_afpd, "Could not stat %s: %s", upath, strerror(errno));
75         return AFPERR_NOOBJ ;
76     }
77
78     adpath = vol->vfs->ad_path( upath, ADFLAGS_HF );
79     /* FIXME dirsearch doesn't move cwd to did ! */
80     if (( dir = dirlookup( vol, did )) == NULL ) {
81         LOG(log_error, logtype_afpd, "matchfile2dirperms: Unable to get directory info.");
82         ret = AFPERR_NOOBJ;
83     }
84     else if (stat(".", &sb) < 0) {
85         LOG(log_error, logtype_afpd,
86             "matchfile2dirperms: Error checking directory \"%s\": %s",
87             dir->d_m_name, strerror(errno));
88         ret = AFPERR_NOOBJ;
89     }
90     else {
91         uid=geteuid();
92         if ( uid != sb.st_uid )
93         {
94             seteuid(0);
95             if (lchown(upath, sb.st_uid, sb.st_gid) < 0)
96             {
97                 LOG(log_error, logtype_afpd,
98                     "matchfile2dirperms(%s): Error changing owner/gid: %s",
99                     upath, strerror(errno));
100                 ret = AFPERR_ACCESS;
101             }
102             else if (chmod(upath,(st.st_mode&~default_options.umask)| S_IRGRP| S_IROTH) < 0)
103             {
104                 LOG(log_error, logtype_afpd,
105                     "matchfile2dirperms(%s): Error adding file read permissions: %s",
106                     upath, strerror(errno));
107                 ret = AFPERR_ACCESS;
108             }
109             else if (lchown(adpath, sb.st_uid, sb.st_gid) < 0)
110             {
111                 LOG(log_error, logtype_afpd,
112                     "matchfile2dirperms(%s): Error changing AppleDouble owner/gid: %s",
113                     adpath, strerror(errno));
114                 ret = AFPERR_ACCESS;
115             }
116             else if (chmod(adpath, (st.st_mode&~default_options.umask)| S_IRGRP| S_IROTH) < 0)
117             {
118                 LOG(log_error, logtype_afpd,
119                     "matchfile2dirperms(%s):  Error adding AD file read permissions: %s",
120                     adpath, strerror(errno));
121                 ret = AFPERR_ACCESS;
122             }
123             seteuid(uid); 
124         }
125     } /* end else if stat success */
126
127 #ifdef DEBUG
128     LOG(log_info, logtype_afpd, "end matchfile2dirperms:");
129 #endif /* DEBUG */
130     return ret;
131 }
132 #endif
133
134 int afp_getfildirparams(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t *rbuflen)
135 {
136     struct stat         *st;
137     struct vol          *vol;
138     struct dir          *dir;
139     u_int32_t           did;
140     int                 ret;
141     size_t              buflen;
142     u_int16_t           fbitmap, dbitmap, vid;
143     struct path         *s_path;
144
145 #ifdef DEBUG
146     LOG(log_info, logtype_afpd, "begin afp_getfildirparams:");
147 #endif /* DEBUG */
148
149     *rbuflen = 0;
150     ibuf += 2;
151
152     memcpy( &vid, ibuf, sizeof( vid ));
153     ibuf += sizeof( vid );
154     if (NULL == ( vol = getvolbyvid( vid )) ) {
155         /* was AFPERR_PARAM but it helps OS 10.3 when a volume has been removed
156          * from the list.
157          */ 
158         return( AFPERR_ACCESS );
159     }
160
161     memcpy( &did, ibuf, sizeof( did ));
162     ibuf += sizeof( did );
163
164     if (NULL == ( dir = dirlookup( vol, did )) ) {
165         return afp_errno;
166     }
167
168     memcpy( &fbitmap, ibuf, sizeof( fbitmap ));
169     fbitmap = ntohs( fbitmap );
170     ibuf += sizeof( fbitmap );
171     memcpy( &dbitmap, ibuf, sizeof( dbitmap ));
172     dbitmap = ntohs( dbitmap );
173     ibuf += sizeof( dbitmap );
174
175     if (NULL == ( s_path = cname( vol, dir, &ibuf )) ) {
176         return get_afp_errno(AFPERR_NOOBJ); 
177     }
178
179     st   = &s_path->st;
180     if (!s_path->st_valid) {
181         /* it's a dir and it should be there
182          * because we chdir in it in cname or
183          * it's curdir (maybe deleted, but then we can't know).
184          * So we need to try harder.
185          */
186         of_statdir(vol, s_path);
187     }
188     if ( s_path->st_errno != 0 ) {
189         return( AFPERR_NOOBJ );
190     }
191
192     buflen = 0;
193     if (S_ISDIR(st->st_mode)) {
194         if (dbitmap) {
195             dir = s_path->d_dir;
196             if (!dir) 
197                 return AFPERR_NOOBJ;
198
199             ret = getdirparams(vol, dbitmap, s_path, dir,
200                                  rbuf + 3 * sizeof( u_int16_t ), &buflen );
201             if (ret != AFP_OK )
202                 return( ret );
203         }
204         /* this is a directory */
205         *(rbuf + 2 * sizeof( u_int16_t )) = (char) FILDIRBIT_ISDIR;
206     } else {
207         if (fbitmap && AFP_OK != (ret = getfilparams(vol, fbitmap, s_path, curdir, 
208                                             rbuf + 3 * sizeof( u_int16_t ), &buflen )) ) {
209             return( ret );
210         }
211         /* this is a file */
212         *(rbuf + 2 * sizeof( u_int16_t )) = FILDIRBIT_ISFILE;
213     }
214     *rbuflen = buflen + 3 * sizeof( u_int16_t );
215     fbitmap = htons( fbitmap );
216     memcpy( rbuf, &fbitmap, sizeof( fbitmap ));
217     rbuf += sizeof( fbitmap );
218     dbitmap = htons( dbitmap );
219     memcpy( rbuf, &dbitmap, sizeof( dbitmap ));
220     rbuf += sizeof( dbitmap ) + sizeof( u_char );
221     *rbuf = 0;
222
223 #ifdef DEBUG
224     LOG(log_info, logtype_afpd, "end afp_getfildirparams:");
225 #endif /* DEBUG */
226
227     return( AFP_OK );
228 }
229
230 int afp_setfildirparams(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen)
231 {
232     struct stat *st;
233     struct vol  *vol;
234     struct dir  *dir;
235     struct path *path;
236     u_int16_t   vid, bitmap;
237     int         did, rc;
238
239 #ifdef DEBUG
240     LOG(log_info, logtype_afpd, "begin afp_setfildirparams:");
241 #endif /* DEBUG */
242
243     *rbuflen = 0;
244     ibuf += 2;
245     memcpy( &vid, ibuf, sizeof(vid));
246     ibuf += sizeof( vid );
247
248     if (NULL == ( vol = getvolbyvid( vid )) ) {
249         return( AFPERR_PARAM );
250     }
251
252     if (vol->v_flags & AFPVOL_RO)
253         return AFPERR_VLOCK;
254
255     memcpy( &did, ibuf, sizeof( did));
256     ibuf += sizeof( did);
257
258     if (NULL == ( dir = dirlookup( vol, did )) ) {
259         return afp_errno;    
260     }
261
262     memcpy( &bitmap, ibuf, sizeof( bitmap ));
263     bitmap = ntohs( bitmap );
264     ibuf += sizeof( bitmap );
265
266     if (NULL == ( path = cname( vol, dir, &ibuf ))) {
267         return get_afp_errno(AFPERR_NOOBJ); 
268     }
269
270     st   = &path->st;
271     if (!path->st_valid) {
272         /* it's a dir and it should be there
273          * because we chdir in it in cname
274          */
275         of_statdir(vol, path);
276     }
277
278     if ( path->st_errno != 0 ) {
279         return( AFPERR_NOOBJ );
280     }
281     /*
282      * If ibuf is odd, make it even.
283      */
284     if ((u_long)ibuf & 1 ) {
285         ibuf++;
286     }
287
288     if (S_ISDIR(st->st_mode)) {
289         rc = setdirparams(vol, path, bitmap, ibuf );
290     } else {
291         rc = setfilparams(vol, path, bitmap, ibuf );
292     }
293     if ( rc == AFP_OK ) {
294         setvoltime(obj, vol );
295     }
296
297 #ifdef DEBUG
298     LOG(log_info, logtype_afpd, "end afp_setfildirparams:");
299 #endif /* DEBUG */
300
301     return( rc );
302 }
303
304 /* -------------------------------------------- 
305    Factorise some checks on a pathname
306 */
307 int check_name(const struct vol *vol, char *name)
308 {
309     /* check for illegal characters in the unix filename */
310     if (!wincheck(vol, name))
311         return AFPERR_PARAM;
312
313     if ((vol->v_flags & AFPVOL_NOHEX) && strchr(name, '/'))
314         return AFPERR_PARAM;
315
316     if (!vol->vfs->vfs_validupath(vol, name)) {
317         LOG(log_info, logtype_afpd, "check_name: illegal name: '%s'", name);
318         return AFPERR_EXIST;
319     }
320
321     /* check for vetoed filenames */
322     if (veto_file(vol->v_veto, name))
323         return AFPERR_EXIST;
324     return 0;
325 }
326
327 /* ------------------------- 
328     move and rename sdir:oldname to curdir:newname in volume vol
329    
330     special care is needed for lock   
331 */
332 static int moveandrename(const struct vol *vol, struct dir *sdir, char *oldname, char *newname, int isdir)
333 {
334     char            *p;
335     char            *upath;
336     int             rc;
337     struct stat     *st, nst;
338     int             adflags;
339     struct adouble      ad;
340     struct adouble      *adp;
341     struct ofork        *opened = NULL;
342     struct path         path;
343     cnid_t      id;
344
345     ad_init(&ad, vol->v_adouble, vol->v_ad_options);
346     adp = &ad;
347     adflags = 0;
348     
349     if (!isdir) {
350         p = mtoupath(vol, oldname, sdir->d_did, utf8_encoding());
351         if (!p) { 
352             return AFPERR_PARAM; /* can't convert */
353         }
354         id = cnid_get(vol->v_cdb, sdir->d_did, p, strlen(p));
355         p = ctoupath( vol, sdir, oldname );
356         if (!p) { 
357             return AFPERR_PARAM; /* pathname too long */
358         }
359         path.st_valid = 0;
360         path.u_name = p;
361         if ((opened = of_findname(&path))) {
362             /* reuse struct adouble so it won't break locks */
363             adp = opened->of_ad;
364         }
365     }
366     else {
367         id = sdir->d_did; /* we already have the CNID */
368         p = ctoupath( vol, sdir->d_parent, oldname );
369         if (!p) {
370             return AFPERR_PARAM;
371         }
372         adflags = ADFLAGS_DIR;
373     }
374     /*
375      * p now points to the full pathname of the source fs object.
376      * 
377      * we are in the dest folder so we need to use p for ad_open
378     */
379     
380     if (!ad_metadata(p, adflags, adp)) {
381         u_int16_t bshort;
382
383         ad_getattr(adp, &bshort);
384         ad_close_metadata( adp);
385         if ((bshort & htons(ATTRBIT_NORENAME))) 
386             return(AFPERR_OLOCK);
387     }
388
389     if (NULL == (upath = mtoupath(vol, newname, curdir->d_did, utf8_encoding()))){ 
390         return AFPERR_PARAM;
391     }
392     path.u_name = upath;
393     st = &path.st;    
394     if (0 != (rc = check_name(vol, upath))) {
395             return  rc;
396     }
397
398     /* source == destination. we just silently accept this. */
399     if ((!isdir && curdir == sdir) || (isdir && curdir == sdir->d_parent)) {
400         if (strcmp(oldname, newname) == 0)
401             return AFP_OK;
402
403         if (stat(upath, st) == 0 || caseenumerate(vol, &path, curdir) == 0) {
404             if (!stat(p, &nst) && !(nst.st_dev == st->st_dev && nst.st_ino == st->st_ino) ) {
405                 /* not the same file */
406                 return AFPERR_EXIST;
407             }
408             errno = 0;
409         }
410     } else if (stat(upath, st ) == 0 || caseenumerate(vol, &path, curdir) == 0)
411         return AFPERR_EXIST;
412
413     if ( !isdir ) {
414         path.st_valid = 1;
415         path.st_errno = errno;
416         if (of_findname(&path)) {
417             rc = AFPERR_EXIST; /* was AFPERR_BUSY; */
418         } else {
419             rc = renamefile(vol, p, upath, newname, adp );
420             if (rc == AFP_OK)
421                 of_rename(vol, opened, sdir, oldname, curdir, newname);
422         }
423     } else {
424         rc = renamedir(vol, p, upath, sdir, curdir, newname);
425     }
426     if ( rc == AFP_OK && id ) {
427         /* renaming may have moved the file/dir across a filesystem */
428         if (stat(upath, st) < 0)
429             return AFPERR_MISC;
430
431         /* fix up the catalog entry */
432         cnid_update(vol->v_cdb, id, st, curdir->d_did, upath, strlen(upath));
433     }
434
435     return rc;
436 }
437
438 /* -------------------------------------------- */
439 int afp_rename(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen)
440 {
441     struct vol  *vol;
442     struct dir  *sdir;
443     char        *oldname, *newname;
444     struct path *path;
445     u_int32_t   did;
446     int         plen;
447     u_int16_t   vid;
448     int         isdir = 0;
449     int         rc;
450 #ifdef DEBUG
451     LOG(log_info, logtype_afpd, "begin afp_rename:");
452 #endif /* DEBUG */
453
454     *rbuflen = 0;
455     ibuf += 2;
456
457     memcpy( &vid, ibuf, sizeof( vid ));
458     ibuf += sizeof( vid );
459     if (NULL == ( vol = getvolbyvid( vid )) ) {
460         return( AFPERR_PARAM );
461     }
462
463     if (vol->v_flags & AFPVOL_RO)
464         return AFPERR_VLOCK;
465
466     memcpy( &did, ibuf, sizeof( did ));
467     ibuf += sizeof( did );
468     if (NULL == ( sdir = dirlookup( vol, did )) ) {
469         return afp_errno;    
470     }
471
472     /* source pathname */
473     if (NULL == ( path = cname( vol, sdir, &ibuf )) ) {
474         return get_afp_errno(AFPERR_NOOBJ); 
475     }
476
477     sdir = curdir;
478     newname = obj->newtmp;
479     oldname = obj->oldtmp;
480     isdir = path_isadir(path);
481     if ( *path->m_name != '\0' ) {
482         strcpy(oldname, path->m_name); /* an extra copy for of_rename */
483         if (isdir) {
484             /* curdir parent dir, need to move sdir back */
485             sdir = path->d_dir;
486         }
487     }
488     else {
489         if ( sdir->d_parent == NULL ) { /* root directory */
490             return( AFPERR_NORENAME );
491         }
492         /* move to destination dir */
493         if ( movecwd( vol, sdir->d_parent ) < 0 ) {
494             return afp_errno;
495         }
496         strcpy(oldname, sdir->d_m_name);
497     }
498
499     /* another place where we know about the path type */
500     if ((plen = copy_path_name(vol, newname, ibuf)) < 0) {
501         return( AFPERR_PARAM );
502     }
503
504     if (!plen) {
505         return AFP_OK; /* newname == oldname same dir */
506     }
507     
508     rc = moveandrename(vol, sdir, oldname, newname, isdir);
509
510     if ( rc == AFP_OK ) {
511         setvoltime(obj, vol );
512     }
513
514 #ifdef DEBUG
515     LOG(log_info, logtype_afpd, "end afp_rename:");
516 #endif /* DEBUG */
517
518     return( rc );
519 }
520
521 /* ------------------------------- */
522 int afp_delete(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen)
523 {
524     struct vol          *vol;
525     struct dir          *dir;
526     struct path         *s_path;
527     char                *upath;
528     int                 did, rc;
529     u_int16_t           vid;
530
531 #ifdef DEBUG
532     LOG(log_info, logtype_afpd, "begin afp_delete:");
533 #endif /* DEBUG */ 
534
535     *rbuflen = 0;
536     ibuf += 2;
537
538     memcpy( &vid, ibuf, sizeof( vid ));
539     ibuf += sizeof( vid );
540     if (NULL == ( vol = getvolbyvid( vid )) ) {
541         return( AFPERR_PARAM );
542     }
543
544     if (vol->v_flags & AFPVOL_RO)
545         return AFPERR_VLOCK;
546
547     memcpy( &did, ibuf, sizeof( did ));
548     ibuf += sizeof( int );
549     if (NULL == ( dir = dirlookup( vol, did )) ) {
550         return afp_errno;    
551     }
552
553     if (NULL == ( s_path = cname( vol, dir, &ibuf )) ) {
554         return get_afp_errno(AFPERR_NOOBJ); 
555     }
556
557     upath = s_path->u_name;
558     if ( path_isadir( s_path) ) {
559         if (*s_path->m_name != '\0') {
560             rc = AFPERR_ACCESS;
561         }
562         else {
563             rc = deletecurdir( vol);
564         }
565     } else if (of_findname(s_path)) {
566         rc = AFPERR_BUSY;
567     } else {
568         rc = deletefile(vol, upath, 1);
569     }
570     if ( rc == AFP_OK ) {
571         curdir->offcnt--;
572         setvoltime(obj, vol );
573     }
574
575 #ifdef DEBUG
576     LOG(log_info, logtype_afpd, "end afp_delete:");
577 #endif /* DEBUG */
578
579     return( rc );
580 }
581 /* ------------------------ */
582 char *absupath(const struct vol *vol, struct dir *dir, char *u)
583 {
584     struct dir  *d;
585     static char path[ MAXPATHLEN + 1];
586     char        *p;
587     int         len;
588
589     if (u == NULL)
590         return NULL;
591         
592     p = path + sizeof( path ) - 1;
593     *p = '\0';
594     len = strlen( u );
595     p -= len;
596     memcpy( p, u, len );
597     if (dir) for ( d = dir; d->d_parent; d = d->d_parent ) {
598         u = d->d_u_name;
599         len = strlen( u );
600         if (p -len -1 < path) {
601             /* FIXME 
602                rather rare so LOG error and/or client message ?
603             */
604             return NULL;
605         }
606         *--p = '/';
607         p -= len;
608         memcpy( p, u, len );
609     }
610     len = strlen( vol->v_path );
611     if (p -len -1 < path) {
612         return NULL;
613     }
614     *--p = '/';
615     p -= len;
616     memcpy( p, vol->v_path, len );
617
618     return( p );
619 }
620
621 /* ------------------------
622  * FIXME dir could be NULL
623 */
624 char *ctoupath(const struct vol *vol, struct dir *dir, char *name)
625 {
626     return absupath(vol, dir, mtoupath(vol, name, dir->d_did, utf8_encoding()));
627 }
628
629 /* ------------------------- */
630 int afp_moveandrename(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen)
631 {
632     struct vol  *vol;
633     struct dir  *sdir, *ddir;
634     int         isdir;
635     char        *oldname, *newname;
636     struct path *path;
637     int         did;
638     int         pdid;
639     int         plen;
640     u_int16_t   vid;
641     int         rc;
642 #ifdef DROPKLUDGE
643     int         retvalue;
644 #endif /* DROPKLUDGE */
645
646 #ifdef DEBUG
647     LOG(log_info, logtype_afpd, "begin afp_moveandrename:");
648 #endif /* DEBUG */
649
650     *rbuflen = 0;
651     ibuf += 2;
652
653     memcpy( &vid, ibuf, sizeof( vid ));
654     ibuf += sizeof( vid );
655     if (NULL == ( vol = getvolbyvid( vid )) ) {
656         return( AFPERR_PARAM );
657     }
658
659     if (vol->v_flags & AFPVOL_RO)
660         return AFPERR_VLOCK;
661
662     /* source did followed by dest did */
663     memcpy( &did, ibuf, sizeof( did ));
664     ibuf += sizeof( int );
665     if (NULL == ( sdir = dirlookup( vol, did )) ) {
666         return afp_errno; /* was AFPERR_PARAM */
667     }
668
669     memcpy( &did, ibuf, sizeof( did ));
670     ibuf += sizeof( int );
671
672     /* source pathname */
673     if (NULL == ( path = cname( vol, sdir, &ibuf )) ) {
674         return get_afp_errno(AFPERR_NOOBJ); 
675     }
676
677     sdir = curdir;
678     newname = obj->newtmp;
679     oldname = obj->oldtmp;
680     
681     isdir = path_isadir(path);
682     if ( *path->m_name != '\0' ) {
683         if (isdir) {
684             sdir = path->d_dir;
685         }
686         strcpy(oldname, path->m_name); /* an extra copy for of_rename */
687     } else {
688         strcpy(oldname, sdir->d_m_name);
689     }
690
691     /* get the destination directory */
692     if (NULL == ( ddir = dirlookup( vol, did )) ) {
693         return afp_errno; /*  was AFPERR_PARAM */
694     }
695     if (NULL == ( path = cname( vol, ddir, &ibuf ))) {
696         return( AFPERR_NOOBJ );
697     }
698     pdid = curdir->d_did;
699     if ( *path->m_name != '\0' ) {
700         return path_error(path, AFPERR_NOOBJ);
701     }
702
703     /* one more place where we know about path type */
704     if ((plen = copy_path_name(vol, newname, ibuf)) < 0) {
705         return( AFPERR_PARAM );
706     }
707
708     if (!plen) {
709         strcpy(newname, oldname);
710     }
711
712     rc = moveandrename(vol, sdir, oldname, newname, isdir);
713
714     if ( rc == AFP_OK ) {
715         char *upath = mtoupath(vol, newname, pdid, utf8_encoding());
716         
717         if (NULL == upath) {
718             return AFPERR_PARAM;
719         }
720         curdir->offcnt++;
721         sdir->offcnt--;
722 #ifdef DROPKLUDGE
723         if (vol->v_flags & AFPVOL_DROPBOX) {
724             /* FIXME did is not always the source id */
725             if ((retvalue=matchfile2dirperms (upath, vol, did)) != AFP_OK) {
726                 return retvalue;
727             }
728         }
729         else
730 #endif /* DROPKLUDGE */
731             /* if unix priv don't try to match perm with dest folder */
732             if (!isdir && !vol_unix_priv(vol)) {
733                 int  admode = ad_mode("", 0777) | vol->v_fperm;
734
735                 setfilmode(upath, admode, NULL, vol->v_umask);
736                 vol->vfs->vfs_setfilmode(vol, upath, admode, NULL);
737             }
738         setvoltime(obj, vol );
739     }
740
741 #ifdef DEBUG
742     LOG(log_info, logtype_afpd, "end afp_moveandrename:");
743 #endif /* DEBUG */
744
745     return( rc );
746 }
747
748 int veto_file(const char*veto_str, const char*path)
749 /* given a veto_str like "abc/zxc/" and path "abc", return 1
750  * veto_str should be '/' delimited
751  * if path matches any one of the veto_str elements exactly, then 1 is returned
752  * otherwise, 0 is returned.
753  */
754 {
755     int i;      /* index to veto_str */
756     int j;      /* index to path */
757
758     if ((veto_str == NULL) || (path == NULL))
759         return 0;
760
761     for(i=0, j=0; veto_str[i] != '\0'; i++) {
762         if (veto_str[i] == '/') {
763             if ((j>0) && (path[j] == '\0')) {
764                 LOG(log_info, logtype_afpd, "vetoed file:'%s'", path);
765                 return 1;
766             }
767             j = 0;
768         } else {
769             if (veto_str[i] != path[j]) {
770                 while ((veto_str[i] != '/')
771                         && (veto_str[i] != '\0'))
772                     i++;
773                 j = 0;
774                 continue;
775             }
776             j++;
777         }
778     }
779     return 0;
780 }
781