summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConstantin Musca <constantinx.musca@intel.com>2012-09-14 17:25:02 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-09-14 17:05:04 +0100
commitfbe9fc4d5ece1e66b03b4c4bce9b7ffad3b5b138 (patch)
tree949bc6a30d0d68fb04f8774b2528c2296057f68a
parentb681b74624d1c8c4c98b2a121828e010fc5c3a25 (diff)
downloadopenembedded-core-fbe9fc4d5ece1e66b03b4c4bce9b7ffad3b5b138.tar.gz
openembedded-core-fbe9fc4d5ece1e66b03b4c4bce9b7ffad3b5b138.tar.bz2
openembedded-core-fbe9fc4d5ece1e66b03b4c4bce9b7ffad3b5b138.zip
patch.bbclass: increase security
- Use mkdtemp for generating temp dir names - Use bb.utils.remove for removing temp dirs - Add comment for explaining the "patch" workaround [YOCTO #3070] Signed-off-by: Constantin Musca <constantinx.musca@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/patch.bbclass16
1 files changed, 8 insertions, 8 deletions
diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass
index d01043807b..ed12802491 100644
--- a/meta/classes/patch.bbclass
+++ b/meta/classes/patch.bbclass
@@ -139,11 +139,11 @@ python patch_do_patch() {
path = os.getenv('PATH')
os.putenv('PATH', d.getVar('PATH', True))
- import shutil
- process_tmpdir = os.path.join('/tmp', str(os.getpid()))
- if os.path.exists(process_tmpdir):
- shutil.rmtree(process_tmpdir)
- os.makedirs(process_tmpdir)
+ # We must use one TMPDIR per process so that the "patch" processes
+ # don't generate the same temp file name.
+
+ import tempfile
+ process_tmpdir = tempfile.mkdtemp()
os.environ['TMPDIR'] = process_tmpdir
for patch in src_patches(d):
@@ -168,15 +168,15 @@ python patch_do_patch() {
try:
patchset.Import({"file":local, "strippath": parm['striplevel']}, True)
except Exception as exc:
- shutil.rmtree(process_tmpdir)
+ bb.utils.remove(process_tmpdir, True)
bb.fatal(str(exc))
try:
resolver.Resolve()
except bb.BBHandledException as e:
- shutil.rmtree(process_tmpdir)
+ bb.utils.remove(process_tmpdir, True)
bb.fatal(str(e))
- shutil.rmtree(process_tmpdir)
+ bb.utils.remove(process_tmpdir, True)
}
patch_do_patch[vardepsexclude] = "PATCHRESOLVE"