1

我支持一个 http 代理,并且想使用sudo port selfupdate. 但它总是失败并显示以下输出:

$ sudo port -d selfupdate
DEBUG: Copying /Users/simon/Library/Preferences/com.apple.dt.Xcode.plist to /opt/local/var/macports/home/Library/Preferences
DEBUG: MacPorts sources location: /opt/local/var/macports/sources/rsync.macports.org/release/tarballs
--->  Updating MacPorts base sources using rsync
rsync: getaddrinfo: rsync.macports.org 873: nodename nor servname provided, or not known
rsync error: error in socket IO (code 10) at /SourceCache/rsync/rsync-42/rsync/clientserver.c(105) [receiver=2.6.9]
Command failed: /usr/bin/rsync -rtzv --delete-after rsync://rsync.macports.org/release/tarballs/base.tar /opt/local/var/macports/sources/rsync.macports.org/release/tarballs
Exit code: 10
DEBUG: Error synchronizing MacPorts sources: command execution failed
    while executing
"macports::selfupdate [array get global_options] base_updated"
Error: /opt/local/bin/port: port selfupdate failed: Error synchronizing MacPorts sources: command execution failed

显然问题是rsync没有连接到服务器,所以我rsync单独尝试,它给了我类似的结果。

$ sudo /usr/bin/rsync -rtzvvv --delete-after rsync://rsync.macports.org/release/tarballs/base.tar /opt/local/var/macports/sources/rsync.macports.org/release/tarballs
opening tcp connection to rsync.macports.org port 873
rsync: getaddrinfo: rsync.macports.org 873: nodename nor servname provided, or not known
rsync error: error in socket IO (code 10) at /SourceCache/rsync/rsync-42/rsync/clientserver.c(105) [receiver=2.6.9]
_exit_cleanup(code=10, file=/SourceCache/rsync/rsync-42/rsync/clientserver.c, line=105): about to call exit(10)

我确实RSYNC_PROXY设置了我的环境变量并且代理正在工作,但根据它的输出,rsync它似乎没有使用我给它的代理,而是尝试直接连接。任何人都可以帮忙吗?谢谢!

如果需要,这里有一些更多信息。

$ echo $RSYNC_PROXY
127.0.0.1:3128
$ curl -x localhost:3128 http://rsync.macports.org:873/
@RSYNCD: 30.0
$ uname -a
Darwin Simon-MP.local 12.0.0 Darwin Kernel Version 12.0.0: Sun Jun 24 23:00:16 PDT 2012; root:xnu-2050.7.9~1/RELEASE_X86_64 x86_64
4

1 回答 1

3

问题解决了。

事实证明,sudo确实将 RSYNC_PROXY 环境传递给rsync. 为了保护环境sudo,接受以下-E选项:

-E(保留环境)选项将覆盖 sudoers(5) 中的 env_reset 选项。仅当匹配的命令具有 SETENV 标记或在 sudoers(5) 中设置了 setenv 选项时,它才可用。

于 2012-08-08T02:30:03.350 回答