Patchwork [bitbake-devel,1/1] utils.py: default mode for mkdirhier

login
register
mail settings
Submitter Peter Seebach
Date May 19, 2014, 9:52 p.m.
Message ID <87695832bf6a443b530e9058f5c9cf208b276d8f.1400270358.git.peter.seebach@windriver.com>
Download mbox | patch
Permalink /patch/72385/
State New
Headers show

Comments

Peter Seebach - May 19, 2014, 9:52 p.m.
The default behavior of os.makedirs() is to create a directory
with mode 777 & ~umask. When populating packages, oe-core uses
a umask of 0, so that files and directories copied in from the
source tree will have the right modes, and that's reasonable,
but it can result in packages-split being created with mode 777,
which is not so reasonable.

Since mkdirhier is used for build system stuff, it is
pretty reasonable for it to assume that you don't want or need
world-writeable directories, so we add a default mode, allowing
a caller to override it if they really want to. Which they
don't.

Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
---
 lib/bb/utils.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Patch

diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 1be1874..cd16b3b 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -618,13 +618,13 @@  def prune_suffix(var, suffixes, d):
             return var.replace(suffix, "")
     return var
 
-def mkdirhier(directory):
+def mkdirhier(directory, mode = 0755):
     """Create a directory like 'mkdir -p', but does not complain if
     directory already exists like os.makedirs
     """
 
     try:
-        os.makedirs(directory)
+        os.makedirs(directory, mode)
     except OSError as e:
         if e.errno != errno.EEXIST:
             raise e