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