X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Fporterbox%2Ffiles%2Fdd-schroot-cmd;h=41993b2c12cc09aef5513ad8d7b39b2b6a67f595;hb=d5ce68a830c42fd613e08e377ace6348a2799e9d;hp=598fb12589b5dc57f86aea508345482fa1c6b551;hpb=ca7e8f4cc9ea7cb01e332eb6f784b30b0a952594;p=mirror%2Fdsa-puppet.git diff --git a/modules/porterbox/files/dd-schroot-cmd b/modules/porterbox/files/dd-schroot-cmd index 598fb1258..41993b2c1 100755 --- a/modules/porterbox/files/dd-schroot-cmd +++ b/modules/porterbox/files/dd-schroot-cmd @@ -6,7 +6,7 @@ ## -# Copyright (c) 2013 Peter Palfrader +# Copyright (c) 2013, 2017 Peter Palfrader # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -177,9 +177,11 @@ class AptSchroot: self.apt_simulate_and_ask(['dist-upgrade']) def apt_install(self, packages): + packages = self.reject_invalid_packages(packages) self.apt_simulate_and_ask(['install', '--'] + packages) def apt_build_dep(self, packages, archonly=False): + packages = self.reject_invalid_packages(packages) cmd = (['--arch-only'] if archonly else []) + ['build-dep', '--'] self.apt_simulate_and_ask(cmd + packages) @@ -197,6 +199,21 @@ class AptSchroot: def secure_run(self, args, unshare=True): WrappedRunner(self.session, args, unshare) + @staticmethod + def reject_invalid_packages(pkgs): + """filter package names + + reject package names that start with . or /, as they are + not valid package names, but can be used to install local files + which we do not want. + """ + new_pkgs = [] + for p in pkgs: + if p.startswith('.') or p.startswith('/'): + die("invalid package name: %s"%(p,)) + new_pkgs.append(p) + return new_pkgs + parser = optparse.OptionParser() parser.set_usage("""%prog [options] -c [-y] --