Dear Michael,
unfortunately, Google Groups didn't want me to get your message by
mail, so I only found it in the forums now. Furthermore, since
Google Groups don't expose the message ID, I cannot properly reply
to your message.
Anyway, thank you for your reply on 15 October:
https://groups.google.com/forum/?fromgroups=#!topic/ansible-project/ccZ72NSJr2Q
Let me pick up your points:
1. Your first sentence is incomplete, but I think I know what you
were trying to say. Yes, indeed, you would be running the
temporary Python script from sudo, which is almost as permissive
as allow sudo to invoke a shell, and I can imagine that even
passing sudo to subprocess.Popen wouldn't work because the script
might need root rights to check for existence or absence of
a file (command module), at the very least the raw module should
do what I want:
-m raw -a '/usr/sbin/apt-get update' --sudo
I don't really need to be able to use --sudo and would be happy
to run
-m raw -a '/usr/bin/sudo apt-get update'
instead, but it does seem to me like there's also a shell
invoked.
2. This brings me to the second point: you do not need a shell to
execute scripts on Unix according to the interpreter line
("shebang line"). This is a function of the linker. You can just
call the script directly and it will be executed using Python.
The shell is *not* needed.
The reason why I think the shell should thus not be invoked is
simply a question of overhead. Your approach will use more memory
and take longer.
3. It's true that recent desktop-oriented Linux distributions have
turned sudo into an all-purpose setuid wrapper. However, this is
not what it was designed for. If a user may use sudo to gain root
access for anything, you might just as well provide a setuid
shell. In my experience, it's better to disable the root account,
force all administration through sudo, disable direct execution
of a shell, and spend some time to configure and maintain the set
of allowed commands. This gives you some poor-man's-auditing, can
be used to ensure policy and serves as a safety belt.
There is no reason that ansible needs to be able to do everything
as root on the target system when an adequate sudo policy is in
place.
It's sad that you rule out my use-case.
Thanks,
"menschen, welche rasch feuer fangen,
werden schnell kalt und sind daher im ganzen unzuverlässig."
- friedrich nietzsche
spamtraps:
madduc...@madduck.net