Mr Arisawa,
Did you get any answers to this?
Peter

On Thu, 17 Dec 2015 at 13:06 arisawa <aris...@ar.aichi-u.ac.jp> wrote:

> Thanks for your replay.
> however I don’t understand the intention of the manual.
> real needs in exporting is to export some different directories.
> it is impossible to do so under current code.
> can anyone show an example that exports two or more directories?
>
> > 2015/12/17 20:40、Peter Hull <peterhul...@gmail.com> のメール:
> >
> > On Wed, Dec 16, 2015 at 11:31 PM, arisawa <aris...@ar.aichi-u.ac.jp>
> wrote:
> >> It seems cpu command is buggy in -P option.
> >> the sources of the problem is in command option -P of exportfs.
> >
> > I had a look at the manpage for exportfs(4), it says: "For a file to
> > be exported, all lines with a prefix + must match and all those with
> > prefix - must not match." (http://man.9front.org/4/exportfs)
> >
> > So isn't the original code correct according to the manpage? If any of
> > the regexps in 'include' fail to match, the function returns -1, then
> > if any in 'exclude' do match, -1 is returned.
> >
> >> patternfile sample
> >> + /usr/arisawa
> >> + /usr/glenda
> >> - /adm
> >> - /sys/log
> >> - /mail
> >> - /usr/.*
> >>
> > Is this sample invalid - no path could match /usr/arisawa and
> > /usr/glenda at the same time?
> >
> > Pete
>
> I said:
>
> > int
> > excludefile(char *path)
> > {
> >       Reprog **re;
> >       char *p;
> >
> >       if(*(path+1) == 0)
> >               p = "/";
> >       else
> >               p = path+1;
> >
> >       DEBUG(DFD, "checking %s\n", p);
> >       for(re = include; *re != nil; re++){
> > -             if(regexec(*re, p, nil, 0) != 1){
> > +             if(regexec(*re, p, nil, 0) == 1){
> >                       DEBUG(DFD, "excluded+ %s\n", p);
> > -                     return -1;
> > +                     return 0;
> >               }
> >       }
> >       for(re = exclude; *re != nil; re++){
> >               if(regexec(*re, p, nil, 0) == 1){
> >                       DEBUG(DFD, "excluded- %s\n", p);
> >                       return -1;
> >               }
> >       }
> >       return 0;
> > }
> >
> >
> > patternfile sample
> > + /usr/arisawa
> > + /usr/glenda
> > - /adm
> > - /sys/log
> > - /mail
> > - /usr/.*
>
> however this code has still a problem.
>
> trailing ‘/‘ is removed in p even if p is a directory.
> assume we have users:
> /usr/rob
> and
> /usr/robin
> then we cannot export only /usr/rob.
> if we wish control this problem, we need tailing ‘/‘ for directory.
> then the code should be
>
> excludefile(char *path)
> {
>         Reprog **re;
>         char *p,*s;
>         Dir *dir;
>
>         if(*(path+1) == 0)
>                 p = "/";
>         else
>                 p = path+1;
>
>         s = p + strlen(p) - 1; /* tail */
>         dir = dirstat(p);
>         /* should not be nil */
>         if((dir->mode)&DMDIR){
>                 /* we have room to append '/'
>                 *  look makepath() in exportfs.c */
>                 *++s = '/';
>                 *++s = 0;
>         }
>
>         DEBUG(DFD, "checking %s\n", p);
>         for(re = include; *re != nil; re++){
>                 if(regexec(*re, p, nil, 0) == 1){
>                         DEBUG(DFD, "excluded+ %s\n", p);
>                         return 0;
>                 }
>         }
>         for(re = exclude; *re != nil; re++){
>                 if(regexec(*re, p, nil, 0) == 1){
>                         DEBUG(DFD, "excluded- %s\n", p);
>                         return -1;
>                 }
>         }
>         return 0;
> }
>
> then patternfile sample become:
>
> + /usr/arisawa/.*
> + /usr/glenda/.*
> - /adm/
> - /sys/log/
> - /mail/
> - /usr/.+
>
> adding tailing ‘/‘ in p makes the pattern file incompatible to existing
> one.
> I don’t know it is better to do so.
>
>
>
>

Reply via email to