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

狂风中的少年 提交于 2020-01-16 01:31:11

问题


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


回答1:


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.




回答2:


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):

mkdir /home/hg
chown -R hg:users /home/hg
chmod -R 700 /home/hg

Log on as the hg user

sudo -s -u hg

Make sure you're in hg's home directory:

cd

and run the initialisation script:

/usr/share/mercurial-server/init/hginit /usr/share/mercurial-server/

this will create the necessary files and directories under /home/hg and the refresh-auth command should now work.




回答3:


From the sudo man page:

-u user     The -u (user) option causes sudo to run the specified
            command as a user other than root.

So if you run sudo -u hg, that means "run the following command as the user named hg". Yep, that's how mercurial-server works:

...developers log in as the "hg" user when they connect to the repository host using SSH...

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 user hg.



来源:https://stackoverflow.com/questions/18901715/mercurial-server-says-no-section-paths-must-be-run-as-the-hg-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!