All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] tools: buildman: prevent trying to use the working directory as build dorectory
@ 2017-07-05  7:34 Lothar Waßmann
  2017-07-13 19:09 ` Simon Glass
  0 siblings, 1 reply; 4+ messages in thread
From: Lothar Waßmann @ 2017-07-05  7:34 UTC (permalink / raw)
  To: u-boot

When the U-Boot base directory happens to have the same name as the
branch that buildman is directed to use via the '-b' option and no
output directory is specified with '-o', buildman happily starts
removing the whole U-Boot sources eventually only stopped with the
error message:
OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg

Add a check to the builderthread.Mkdir function to verify that the
path it tries to create does not match the current working
directory.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
 tools/buildman/builderthread.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py
index acaf500..3549029 100644
--- a/tools/buildman/builderthread.py
+++ b/tools/buildman/builderthread.py
@@ -7,6 +7,7 @@ import errno
 import glob
 import os
 import shutil
+import sys
 import threading
 
 import command
@@ -27,6 +28,9 @@ def Mkdir(dirname, parents = False):
             os.mkdir(dirname)
     except OSError as err:
         if err.errno == errno.EEXIST:
+            if os.path.realpath('.') == os.path.realpath(dirname):
+                print "Cannot create the current working directory '%s'!" % dirname
+                sys.exit(1)
             pass
         else:
             raise
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] tools: buildman: prevent trying to use the working directory as build dorectory
  2017-07-05  7:34 [U-Boot] [PATCH] tools: buildman: prevent trying to use the working directory as build dorectory Lothar Waßmann
@ 2017-07-13 19:09 ` Simon Glass
  2017-07-14  6:57   ` Lothar Waßmann
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Glass @ 2017-07-13 19:09 UTC (permalink / raw)
  To: u-boot

On 5 July 2017 at 01:34, Lothar Waßmann <LW@karo-electronics.de> wrote:
> When the U-Boot base directory happens to have the same name as the
> branch that buildman is directed to use via the '-b' option and no
> output directory is specified with '-o', buildman happily starts
> removing the whole U-Boot sources eventually only stopped with the
> error message:
> OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg
>
> Add a check to the builderthread.Mkdir function to verify that the
> path it tries to create does not match the current working
> directory.
>
> Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
> ---
>  tools/buildman/builderthread.py | 4 ++++
>  1 file changed, 4 insertions(+)

That's nasty, thanks for the fix.

But this is being done inside each thread so I'm not sure how this
will be reported, or whether buildman will stop correctly.

Can the check happen before the build even starts, perhaps? E,g, in builder.py?

Regards,
Simon

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] tools: buildman: prevent trying to use the working directory as build dorectory
  2017-07-13 19:09 ` Simon Glass
@ 2017-07-14  6:57   ` Lothar Waßmann
  2018-04-02  8:43     ` Simon Glass
  0 siblings, 1 reply; 4+ messages in thread
From: Lothar Waßmann @ 2017-07-14  6:57 UTC (permalink / raw)
  To: u-boot

Hi,

On Thu, 13 Jul 2017 13:09:58 -0600 Simon Glass wrote:
> On 5 July 2017 at 01:34, Lothar Waßmann <LW@karo-electronics.de> wrote:
> > When the U-Boot base directory happens to have the same name as the
> > branch that buildman is directed to use via the '-b' option and no
> > output directory is specified with '-o', buildman happily starts
> > removing the whole U-Boot sources eventually only stopped with the
> > error message:
> > OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg
> >
> > Add a check to the builderthread.Mkdir function to verify that the
> > path it tries to create does not match the current working
> > directory.
> >
> > Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
> > ---
> >  tools/buildman/builderthread.py | 4 ++++
> >  1 file changed, 4 insertions(+)
> 
> That's nasty, thanks for the fix.
> 
> But this is being done inside each thread so I'm not sure how this
> will be reported, or whether buildman will stop correctly.
> 
> Can the check happen before the build even starts, perhaps? E,g, in builder.py?
> 
I don't have the time to look deeper into this, perhaps someone more
involved with the builman scripts can have a look into this.


Lothar Waßmann

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] tools: buildman: prevent trying to use the working directory as build dorectory
  2017-07-14  6:57   ` Lothar Waßmann
@ 2018-04-02  8:43     ` Simon Glass
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Glass @ 2018-04-02  8:43 UTC (permalink / raw)
  To: u-boot

Hi Lothar,

On 14 July 2017 at 14:57, Lothar Waßmann <LW@karo-electronics.de> wrote:
> Hi,
>
> On Thu, 13 Jul 2017 13:09:58 -0600 Simon Glass wrote:
>> On 5 July 2017 at 01:34, Lothar Waßmann <LW@karo-electronics.de> wrote:
>> > When the U-Boot base directory happens to have the same name as the
>> > branch that buildman is directed to use via the '-b' option and no
>> > output directory is specified with '-o', buildman happily starts
>> > removing the whole U-Boot sources eventually only stopped with the
>> > error message:
>> > OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg
>> >
>> > Add a check to the builderthread.Mkdir function to verify that the
>> > path it tries to create does not match the current working
>> > directory.
>> >
>> > Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
>> > ---
>> >  tools/buildman/builderthread.py | 4 ++++
>> >  1 file changed, 4 insertions(+)
>>
>> That's nasty, thanks for the fix.
>>
>> But this is being done inside each thread so I'm not sure how this
>> will be reported, or whether buildman will stop correctly.
>>
>> Can the check happen before the build even starts, perhaps? E,g, in builder.py?
>>
> I don't have the time to look deeper into this, perhaps someone more
> involved with the builman scripts can have a look into this.

OK, I've updated this patch. In general my advice is to assume that no
one else has time either :-)

Regards,
Simon

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-02  8:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-05  7:34 [U-Boot] [PATCH] tools: buildman: prevent trying to use the working directory as build dorectory Lothar Waßmann
2017-07-13 19:09 ` Simon Glass
2017-07-14  6:57   ` Lothar Waßmann
2018-04-02  8:43     ` Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.