Find the answer to your Linux question:
Results 1 to 3 of 3
I seriously wonder why this is the case: When I use a local proxy, and set the proxy in /etc/bash.bashrc, after a reboot I get, as expected: (Sorry, for posting ...
  1. #1
    Just Joined!
    Join Date
    Feb 2007
    Posts
    10

    Question Baffled about sudo-behaviour with wget, R

    I seriously wonder why this is the case:
    When I use a local proxy, and set the proxy in /etc/bash.bashrc, after a reboot I get, as expected:

    (Sorry, for posting rules I had to change all '//' into '\\')

    $ echo $http_proxy
    http:\\127.0.0.1:3128
    $ sudo echo $http_proxy
    http:\\127.0.0.1:3128

    And now,
    $ wget http:\\anga.funkfeuer.at/ftp/pub/OpenBSD/4.7/ports.tar.gz
    --2010-06-11 20:22:12-- http:\\anga.funkfeuer.at/ftp/pub/OpenBSD/4.7/ports.tar.gz
    Connecting to 127.0.0.1:3128... connected.
    Proxy request sent, awaiting response... 200 OK
    [...]
    everything is fine and wget works.

    Though, now I expect root to be allowed likewise:
    $ sudo wget http:\\anga.funkfeuer.at/ftp/pub/OpenBSD/4.7/ports.tar.gz
    --2010-06-11 20:22:22-- http:\\anga.funkfeuer.at/ftp/pub/OpenBSD/4.7/ports.tar.gz
    Resolving anga.funkfeuer.at... 78.41.115.130, 2a02:60:1:1::9
    Connecting to anga.funkfeuer.at|78.41.115.130|:80... failed: Connection refused.
    Connecting to anga.funkfeuer.at|2a02:60:1:1::9|:80... failed: Network is unreachable.
    $

    Why is this the case?
    And in R, it behaves the same way: as user, I can
    > install.packages("ThisPack")
    but I can't install system-wide.
    So when I 'sudo R', I could install system-wide, if only R could contact the package site. But it cannot.

    Question in a nutshell:
    Why, if sudo echo $http_proxy is okay, can sudo not use that proxy??

    Any enlightenment is welcome!

    Uwe

  2. #2
    Just Joined!
    Join Date
    Apr 2010
    Posts
    69
    Quote Originally Posted by udippel View Post
    Question in a nutshell:
    Why, if sudo echo $http_proxy is okay, can sudo not use that proxy??
    You probably already know this much, but hey, why not?

    It could be that your sudoers is setup to allow the use of certain env vars for certain commands. Like, maybe a more permissive set for "echo" and the default, more restrictive set for "wget." Typically, sudo will keep only a limited set of vars from the invoking user's shell for safety's sake. So, really, it would seem you should actually get no output from the "sudo echo" command.

    I guess I am not sure why that is actually happening. Although, you could probably do a few things to fix it. One, you could modify your sudoers file to permit the proxy variable to be passed from your environment. Two, you could setup a .wgetrc containing the proxy info in root's home dir, but I think you would then need to invoke sudo as "sudo -i wget ..." each time to initiate wget with root's login environment.

    Maybe that helps?

    If not, hey, good luck finding the actual and more thorough answer.

    - N++

  3. #3
    Just Joined!
    Join Date
    Feb 2007
    Posts
    10
    Quote Originally Posted by nplusplus View Post
    One, you could modify your sudoers file to permit the proxy variable to be passed from your environment. Two, you could setup a .wgetrc containing the proxy info in root's home dir, but I think you would then need to invoke sudo as "sudo -i wget ..." each time to initiate wget with root's login environment.
    I guess, your mention of 'environment' is quite correct here. Of course, when I run 'sudo something', which environment do I use?

    Though, look carefully, I didn't put the proxy statement into .bashrc, but /etc/bash.bashrc. So, I am getting it, as a system-wide setting, without any further setting in HOME. So why not su(do), whichever environment is being used?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...