2012-08-07 321 views
0

我在使用http代理並希望使用sudo port selfupdate更新macports。但它總是失敗,出現以下的輸出:儘管RSYNC_PROXY已設置,但rsync代理無法正常工作

$ 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 

回答

2

問題解決了。

事實證明,sudo確實將RSYNC_PROXY環境傳遞給rsync。爲了保護環境sudo接受-E選項:

的-E(保護環境)選項將覆蓋在sudoers中的env_reset 選項(5))。只有當匹配的 命令具有SETENV標記或在sudoers(5)中設置了setenv選項時纔可用。

相關問題