启动 pypi 服务器时出现"malformed htpasswd file"错误消息



启动pypi服务器时,我收到一条错误消息,上面写着"格式错误的htpasswd文件"。即使.htpasswd文件不存在,我也会收到错误消息。错误的原因是什么?

以下是整个Traceback:

C:Data>pypi-server -p 8080 -P packages.htaccess packages
Traceback (most recent call last):
  File "c:python27librunpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:python27librunpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:Python27Scriptspypi-server.exe__main__.py", line 9, in <module>
  File "c:python27libsite-packagespypiserver__main__.py", line 293, in main
    app = pypiserver.app(**vars(c))
  File "c:python27libsite-packagespypiserver__init__.py", line 124, in app
    config, packages = core.configure(**kwds)
  File "c:python27libsite-packagespypiservercore.py", line 47, in configure
    htPsswdFile = HtpasswdFile(c.password_file)
  File "c:python27libsite-packagespasslibapache.py", line 583, in __init__
    super(HtpasswdFile, self).__init__(path, **kwds)
  File "c:python27libsite-packagespasslibapache.py", line 166, in __init__
    self.load()
  File "c:python27libsite-packagespasslibapache.py", line 236, in load
    self._load_lines(fh)
  File "c:python27libsite-packagespasslibapache.py", line 261, in _load_lines
    key, value = parse(line, idx+1)
  File "c:python27libsite-packagespasslibapache.py", line 590, in _parse_record
    % lineno)
ValueError: malformed htpasswd file (error reading line 1)

我有以下文件夹结构:

C:Datapackages.htaccess 
C:Datapackages.htpasswd

.htaccess文件的内容是:

AuthName "Under Development"
AuthUserFile C:Datapackages.htpasswd
AuthType basic
Require valid-user

.htpasswd文件的内容是:

user:$apr1$zYBRb3n6$PBrNqfGoyb9ZQC5hGuRJN0

pypiserver不支持.htaccess文件;这是Apache独有的功能。它只是重用Apache中的CCD_ 2文件格式。

此外,htpasswd文件最好不要位于packages文件夹内,以免pypiserver错误地为其提供服务,从而泄露其内容。

因此,将htpasswd文件移动到父文件夹,删除点前缀(无需隐藏/特殊),并更改启动命令:

move packages.htpasswd .htpasswd
del packages.htaccess
pypiserver -p 8080 -P htpasswd packages

相关内容

  • 没有找到相关文章

最新更新