You are not logged in.

#1 2007-11-10 18:57:06

steamedfish
Member
From: Guangzhou, Guangdong,China
Registered: 2007-11-10
Posts: 9
Website

[SOLVED]Use pacman as root differs from use pacman by sudo

I need a proxy server to connect the internet. I configured and then I can use pacman as root. But use pacman by sudo doesn't work.

Here is how I configure pacman:

/etc/pacman.conf

#
# /etc/pacman.conf
#
# NOTE: If you find a mirror that is geographically close to you, please
#       move it to the top of the server list, so pacman will choose it
#       first.
#
# To re-sort your mirror lists by ping/traceroute results, use the
# /usr/bin/sortmirrors script.  It requires the "netselect" package.
#

# See the pacman manpage for option directives

#
# GENERAL OPTIONS
#
[options]
LogFile     = /var/log/pacman.log
NoUpgrade   = etc/passwd etc/group etc/shadow etc/sudoers
NoUpgrade   = etc/fstab etc/raidtab etc/ld.so.conf
NoUpgrade   = etc/rc.conf etc/rc.local
NoUpgrade   = etc/modprobe.conf etc/modules.conf
NoUpgrade   = etc/lilo.conf boot/grub/menu.lst
HoldPkg     = pacman glibc
XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
#XferCommand = /usr/bin/wget --proxy-user=MyProxyUsername --proxy-password=ProxyPassword -c %o %u
#I tryed both the two XferCommand options and they works the same way.

#
# REPOSITORIES
#   - can be defined here or included from another file
#   - pacman will search repositories in the order defined here.
#   - local/custom mirrors can be added here or in separate files
# 

#[testing]
#Server = ftp://ftp.archlinux.org/testing/os/i686
#Server = ftp://mirror.cs.vt.edu/pub/ArchLinux/testing/os/i686

#[current]
# Add your preferred servers here, they will be used first
#Include = /etc/pacman.d/current
#Server = ftp://ftp.archlinux.org/current/os/i686
#Server = ftp://mirror.cs.vt.edu/pub/ArchLinux/current/os/i686

[core]
# Add your preferred servers here, they will be used first
#Include = /etc/pacman.d/core
Server = ftp://ftp.archlinux.org/core/os/i686
#Server = ftp://mirror.cs.vt.edu/pub/ArchLinux/core/os/i686

[extra]
# Add your preferred servers here, they will be used first
#Include = /etc/pacman.d/extra
Server = ftp://ftp.archlinux.org/extra/os/i686
#Server = ftp://mirror.cs.vt.edu/pub/ArchLinux/extra/os/i686


#[unstable]
# Add your preferred servers here, they will be used first
#Include = /etc/pacman.d/unstable

[community]
# Add your preferred servers here, they will be used first
#Include = /etc/pacman.d/community
Server = ftp://ftp.archlinux.org/community/os/i686
#Server = ftp://mirror.cs.vt.edu/pub/ArchLinux/community/os/i686

# An example of a custom package repository.  See the pacman manpage for
# tips on creating your own repositories.
#[custom]
#Server = file:///home/custompkgs

And I also

export http_proxy=http://ProxyUsername:ProxyPassword@ProxyIPaddress:port
export ftp_proxy=http://ProxyUsername:ProxyPassword@ProxyIPaddress:port

I haven't change /etc/wgetrc .

My /etc/sudoers

# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#

# Host alias specification

# User alias specification

# Cmnd alias specification

# Defaults specification

# Runas alias specification

# User privilege specification
root    ALL=(ALL) SETENV: ALL
steamedfish ALL=(ALL) SETENV: ALL

# Uncomment to allow people in group wheel to run all commands
# and set environment variables.
# %wheel    ALL=(ALL) SETENV: ALL

# Same thing without a password
# %wheel    ALL=(ALL) NOPASSWD: SETENV: ALL

# Samples
# %users  ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users  localhost=/sbin/shutdown -h now

When use pacman by sudo (I changed my default enviroment $LANG from "zh_CN.UTF-8 to "C" so that there's no Chinese in the output)

steamedfish@SteamedFish:~$ sudo pacman -Syu
:: Synchronizing package databases...
--02:33:05--  ftp://ftp.archlinux.org/core/os/i686/core.db.tar.gz
           => `/var/lib/pacman/core.db.tar.gz.part'
Resolving ftp.archlinux.org... 209.85.41.145, 209.85.41.144
Connecting to ftp.archlinux.org|209.85.41.145|:21... failed: Network is unreachable.
Connecting to ftp.archlinux.org|209.85.41.144|:21... failed: Network is unreachable.
error: failed to synchronize core: 
--02:33:05--  ftp://ftp.archlinux.org/extra/os/i686/extra.db.tar.gz
           => `/var/lib/pacman/extra.db.tar.gz.part'
Resolving ftp.archlinux.org... 209.85.41.144, 209.85.41.145
Connecting to ftp.archlinux.org|209.85.41.144|:21... failed: Network is unreachable.
Connecting to ftp.archlinux.org|209.85.41.145|:21... failed: Network is unreachable.
error: failed to synchronize extra: 
--02:33:05--  ftp://ftp.archlinux.org/community/os/i686/community.db.tar.gz
           => `/var/lib/pacman/community.db.tar.gz.part'
Resolving ftp.archlinux.org... 209.85.41.145, 209.85.41.144
Connecting to ftp.archlinux.org|209.85.41.145|:21... failed: Network is unreachable.
Connecting to ftp.archlinux.org|209.85.41.144|:21... failed: Network is unreachable.
error: failed to synchronize community: 
error: failed to synchronize any databases

When use pacman under root:

[root@SteamedFish steamedfish]# pacman -Syu
:: Synchronizing package databases...
--02:45:02--  ftp://ftp.archlinux.org/core/os/i686/core.db.tar.gz
           => `/var/lib/pacman/core.db.tar.gz.part'
Connecting to ProxyAddess:port... connected.
Proxy request sent, awaiting response... 200 OK
Length: 23,635 (23K) [application/x-tar]

100%[====================================>] 23,635        20.00K/s             

02:45:10 (19.98 KB/s) - `/var/lib/pacman/core.db.tar.gz.part' saved [23635/23635]

--02:45:10--  ftp://ftp.archlinux.org/extra/os/i686/extra.db.tar.gz
           => `/var/lib/pacman/extra.db.tar.gz.part'
Connecting to ProxyAddess:port... connected.
Proxy request sent, awaiting response... 200 OK
Length: 322,251 (315K) [application/x-tar]

100%[====================================>] 322,251       54.41K/s    ETA 00:00

02:45:23 (54.33 KB/s) - `/var/lib/pacman/extra.db.tar.gz.part' saved [322251/322251]

--02:45:32--  ftp://ftp.archlinux.org/community/os/i686/community.db.tar.gz
           => `/var/lib/pacman/community.db.tar.gz.part'
Connecting to ProxyAddess:port... connected.
Proxy request sent, awaiting response... 200 OK
Length: 333,117 (325K) [application/x-tar]

100%[====================================>] 333,117       83.58K/s    ETA 00:00

02:45:46 (83.48 KB/s) - `/var/lib/pacman/community.db.tar.gz.part' saved [333117/333117]

:: Starting full system upgrade...
resolving dependencies... done.
looking for inter-conflicts... done.

Targets: skype-2.0.0.13-2  

Total Package Size:   14.26 MB
Total Installed Size:   17.35 MB

Proceed with installation? [Y/n] n

Last edited by steamedfish (2007-11-10 21:05:06)

Offline

#2 2007-11-10 19:11:33

steamedfish
Member
From: Guangzhou, Guangdong,China
Registered: 2007-11-10
Posts: 9
Website

Re: [SOLVED]Use pacman as root differs from use pacman by sudo

I moved my computer to a place that can directly connect to the internet without a proxy server.
Then I try to use pacman by sudo, the output are the followings.

steamedfish@SteamedFish:~$ sudo pacman -Su
:: Starting full system upgrade...
resolving dependencies... done.
looking for inter-conflicts... done.

Targets: skype-2.0.0.13-2  

Total Package Size:   14.26 MB
Total Installed Size:   17.35 MB

Proceed with installation? [Y/n] y
:: Retrieving packages from community...
--02:52:37--  ftp://ftp.archlinux.org/community/os/i686/skype-2.0.0.13-2.pkg.tar.gz
           => `/var/cache/pacman/pkg/skype-2.0.0.13-2.pkg.tar.gz.part'
Resolving ftp.archlinux.org... 209.85.41.145, 209.85.41.144
Connecting to ftp.archlinux.org|209.85.41.145|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD /community/os/i686 ... done.
==> PASV ... done.    ==> RETR skype-2.0.0.13-2.pkg.tar.gz ... done.
Length: 14,952,312 (14M) (unauthoritative)

100%[====================================>] 14,952,312   295.29K/s    ETA 00:00

02:54:24 (143.13 KB/s) - `/var/cache/pacman/pkg/skype-2.0.0.13-2.pkg.tar.gz.part' saved [14952312]

checking package integrity... done.
cleaning up... done.
(1/1) checking for file conflicts                   [#####################] 100%
(1/1) upgrading skype                               [#####################] 100%

Last edited by steamedfish (2007-11-10 19:13:15)

Offline

#3 2007-11-10 20:26:31

mcover
Member
From: Germany
Registered: 2007-01-25
Posts: 134

Re: [SOLVED]Use pacman as root differs from use pacman by sudo

I think you have a problem with

export http_proxy=http://ProxyUsername:ProxyPassword@ProxyIPaddress:port
export ftp_proxy=http://ProxyUsername:ProxyPassword@ProxyIPaddress:port

Depending where you call it, those variables are possibly not available in the sudo-environment. What you could try is calling pacman via sudo by the following command:

sudo http_proxy=http://ProxyUsername:ProxyPassword@ProxyIPaddress:port ftp_proxy=http://ProxyUsername:ProxyPassword@ProxyIPaddress:port   pacman -Syu

Should work since you defined SETENV: ALL.

Offline

#4 2007-11-10 20:36:45

steamedfish
Member
From: Guangzhou, Guangdong,China
Registered: 2007-11-10
Posts: 9
Website

Re: [SOLVED]Use pacman as root differs from use pacman by sudo

It won't work:(

steamedfish@SteamedFish:~$ sudo http_proxy=http://Username:password@ProxyIP:port
usage: sudo -h | -K | -k | -L | -l | -V | -v
usage: sudo [-bEHPS] [-p prompt] [-u username|#uid] [VAR=value]
            {-i | -s | <command>}
usage: sudo -e [-S] [-p prompt] [-u username|#uid] file ...
steamedfish@SteamedFish:~$ sudo ftp_proxy=http://Username:password@ProxyIP:port
usage: sudo -h | -K | -k | -L | -l | -V | -v
usage: sudo [-bEHPS] [-p prompt] [-u username|#uid] [VAR=value]
            {-i | -s | <command>}
usage: sudo -e [-S] [-p prompt] [-u username|#uid] file ...
steamedfish@SteamedFish:~$ sudo http_proxy="http://Username:password@ProxyIP:port"
usage: sudo -h | -K | -k | -L | -l | -V | -v
usage: sudo [-bEHPS] [-p prompt] [-u username|#uid] [VAR=value]
            {-i | -s | <command>}
usage: sudo -e [-S] [-p prompt] [-u username|#uid] file ...
steamedfish@SteamedFish:~$ sudo export http_proxy=http://Username:password@ProxyIP:port
Password:
sudo: export: command not found

Offline

#5 2007-11-10 20:53:50

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: [SOLVED]Use pacman as root differs from use pacman by sudo

steamedfish wrote:

It won't work:(

That's not what mcover asked you to try at all!

Also, I am not sure how it works since I'm not using a proxy myself, but pacman (with libdownload behind) has some kind of proxy support.
Maybe it also uses the http_proxy and ftp_proxy env var. So you could try commenting the XferCommand in pacman.conf .


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#6 2007-11-10 21:01:55

steamedfish
Member
From: Guangzhou, Guangdong,China
Registered: 2007-11-10
Posts: 9
Website

Re: [SOLVED]Use pacman as root differs from use pacman by sudo

Oh I'm sorry I'm so sleepy that I misunderstand what mcover asked.
Now it works! Thank you very much. big_smile

Last edited by steamedfish (2007-11-10 21:07:12)

Offline

Board footer

Powered by FluxBB