Mercurial:hgwebdir权限拒绝

2 投票
1 回答
1376 浏览
提问于 2025-04-16 02:09

昨天我设置了Apache来提供我的Mercurial代码库,并且一切都正常工作。然后我测试了一下把更改推送回这个代码库,结果出现了一个错误,现在每次我尝试任何操作时,这个错误都会出现——就连简单的获取请求也不例外!错误信息如下:

mod_wsgi (pid=1771): Target WSGI script '/var/hg/hgweb.wsgi' cannot be loaded as Python module.
mod_wsgi (pid=1771): Exception occurred processing WSGI script '/var/hg/hgweb.wsgi'.
Traceback (most recent call last):
  File "/var/hg/hgweb.wsgi", line 18, in ?
    application = hgwebdir(config)
  File "/usr/lib64/python2.4/site-packages/mercurial/hgweb/__init__.py", line 15, in hgwebdir
    return hgwebdir_mod.hgwebdir(*args, **kwargs)
  File "/usr/lib64/python2.4/site-packages/mercurial/hgweb/hgwebdir_mod.py", line 52, in __init__
    self.refresh()
  File "/usr/lib64/python2.4/site-packages/mercurial/hgweb/hgwebdir_mod.py", line 82, in refresh
    self.repos = findrepos(paths)
  File "/usr/lib64/python2.4/site-packages/mercurial/hgweb/hgwebdir_mod.py", line 36, in findrepos
    for path in util.walkrepos(roothead, followsym=True, recurse=recurse):
  File "/usr/lib64/python2.4/site-packages/mercurial/util.py", line 1164, in walkrepos
    for hgname in walkrepos(fname, True, seen_dirs):
  File "/usr/lib64/python2.4/site-packages/mercurial/util.py", line 1146, in walkrepos
    for root, dirs, files in os.walk(path, topdown=True, onerror=errhandler):
  File "/usr/lib64/python2.4/os.py", line 276, in walk
    onerror(err)
  File "/usr/lib64/python2.4/site-packages/mercurial/util.py", line 1127, in errhandler
    raise err
OSError: [Errno 13] Permission denied: './dev/fd'

我的代码库目录是由apache这个用户拥有的,也就是运行Apache的那个用户。我也不知道为什么会涉及到'./dev/fd'这个东西。我已经重启了服务器很多次,重新创建了代码库目录,但无论我怎么做,这个错误还是一直存在!我没有权限重启机器,所以这个办法行不通。但看起来系统现在处于一个很糟糕的状态,我不知道该怎么解决。任何帮助都非常感谢!

1 个回答

3

这其实是我自己配置出错了。为了不删掉这个问题,我决定把解决办法写在这里,以防将来有人遇到同样的问题。

这是我当时使用的 hgweb.config 文件:

[paths]
/ = /var/hg/repos/*

#[web]
style = gitweb
allow_archive = bz2 gz zip
maxchanges = 200
allow_push = *
push_ssl = false

这里有两个问题,一个是显而易见的。我把 [web] 这一部分给注释掉了,我想很多选项在 [paths] 这一部分是不适用的。而且,重新看了一遍 Hg 的文档后发现,push_ssl 这个设置不应该放在 hgweb.config 文件里,而是应该放在每个仓库的 .hg/hgrc 文件中(或者放在运行 apache 的用户的 ~/.hgrc 文件里)。修正了这些问题后,一切都正常运作了!

撰写回答