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
From the sudo man page:
So if you run
sudo -u hg
, that means "run the following command as the user namedhg
". Yep, that's how mercurial-server works:It's unfortunate that the "step by step" instructions don't tell you do create a user named
hg
, but that's what you need to do. I have no idea what permissions that user needs to have.Alternately, you could try running
sudo /usr/share/mercurial-server/refresh-auth
, and see if that gives access to the proper users, as it's supposed to. But that will probably break things later, since other parts of mercurial-server will rely on the userhg
.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.
Gentoo users can get the same error. I found the following useful recommendations here:
Check
/home
for/home/hg
, if it doesn't exist you can create it (under root):Log on as the hg user
Make sure you're in hg's home directory:
and run the initialisation script:
this will create the necessary files and directories under
/home/hg
and therefresh-auth
command should now work.