Skip to content

Commit

Permalink
Makes directory rewrite abs. paths on the cmdline
Browse files Browse the repository at this point in the history
  • Loading branch information
remram44 committed Dec 18, 2014
1 parent caad73d commit f1d8677
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion reprounzip/reprounzip/unpackers/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
COMPAT_OK, COMPAT_NO, target_must_exist, shell_escape, load_config, \
select_installer, busybox_url, join_root, FileUploader, FileDownloader, \
get_runs
from reprounzip.utils import unicode_, iteritems, itervalues, \
from reprounzip.utils import unicode_, irange, iteritems, itervalues, \
make_dir_writable, rmtree_fixed, download_file


Expand Down Expand Up @@ -258,6 +258,23 @@ def directory_run(args):
# FIXME : Use exec -a or something if binary != argv[0]
if cmdline is None:
argv = run['argv']

# Rewrites command-line arguments that are absolute filenames
rewritten = False
for i in irange(len(argv)):
try:
p = Path(argv[i])
except UnicodeEncodeError:
continue
if p.is_absolute:
rp = join_root(root, p)
if (rp.exists() or
(len(rp.components) > 3 and rp.parent.exists())):
argv[i] = str(rp)
rewritten = True
if rewritten:
logging.warning("Rewrote command-line as: %s",
' '.join(shell_escape(a) for a in argv))
else:
argv = cmdline
cmd += ' '.join(shell_escape(a) for a in argv)
Expand Down

0 comments on commit f1d8677

Please sign in to comment.