summaryrefslogtreecommitdiffstats
path: root/meta/classes/patch.bbclass
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:12:43 +0100
commitada2c27f751c6f9277787a5e774927bd38797706 (patch)
tree13c00bf3194181874eacafe8fbb4f5c26f4489b8 /meta/classes/patch.bbclass
parentc4a923bcb0194c05b14d40be7ad4ecd193eb7a69 (diff)
downloadpoky-ada2c27f751c6f9277787a5e774927bd38797706.tar.gz
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] (From OE-Core rev: fbe9fc4d5ece1e66b03b4c4bce9b7ffad3b5b138) Signed-off-by: Constantin Musca <constantinx.musca@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/patch.bbclass')
-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() {
139 path = os.getenv('PATH') 139 path = os.getenv('PATH')
140 os.putenv('PATH', d.getVar('PATH', True)) 140 os.putenv('PATH', d.getVar('PATH', True))
141 141
142 import shutil 142 # We must use one TMPDIR per process so that the "patch" processes
143 process_tmpdir = os.path.join('/tmp', str(os.getpid())) 143 # don't generate the same temp file name.
144 if os.path.exists(process_tmpdir): 144
145 shutil.rmtree(process_tmpdir) 145 import tempfile
146 os.makedirs(process_tmpdir) 146 process_tmpdir = tempfile.mkdtemp()
147 os.environ['TMPDIR'] = process_tmpdir 147 os.environ['TMPDIR'] = process_tmpdir
148 148
149 for patch in src_patches(d): 149 for patch in src_patches(d):
@@ -168,15 +168,15 @@ python patch_do_patch() {
168 try: 168 try:
169 patchset.Import({"file":local, "strippath": parm['striplevel']}, True) 169 patchset.Import({"file":local, "strippath": parm['striplevel']}, True)
170 except Exception as exc: 170 except Exception as exc:
171 shutil.rmtree(process_tmpdir) 171 bb.utils.remove(process_tmpdir, True)
172 bb.fatal(str(exc)) 172 bb.fatal(str(exc))
173 try: 173 try:
174 resolver.Resolve() 174 resolver.Resolve()
175 except bb.BBHandledException as e: 175 except bb.BBHandledException as e:
176 shutil.rmtree(process_tmpdir) 176 bb.utils.remove(process_tmpdir, True)
177 bb.fatal(str(e)) 177 bb.fatal(str(e))
178 178
179 shutil.rmtree(process_tmpdir) 179 bb.utils.remove(process_tmpdir, True)
180} 180}
181patch_do_patch[vardepsexclude] = "PATCHRESOLVE" 181patch_do_patch[vardepsexclude] = "PATCHRESOLVE"
182 182