[Discuss] send email from script as non-root
David Kramer
david at thekramers.net
Sat Jan 23 16:39:08 EST 2021
As part of my home automation, I want a process on my server (which is
also my mail server) to send an email (actually an SMS throught he email
gateway). The process that needs to do it is not run as root though,
it's running as a mortal user. I've tried mail, sendmail, curl, etc and
they complain
send-mail: fatal: open /etc/postfix/main.cf: Permission denied
Can't send mail: sendmail process failed with error code 75
If I make /etc/postfix o+rx and make main.cf readable, it just fails on
some other file in that directory, and I feel this path is going in an
unsafe direction, so I made /etc/postfix 750 again.
I tried creating a script owned by root and setuid, and even then I got
the same error, which confused me. I put a "who am i" in the script and
it said it was running with david (maybe it doesn't show effective UID???).
I guess I could add something to sudoers, but before I get too deep into
this, are there better solutions for this that google isn't showing me?
Have you faced this before?
Thanks
More information about the Discuss
mailing list