From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 References: <73CCEA09-C492-439D-9E8A-AA2BA9CB93DB@ar.aichi-u.ac.jp> <5E232682-7ABD-4564-96C1-89B1540FC4E2@ar.aichi-u.ac.jp> In-Reply-To: <5E232682-7ABD-4564-96C1-89B1540FC4E2@ar.aichi-u.ac.jp> From: Peter Hull Date: Tue, 22 Dec 2015 09:25:10 +0000 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=047d7b3a839e395e280527792f2c Subject: Re: [9fans] bug in exportfs Topicbox-Message-UUID: 7ad746bc-ead9-11e9-9d60-3106f5b1d025 --047d7b3a839e395e280527792f2c Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Mr Arisawa, Did you get any answers to this? Peter On Thu, 17 Dec 2015 at 13:06 arisawa wrote: > Thanks for your replay. > however I don=E2=80=99t 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=E3=80=81Peter Hull =E3=81=AE= =E3=83=A1=E3=83=BC=E3=83=AB=EF=BC=9A > > > > On Wed, Dec 16, 2015 at 11:31 PM, arisawa > 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) =3D=3D 0) > > p =3D "/"; > > else > > p =3D path+1; > > > > DEBUG(DFD, "checking %s\n", p); > > for(re =3D include; *re !=3D nil; re++){ > > - if(regexec(*re, p, nil, 0) !=3D 1){ > > + if(regexec(*re, p, nil, 0) =3D=3D 1){ > > DEBUG(DFD, "excluded+ %s\n", p); > > - return -1; > > + return 0; > > } > > } > > for(re =3D exclude; *re !=3D nil; re++){ > > if(regexec(*re, p, nil, 0) =3D=3D 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 =E2=80=98/=E2=80=98 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 =E2=80=98/=E2=80=98 for = directory. > then the code should be > > excludefile(char *path) > { > Reprog **re; > char *p,*s; > Dir *dir; > > if(*(path+1) =3D=3D 0) > p =3D "/"; > else > p =3D path+1; > > s =3D p + strlen(p) - 1; /* tail */ > dir =3D dirstat(p); > /* should not be nil */ > if((dir->mode)&DMDIR){ > /* we have room to append '/' > * look makepath() in exportfs.c */ > *++s =3D '/'; > *++s =3D 0; > } > > DEBUG(DFD, "checking %s\n", p); > for(re =3D include; *re !=3D nil; re++){ > if(regexec(*re, p, nil, 0) =3D=3D 1){ > DEBUG(DFD, "excluded+ %s\n", p); > return 0; > } > } > for(re =3D exclude; *re !=3D nil; re++){ > if(regexec(*re, p, nil, 0) =3D=3D 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 =E2=80=98/=E2=80=98 in p makes the pattern file incompatib= le to existing > one. > I don=E2=80=99t know it is better to do so. > > > > --047d7b3a839e395e280527792f2c Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Mr Arisawa,
Did you get any answers to = this?
Peter


On Thu, 17 Dec 2015 at 13:06 arisawa <arisawa@ar.aichi-u.ac.jp> wrote:
Thanks for your replay.
however I don=E2=80=99t 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=E3=80=81Peter Hull <peterhull90@gmail.com> =E3=81=AE=E3=83= =A1=E3=83=BC=E3=83=AB=EF=BC=9A
>
> On Wed, Dec 16, 2015 at 11:31 PM, arisawa <arisawa@ar.aichi-u.ac.jp> wrot= e:
>> 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/exportf= s)
>
> So isn't the original code correct according to the manpage? If an= y 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)
> {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0Reprog **re;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0char *p;
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0if(*(path+1) =3D=3D 0)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0p =3D "/&qu= ot;;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0else
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0p =3D path+1; >
>=C2=A0 =C2=A0 =C2=A0 =C2=A0DEBUG(DFD, "checking %s\n", p); >=C2=A0 =C2=A0 =C2=A0 =C2=A0for(re =3D include; *re !=3D nil; re++){
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if(regexec(*re, p, ni= l, 0) !=3D 1){
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if(regexec(*re, p, ni= l, 0) =3D=3D 1){
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0DEBUG(DFD, "excluded+ %s\n", p);
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0return -1;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0return 0;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
>=C2=A0 =C2=A0 =C2=A0 =C2=A0}
>=C2=A0 =C2=A0 =C2=A0 =C2=A0for(re =3D exclude; *re !=3D nil; re++){
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if(regexec(*re, = p, nil, 0) =3D=3D 1){
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0DEBUG(DFD, "excluded- %s\n", p);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0return -1;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
>=C2=A0 =C2=A0 =C2=A0 =C2=A0}
>=C2=A0 =C2=A0 =C2=A0 =C2=A0return 0;
> }
>
>
> patternfile sample
> + /usr/arisawa
> + /usr/glenda
> - /adm
> - /sys/log
> - /mail
> - /usr/.*

however this code has still a problem.

trailing =E2=80=98/=E2=80=98 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 =E2=80=98/=E2=80=98 for di= rectory.
then the code should be

excludefile(char *path)
{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Reprog **re;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 char *p,*s;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Dir *dir;

=C2=A0 =C2=A0 =C2=A0 =C2=A0 if(*(path+1) =3D=3D 0)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 p =3D "/"= ;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 else
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 p =3D path+1;

=C2=A0 =C2=A0 =C2=A0 =C2=A0 s =3D p + strlen(p) - 1; /* tail */
=C2=A0 =C2=A0 =C2=A0 =C2=A0 dir =3D dirstat(p);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 /* should not be nil */
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if((dir->mode)&DMDIR){
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* we have room to = append '/'
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *=C2=A0 look makepa= th() in exportfs.c */
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *++s =3D '/'= ;;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *++s =3D 0;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }

=C2=A0 =C2=A0 =C2=A0 =C2=A0 DEBUG(DFD, "checking %s\n", p);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 for(re =3D include; *re !=3D nil; re++){
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if(regexec(*re, p, = nil, 0) =3D=3D 1){
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 DEBUG(DFD, "excluded+ %s\n", p);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 return 0;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 for(re =3D exclude; *re !=3D nil; re++){
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if(regexec(*re, p, = nil, 0) =3D=3D 1){
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 DEBUG(DFD, "excluded- %s\n", p);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 return -1;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return 0;
}

then patternfile sample become:

+ /usr/arisawa/.*
+ /usr/glenda/.*
- /adm/
- /sys/log/
- /mail/
- /usr/.+

adding tailing =E2=80=98/=E2=80=98 in p makes the pattern file incompatible= to existing one.
I don=E2=80=99t know it is better to do so.



--047d7b3a839e395e280527792f2c--