Alex Rivera | Logout

HgWebDir push permission denied error

Asked 2010-04-19T22:12:08.833
11

I have a new Fedora 12 server that I am attempting to set up Mercurial on. I have yum installed mercurial, and most things seem to work fine. However, after setting up hgwebdir.cgi through apache, I am unable to do an hg push to the only repo currently being hosted. The error I get back is:

searching for changes
abort: HTTP Error 500: Permission denied: .hg/store/lock

httpd is running as user apache

UID        PID  PPID  C STIME TTY          TIME CMD
root      1691     1  0 13:19 ?        00:00:00 /usr/sbin/httpd
apache    1694  1691  0 13:19 ?        00:00:00 /usr/sbin/httpd
apache    1695  1691  0 13:19 ?        00:00:00 /usr/sbin/httpd
apache    1696  1691  0 13:19 ?        00:00:00 /usr/sbin/httpd
apache    1697  1691  0 13:19 ?        00:00:00 /usr/sbin/httpd
apache    1698  1691  0 13:19 ?        00:00:00 /usr/sbin/httpd
apache    1699  1691  0 13:19 ?        00:00:00 /usr/sbin/httpd
apache    1700  1691  0 13:19 ?        00:00:00 /usr/sbin/httpd
apache    1701  1691  0 13:19 ?        00:00:00 /usr/sbin/httpd

and I set permissions so that the apache user owns the whole repo and everything. In a last ditch attempt, I even made the repo globally writable.

[root@builds .hg]# ll
total 424K
drwxrwxrwx.  3 apache apache 4.0K 2010-04-19 14:43 .
drwxrwxrwx. 19 apache apache 4.0K 2010-04-15 13:33 ..
-rw-rw-rw-.  2 apache apache   57 2010-04-13 11:42 00changelog.i
-rw-rw-rw-.  1 apache apache   93 2010-04-16 15:33 branchheads.cache
-rw-rw-rw-.  1 apache apache 192K 2010-04-15 13:33 dirstate
-rw-r--r--.  1 apache apache  156 2010-04-19 14:43 hgrc
-rw-rw-rw-.  1 apache apache   42 2010-04-15 13:33 last-message.txt
-rw-rw-rw-.  2 apache apache   23 2010-04-13 11:42 requires
drwxrwxrwx.  4 apache apache 4.0K 2010-04-19 11:26 store
-rw-rw-rw-.  1 apache apache   45 2010-04-14 14:08 tags.cache
-rw-rw-rw-.  1 apache apache    7 2010-04-16 15:33 undo.branch
-rw-rw-rw
Edit
Report

3 Answers

15

For me it was the permissions were set wrong on the server. A chown -R www-data /path/to/repo (on the server) fixed it all up for me... maybe this is different for you. Good luck.

answered 2010-12-19T04:23:30.510
11

I had a similar problem on Ubuntu. The problem stopped when I loosened the permissions on the .hg directory.

I did a chmod -R 777 .hg from the repo directory. After that, everything worked. I still need to play around to find the minimally permissive option that permits pushes, but this works on our internal dev server.

answered 2010-11-29T13:18:06.607
4

Instead of 777, with the webserver running under the group apache, and your repositories in /opt/hg:

Execute sudo chown :apache /opt/hg -R to add the repositories to the apache group and sudo chmod g+w /opt/hg -R to give write access to the group. This way you just give enough permissions.

BTW under Ubuntu the apache process runs under www-data instead of apache.

answered 2011-09-29T14:26:42.470

Your Answer