Store dose3 Packages and Sources in a secure way using tempfile

This commit is contained in:
Johannes 'josch' Schauer 2017-01-15 15:42:26 +01:00
parent e68e7e31e8
commit d6cd69e9d2

16
run.py
View file

@ -16,6 +16,8 @@ import subprocess
import yaml
import daklib_arch
import debarch
import tempfile
import os
abi_from_abitable = [row[0] for row in debarch._load_table('/usr/share/dpkg/abitable')]
abi_from_ostable = [row[0].split('-')[0] for row in debarch._load_table('/usr/share/dpkg/ostable')]
@ -55,20 +57,26 @@ def dpkg_arch_matches(arch, wildcard):
env={}) == 0
def dose_arch_matches(arch, wildcard):
with open("/tmp/sources", "w") as f:
f.write("""
f1 = tempfile.NamedTemporaryFile(mode='w', delete=False)
n1 = f1.name
f1.write("""
Package: foo
Architecture: %s
Version: 0.invalid.0
"""%(wildcard))
with open("/tmp/packages", "w") as f:
f.write("""
f1.close()
f2 = tempfile.NamedTemporaryFile(mode='w', delete=False)
n2 = f2.name
f2.write("""
Package: build-essential
Architecture: %s
Version: 0.invalid.0
"""%(arch))
f2.close()
data = subprocess.check_output(['dose-builddebcheck', '--deb-native-arch=%s'%arch,
'--successes', '/tmp/packages', '/tmp/sources'])
os.unlink(n1)
os.unlink(n2)
data = yaml.load(data, Loader=yaml.CBaseLoader)
return len(data['report']) == 1