Search code examples
mercurialmercurial-server

mercurial-server says: No section: 'paths' Must be run as the 'hg' user


I try to tune hg through this (official) tutorial: http://dev.lshift.net/paul/mercurial-server/docbook.html

when i try:

sudo -u hg /usr/share/mercurial-server/refresh-auth

it says:

No section: 'paths'
Must be run as the 'hg' user

So it is a problem

UPD:

way to resolve, and true tutorial for install mercurial-server:

on remote server:

0) save your repos to homedir
1) <username>@<remote_server>:$ sudo apt-get purge mercurial mercurial-server
2) <username>@<remote_server>:$ sudo userdel -r hg
3) <username>@<remote_server>:$ sudo rm -r /var/lib/mercurial-server
4) <username>@<remote_server>:$ sudo rm -r /etc/mercurial-server
5) <username>@<remote_server>:$ sudo rm -r /usr/share/mercurial-server
6) <username>@<remote_server>:$ sudo apt-get install mercurial mercurial-server
7) <username>@<remote_server>:$ exit

on localhost:

8) ssh -A <remote_hg_server_domain>

on remote server:

9) <username>@<remote_server>:$ ssh-add -L > id_rsa.pub
10) <username>@<remote_server>:$ sudo mkdir -p /etc/mercurial-server/keys/root/<username>
11) <username>@<remote_server>:$ sudo cp my-key /etc/mercurial-server/keys/root/<username>/localhost (if you work from local terminal)
12) <username>@<remote_server>:$ sudo -u hg /usr/share/mercurial-server/refresh-auth - OOPS

we get

Traceback (most recent call last):
  File "/usr/share/mercurial-server/refresh-auth", line 22, in <module>
    refreshauth.refreshAuth()
  File "/usr/share/mercurial-server/mercurialserver/refreshauth.py", line 49, in refreshAuth
    kf = open(ffn)
IOError: [Errno 13] Permission denied: '/etc/mercurial-server/keys/root/<username>/localhost'

resolving:

13) <username>@<remote_server>:$ sudo chmod 644 /etc/mercurial-server/keys/root/<username>/localhost
14) <username>@<remote_server>:$ sudo -u hg /usr/share/mercurial-server/refresh-auth
15) <username>@<remote_server>:$ sudo chmod 600 /etc/mercurial-server/keys/root/<username>/localhost

works good


Solution

  • The initial problem means you've got your mercurial-server installation into a confused state. After creating the "hg" user, the install scripts place a configuration file called ".mercurial-server" in its home directory. This file somehow got removed on your system - perhaps you created the "hg" user by hand? That's why deleting and reinstalling all fixed everything, because it ran the install scripts and created this file.

    The second problem was simply that the "hg" user was unable to read the "localhost" file you created. 777 gives write permission to all - never do that! 644 for files and 755 for directories will suffice. It looks like you have your "umask" set to an unusually restrictive mask.