lelutin / puppet-spamassassin

Install and configure spamassassin either as a service (through spamd) or for use with applications like amavisd. This is a fork of https://bitbucket.org/wyrie/puppet-spamassassin
Other
2 stars 9 forks source link

fix an error when Razor is run as non-root #3

Closed tequeter closed 4 years ago

lelutin commented 4 years ago

hi there. it's been a good while since you submitted this and I still haven't replied.. so sorry about this :(

I'm trying to wrap my head around this PR and I'm still unable to do so.. (e.g. I can see that getting the error you described in the commit from razor would be problematic, but I don't understand how the solution can actually fix it)

Could you help me out with providing some more information about the context in which this is happening? e.g.:

cheers!

lelutin commented 4 years ago

Actually I've just run a bit of testing and from what I can see, puppet runs execs in the CWD that was set when the agent was started:

# pwd
/root
# puppet apply -e "exec { '/bin/pwd': logoutput => true }"
Notice: Compiled catalog for host123.example.com in environment production in 0.10 seconds
Notice: /Stage[main]/Main/Exec[/bin/pwd]/returns: /root
Notice: /Stage[main]/Main/Exec[/bin/pwd]/returns: executed successfully
Notice: Applied catalog in 0.60 seconds
# cd /home/
# puppet apply -e "exec { '/bin/pwd': logoutput => true }"
Notice: Compiled catalog for host123.example.com in environment production in 0.10 seconds
Notice: /Stage[main]/Main/Exec[/bin/pwd]/returns: /home
Notice: /Stage[main]/Main/Exec[/bin/pwd]/returns: executed successfully
Notice: Applied catalog in 0.38 seconds

and if running the puppet agent in a cronjob as root, cron sets the CWD to the user's homedir:

# crontab -e
... add this line to the end and save+quit:
* * * * * /bin/pwd > /tmp/cron_pwd
# [... wait for one minute]
# cat /tmp/cron_pwd 
/root

so then if puppet runs a non-root command from inside @/root@ it indeed doesn't really make sense.