summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2012-06-16 14:55:28 +0200
committerhut <hut@lavabit.com>2012-06-16 14:55:28 +0200
commit542d3a2514e9d5ae6c59ab9a11e807864d4b2039 (patch)
tree079ca95b68d978939018b847647f3b1be58f5af5
parentf8dd9d50667a299edefc78f48888d6a32d9bfede (diff)
downloadranger-542d3a2514e9d5ae6c59ab9a11e807864d4b2039.tar.gz
ext.rifle: fix "r" flag in combination with pipes in commands
-rwxr-xr-xranger/ext/rifle.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py
index 1080ecec..debac786 100755
--- a/ranger/ext/rifle.py
+++ b/ranger/ext/rifle.py
@@ -227,8 +227,7 @@ class Rifle(object):
 
 	def _apply_flags(self, action, flags):
 		# FIXME: Flags do not work properly when pipes are in the command.
-		if 'r' in flags:
-			action = 'sudo ' + action
+		# NOTE: "r" flag is handled in execute()
 		if 't' in flags:
 			if 'TERMCMD' not in os.environ:
 				term = os.environ['TERM']
@@ -319,7 +318,11 @@ class Rifle(object):
 			command = self.hook_command_postprocessing(command)
 			self.hook_before_executing(command, self._mimetype, self._app_flags)
 			try:
-				p = Popen(command, env=self.hook_environment(os.environ), shell=True)
+				if 'r' in flags:
+					p = Popen(['sudo', '-E', 'su', '-mc', command],
+							env=self.hook_environment(os.environ), shell=False)
+				else:
+					p = Popen(command, env=self.hook_environment(os.environ), shell=True)
 				p.wait()
 			finally:
 				self.hook_after_executing(command, self._mimetype, self._app_flags)