From: Constantin Musca <constantinx.musca@intel.com>
To: openembedded-core@lists.openembedded.org
Cc: Constantin Musca <constantinx.musca@intel.com>
Subject: [PATCH v4] patch.bbclass: increase security
Date: Fri, 14 Sep 2012 17:25:02 +0300 [thread overview]
Message-ID: <1347632702-16313-1-git-send-email-constantinx.musca@intel.com> (raw)
- 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>
---
meta/classes/patch.bbclass | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass
index d010438..ed12802 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"
--
1.7.9.5
next reply other threads:[~2012-09-14 15:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-14 14:25 Constantin Musca [this message]
2012-09-16 19:52 ` [PATCH v4] patch.bbclass: increase security Saul Wold
2012-09-16 20:04 ` Chris Larson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1347632702-16313-1-git-send-email-constantinx.musca@intel.com \
--to=constantinx.musca@intel.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.