All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] utils.py: default mode on mkdirhier
@ 2014-05-19 21:52 Peter Seebach
  2014-05-19 21:52 ` [PATCH 1/1] utils.py: default mode for mkdirhier Peter Seebach
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Seebach @ 2014-05-19 21:52 UTC (permalink / raw)
  To: bitbake-devel

It turns out that bb.utils.mkdirhier() is occasionally called with
widely varying umasks, including but not limited to 022, 002, or 0.
This can result in unpredictable directory permissions, depending on
which context you were in when a directory got made, and it can
also result in mode 777 directories, which are Probably Bad. (The
most obvious case involves packages-split being created by
accident with umask 0 in populate_packages, shortly before a later
attempt to create it with umask 022.)

I've done test builds with this modification, and nothing seemed to
go wrong. I used an optional argument, rather than just hard-coding
the 0755, because if I use an optional argument it will always
be right, but if I don't I'm sure it will turn out to break something.

The following changes since commit d150226d11d5f041f78c8c3ce4abc5465dbc81d8:

  fetch2/perforce: Ensure command has a default (2014-05-11 15:25:47 +0100)

are available in the git repository at:
  git://git.yoctoproject.org/poky-contrib seebs/mkdirhier
  http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=seebs/mkdirhier

Peter Seebach (1):
  utils.py: default mode for mkdirhier

 lib/bb/utils.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)



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

* [PATCH 1/1] utils.py: default mode for mkdirhier
  2014-05-19 21:52 [PATCH 0/1] utils.py: default mode on mkdirhier Peter Seebach
@ 2014-05-19 21:52 ` Peter Seebach
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Seebach @ 2014-05-19 21:52 UTC (permalink / raw)
  To: bitbake-devel

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(-)

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
-- 
1.7.1



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

end of thread, other threads:[~2014-05-19 21:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-19 21:52 [PATCH 0/1] utils.py: default mode on mkdirhier Peter Seebach
2014-05-19 21:52 ` [PATCH 1/1] utils.py: default mode for mkdirhier Peter Seebach

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.