1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-02-10 13:05:46 +01:00

Fix python 2.6 SyntaxError

Multiple context expressions are only supported since version 2.7.
It was introduced in commit f6f879d ("Fix potential shell injection
when running rpm2cpio").
This commit is contained in:
Marcus Huewe 2017-10-26 14:14:30 +02:00
parent b7d3ae992c
commit a884b58313

View File

@ -6697,19 +6697,21 @@ def unpack_srcrpm(srpm, dir, *files):
if os.path.isdir(dir): if os.path.isdir(dir):
os.chdir(dir) os.chdir(dir)
ret = -1 ret = -1
with open(srpm, 'r') as fsrpm, open(os.devnull, 'w') as devnull: with open(srpm, 'r') as fsrpm:
rpm2cpio_proc = subprocess.Popen(['rpm2cpio'], stdin=fsrpm, with open(os.devnull, 'w') as devnull:
stdout=subprocess.PIPE) rpm2cpio_proc = subprocess.Popen(['rpm2cpio'], stdin=fsrpm,
# XXX: shell injection is possible via the files parameter, but the stdout=subprocess.PIPE)
# current osc code does not use the files parameter. # XXX: shell injection is possible via the files parameter, but the
cpio_proc = subprocess.Popen(['cpio', '-i'] + list(files), # current osc code does not use the files parameter.
stdin=rpm2cpio_proc.stdout, stderr=devnull) cpio_proc = subprocess.Popen(['cpio', '-i'] + list(files),
rpm2cpio_proc.stdout.close() stdin=rpm2cpio_proc.stdout,
cpio_proc.communicate() stderr=devnull)
rpm2cpio_proc.wait() rpm2cpio_proc.stdout.close()
ret = rpm2cpio_proc.returncode cpio_proc.communicate()
if not ret: rpm2cpio_proc.wait()
ret = cpio_proc.returncode ret = rpm2cpio_proc.returncode
if not ret:
ret = cpio_proc.returncode
if ret != 0: if ret != 0:
print('error \'%s\' - cannot extract \'%s\'' % (ret, srpm), file=sys.stderr) print('error \'%s\' - cannot extract \'%s\'' % (ret, srpm), file=sys.stderr)
sys.exit(1) sys.exit(1)