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