[PATCH 1 of 2 STABLE] tests-subrepo-git: make the "pwned" message output in a stable order

Danek Duvall danek.duvall at oracle.com
Tue May 31 12:57:07 EDT 2016


Kevin Bullock wrote:

> > diff --git a/tests/test-subrepo-git.t b/tests/test-subrepo-git.t
> > --- a/tests/test-subrepo-git.t
> > +++ b/tests/test-subrepo-git.t
> > @@ -1135,7 +1135,7 @@ make sure we show changed files, rather 
> > test for Git CVE-2016-3068
> >   $ hg init malicious-subrepository
> >   $ cd malicious-subrepository
> > -  $ echo "s = [git]ext::sh -c echo% pwned% >&2" > .hgsub
> > +  $ echo "s = [git]ext::sh -c echo% pwned% >pwned.txt" > .hgsub
> >   $ git init s
> >   Initialized empty Git repository in $TESTTMP/tc/malicious-subrepository/s/.git/
> >   $ cd s
> > @@ -1145,23 +1145,27 @@ test for Git CVE-2016-3068
> >   $ hg add .hgsub
> >   $ hg commit -m "add subrepo"
> >   $ cd ..
> > +  $ rm -f pwned.txt
> >   $ env -u GIT_ALLOW_PROTOCOL hg clone malicious-subrepository malicious-subrepository-protected
> >   Cloning into '$TESTTMP/tc/malicious-subrepository-protected/s'... (glob)
> >   fatal: transport 'ext' not allowed
> >   updating to branch default
> > -  cloning subrepo s from ext::sh -c echo% pwned% >&2
> > +  cloning subrepo s from ext::sh -c echo% pwned% >pwned.txt
> >   abort: git clone error 128 in s (in subrepo s)
> >   [255]
> > +  $ test -f pwned.txt && cat pwned.txt || true
> 
> Is this actually needed? Are there shells that wait to see if there's any
> output instead of opening the target file for writing right away?

That's there because Solaris cat and GNU cat have different error messages
if the file doesn't exist:

    $ cat nope
    cat: cannot open nope: No such file or directory
    $ gcat nope
    gcat: nope: No such file or directory

Also, the Solaris cat exit code is 2, and the GNU cat exit code is 1.
<headdesk/>

I suppose f could grow a "dump contents if it exists and exit 1 if not"
function.  My change to put this bit into a shell function didn't make it
in, and Yuya requested static content in the file, too, so I was planning a
follow-up, anyway.  Should I change the shell function into something in f?

Thanks,
Danek


More information about the Mercurial-devel mailing list