1

I'm behind a http proxy and a wanna update macports using sudo port selfupdate. But it always fails with the following output:

$ 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

Obviously the problem is that rsync not connecting to the server, so I tried rsync alone and it gives me a similar result.

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

I do get my RSYNC_PROXY environment variable set and the proxy is working, but according to the output of rsync it seems it's not using the proxy I gave it but trying a direct connection instead. Can anyone help? Thanks!

Here's some more info in case needed.

$ 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
S. Liu
  • 1,018
  • 2
  • 10
  • 25

1 Answers1

3

Problem solved.

It turns out that sudo does's pass the RSYNC_PROXY environment to rsync. To preserve environment sudo accepts the -E option:

The -E (preserve environment) option will override the env_reset option in sudoers(5)). It is only available when either the matching command has the SETENV tag or the setenv option is set in sudoers(5).

S. Liu
  • 1,018
  • 2
  • 10
  • 25