4

I am trying to set up a hook to notify me about new commits via mail.

Because of the issue described in Mercurial hook not executing properly, I can't seem to get it running by simply adding the following to my .hg/hgrc, since the script wouldn't run:

[hooks]  
changegroup = /path/to/script

As a workaround, I added the hook in the hgweb.config where it runs as expected. Now since I'm pushing through HTTP, the actual user running the script is apache (as determined by running id from within the hook), which means that I get errors like

Not trusting file .hg/hgrc from untrusted user u, group g

I added

[trusted]  
users = u

but the same errors remain. What am I doing wrong? Am I understanding this completly wrong? Appreciate any help!

Community
  • 1
  • 1
jonny
  • 4,264
  • 4
  • 22
  • 29

1 Answers1

2

You should add both the hook and the trust blocks not in the hgweb.config but in a .hgrc file in the apache user's home directory. One doesn't usually think of system users having home directories, but they all do, and you can find in in /etc/password. It's often something like /var/www, so if you create a /var/www/.hgrc file, make sure it's owned by the Apache user, and add the hook and the trust you'll be good to go.

Ry4an Brase
  • 78,112
  • 7
  • 148
  • 169
  • You're totally right, putting it in the `hgweb.config` is as ugly as it can be, but it's still more local than it would be in `/var/www/.hgrc` which is why I'm preferring it. We now found the error to result from what appears to be a misconfiguration of the server, erroneously declaring /root to be the webserver's homedir which resulted in it failing to read the correct configuration file. The `trusted` configuration was therefore completely ignored. – jonny Mar 20 '11 at 21:57
  • Jonny, I see that a lot. I always put the absolute path to the hgweb.config file in the hgweb.cgi script -- counting on the webserver's current working dir breaks across CGI, FCGI, and WSGI and different servers. – Ry4an Brase Mar 21 '11 at 02:53