Skip to content

Commit

Permalink
[varnish] fix varnishadm subp call with sudo
Browse files Browse the repository at this point in the history
When calling subprocess with an argv-like array, argv[0] needs to
be the program to execute and not a sequence of programs like
`sudo someprogram`.

Otherwise this results in:
`OSError: [Errno 2] No such file or directory` when trying to find
the `sudo someprogram` executable in the PATH.
  • Loading branch information
LeoCavaille committed Feb 20, 2015
1 parent b5b95ad commit 54a5387
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions checks.d/varnish.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ def check(self, instance):
varnishadm_path = instance.get('varnishadm')
if varnishadm_path:
secretfile_path = instance.get('secretfile', '/etc/varnish/secret')
varnishadm_path = 'sudo %s' % varnishadm_path
cmd = [varnishadm_path, '-S', secretfile_path, 'debug.health']
cmd = ['sudo', varnishadm_path, '-S', secretfile_path, 'debug.health']
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
output, _ = proc.communicate()
if output:
Expand Down

0 comments on commit 54a5387

Please sign in to comment.