1
2
I'd like to have an hg hook that sends email using a gmail account. Obviously I don't want anyone to be able read the email-sending script except me or root, since it has a password in, so here's what I've tried:
-rwsr-xr-x 1 james james 58 Feb 18 12:05 incoming.email.sh
-rwx--x--x 1 james james 262 Feb 18 12:04 send-incoming-email.sh
where incoming.email.sh
is the file executed as the hook:
#! /bin/bash
/path/to/send-incoming-email.sh
However, when I try to run as another user I get the error:
/bin/bash: /path/to/send-incoming-email.sh: Permission denied
The send-incoming-email.sh
file works fine when I run as myself.
Is what I'm trying to do possible, or will setuid not propagate to commands executed from a shell script?
System is Ubuntu 10.04.2 LTS.
setuid(geteuid())
is needed, it seems. – user1686 – 2011-02-18T14:31:34.527Quite correct, good catch! Edited to reflect that. – Jeremy Sturdivant – 2011-02-18T14:39:03.967
I still get permission denied when I run as another user:
/bin/bash: /path/to/send-incoming-email.sh: Permission denied
(permissions:-rwsr-xr-x 1 james james 7227 Feb 18 16:45 incoming.email
) – James – 2011-02-18T16:48:58.013To clarify, you're running incoming.email from another user, and that message results? Try running "id" instead of the incoming email script to test the setuid operation, and make sure the incoming email script works from your user directly still. – Jeremy Sturdivant – 2011-02-21T17:52:49.220