diff mbox

[OSSTEST] standalone-reset: use mkdir -p

Message ID 20170205173434.31894-1-wei.liu2@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Liu Feb. 5, 2017, 5:34 p.m. UTC
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 standalone-reset | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ian Jackson Feb. 6, 2017, 11:49 a.m. UTC | #1
Wei Liu writes ("[OSSTEST PATCH] standalone-reset: use mkdir -p"):
...
>  ensure_dir () {
>  	if test -d "$1"; then return; fi
> -	mkdir "$1"
> +	mkdir -p "$1"

This deliberately doesn't do this.  Otherwise wrong (or partially
missing) configuration can create strangely-named directories.

What missing parent directory did you want it to create ?

Ian.
Wei Liu Feb. 6, 2017, 12:10 p.m. UTC | #2
On Mon, Feb 06, 2017 at 11:49:23AM +0000, Ian Jackson wrote:
> Wei Liu writes ("[OSSTEST PATCH] standalone-reset: use mkdir -p"):
> ...
> >  ensure_dir () {
> >  	if test -d "$1"; then return; fi
> > -	mkdir "$1"
> > +	mkdir -p "$1"
> 
> This deliberately doesn't do this.  Otherwise wrong (or partially
> missing) configuration can create strangely-named directories.
> 
> What missing parent directory did you want it to create ?
> 

/tmp/wei/osstest/


> Ian.
Ian Jackson Feb. 6, 2017, 3:13 p.m. UTC | #3
Wei Liu writes ("Re: [OSSTEST PATCH] standalone-reset: use mkdir -p"):
> On Mon, Feb 06, 2017 at 11:49:23AM +0000, Ian Jackson wrote:
> > Wei Liu writes ("[OSSTEST PATCH] standalone-reset: use mkdir -p"):
> > ...
> > >  ensure_dir () {
> > >  	if test -d "$1"; then return; fi
> > > -	mkdir "$1"
> > > +	mkdir -p "$1"
> > 
> > This deliberately doesn't do this.  Otherwise wrong (or partially
> > missing) configuration can create strangely-named directories.
> > 
> > What missing parent directory did you want it to create ?
> 
> /tmp/wei/osstest/

I guess I mean, which configuration option ?  What was your
configuration ?  Did /tmp/wei exist ?

Ian.
Wei Liu Feb. 6, 2017, 3:37 p.m. UTC | #4
On Mon, Feb 06, 2017 at 03:13:17PM +0000, Ian Jackson wrote:
> Wei Liu writes ("Re: [OSSTEST PATCH] standalone-reset: use mkdir -p"):
> > On Mon, Feb 06, 2017 at 11:49:23AM +0000, Ian Jackson wrote:
> > > Wei Liu writes ("[OSSTEST PATCH] standalone-reset: use mkdir -p"):
> > > ...
> > > >  ensure_dir () {
> > > >  	if test -d "$1"; then return; fi
> > > > -	mkdir "$1"
> > > > +	mkdir -p "$1"
> > > 
> > > This deliberately doesn't do this.  Otherwise wrong (or partially
> > > missing) configuration can create strangely-named directories.
> > > 
> > > What missing parent directory did you want it to create ?
> > 
> > /tmp/wei/osstest/
> 
> I guess I mean, which configuration option ?  What was your
> configuration ?

tftptmp=`getconfig TftpTmpDir`
ensure_dir "$tftp$tftptmp"

And $tftp is set to /tmp/ in my standalone config.

>  Did /tmp/wei exist ?

No.

> 
> Ian.
Ian Jackson Feb. 6, 2017, 3:42 p.m. UTC | #5
Wei Liu writes ("Re: [OSSTEST PATCH] standalone-reset: use mkdir -p"):
> tftptmp=`getconfig TftpTmpDir`
> ensure_dir "$tftp$tftptmp"

OK.  I'm afraid I think if TftpTmpDir's parent does not exist, osstest
should not create it automatically.

> And $tftp is set to /tmp/ in my standalone config.

As an aside: this habit of using /tmp as a personal playground is a
really bad one.

It may be fine on your single-user workstation, but if it slips into
any code or config which you ship to anyone else, it is a security
problem.

You should probably create a ~/tmp.

Ian.
diff mbox

Patch

diff --git a/standalone-reset b/standalone-reset
index 69a3226..d3a8f0d 100755
--- a/standalone-reset
+++ b/standalone-reset
@@ -49,7 +49,7 @@  fi
 
 ensure_dir () {
 	if test -d "$1"; then return; fi
-	mkdir "$1"
+	mkdir -p "$1"
 }
 
 ensure_key () {