[Discuss] send email from script as non-root

Jerry Feldman gaf.linux at gmail.com
Sat Jan 23 17:57:57 EST 2021


Done that many times from Blu
usin mail and mailx

Everything in postfix is 644
And postfix is 733
All owned by root
Check entries in /var/spool/mail
Should all be group mail and owned by individual owners

--
Jerry Feldman <gaf.linux at gmail.com>
Boston Linux and Unix http://www.blu.org
PGP key id: 6F6BB6E7
PGP Key fingerprint: 0EDC 2FF5 53A6 8EED 84D1  3050 5715 B88D 6F6
B B6E7

On Sat, Jan 23, 2021, 4:41 PM David Kramer <david at thekramers.net> wrote:

> 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
>
> _______________________________________________
> Discuss mailing list
> Discuss at lists.blu.org
> http://lists.blu.org/mailman/listinfo/discuss
>


More information about the Discuss mailing list