Reputation: 491
I'm trying to prefill env.password
using --initial-password-prompt
, but remote is throwing back some strangeness. Let's say that I'm trying to cat
a root-owned file as testuser, with 600 permissions on the file. I'm calling sudo('cat /home/testuser/test.txt')
, and getting this back:
[testuser@testserver] sudo: cat /home/testuser/test.txt
[testuser@testserver] out: cat: /home/testuser/test.txt: Permission denied
[testuser@testserver] out:
Fatal error: sudo() received nonzero return code 1 while executing!
Requested: cat /home/testuser/test.txt
Executed: sudo -S -p 'sudo password:' -u "testuser" /bin/bash -l -c "cat /home/testuser/test.txt"
Is that piping the prompt right back into the input? I tried using sudo()
with pty=False
to see if it was an issue with the pseudoterminal, but to no avail.
Here's the weird part: calling run('sudo cat /home/testuser/test.txt')
and invoking fab
without --initial-password-prompt
passes back a password prompt from remote, and on entering the password, everything works fine.
Naturally, running ssh -t testuser@testserver 'sudo cat /home/user/test.txt'
prompts for a password and returns the contents of the file correctly. Do I have an issue with my server's shell config, or is the issue with how I'm using sudo()
?
Down the line, I'm likely to set up a deploy user with no-password sudo
and restricted commands. That'll probably moot the issue, but I'd like to figure this one out if possible. I'm running an Ubuntu 14.10 VPS, in case that's relevant.
Upvotes: 3
Views: 265
Reputation: 491
Oh, my mistake. I had foolishly set env.sudo_user
to my deploy user testuser, thinking that it was specifying the invoking user on remote. In fact, it was specifying the target user, and I was attempting to sudo
into myself. Whoops.
Upvotes: 1