FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 06-19-2010, 12:47 AM
Andres P
 
Default makepkg: simplify su/sudo calling logic

* Before, calls to sudo were not being word-split, whereas falling back to su,
for some reason, meant applying IFS to the arguments. From now on calling
either does not mangle any of the operands.

* Instead of recreating the basic bash concept of $? with $ret, opt for
stacking the command line into a variable that can later be checked *once*
for a return code.

Signed-off-by: Andres P <aepd87@gmail.com>
---
scripts/makepkg.sh.in | 14 ++++++--------
1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 536da30..2258d2a 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -370,17 +370,15 @@ download_file() {
}

run_pacman() {
- local ret=0
- if (( ! ASROOT )) && [[ $1 != "-T" && $1 != "-Qq" ]]; then
- if type -p sudo >/dev/null && sudo -l $PACMAN &>/dev/null; then
- sudo $PACMAN $PACMAN_OPTS "$@" || ret=$?
+ local cmd=$(printf "%q " "$PACMAN" $PACMAN_OPTS "$@")
+ if (( ! ASROOT )) && [[ ! $1 =~ ^-(T|Qq)$ ]]; then
+ if type -p sudo >/dev/null && sudo -l "$PACMAN" &>/dev/null; then
+ cmd="sudo $cmd"
else
- su -c "$PACMAN $PACMAN_OPTS $*" || ret=$?
+ cmd="su -c '$cmd'"
fi
- else
- $PACMAN $PACMAN_OPTS "$@" || ret=$?
fi
- return $ret
+ eval "$cmd"
}

check_deps() {
--
1.7.1
 
Old 06-19-2010, 12:50 AM
Andres P
 
Default makepkg: simplify su/sudo calling logic

On Fri, Jun 18, 2010 at 8:17 PM, Andres P <aepd87@gmail.com> wrote:
> * Before, calls to sudo were not being word-split, whereas falling back to su,
> *for some reason, meant applying IFS to the arguments. From now on calling
> *either does not mangle any of the operands.
>
> * Instead of recreating the basic bash concept of $? with $ret, opt for
> *stacking the command line into a variable that can later be checked *once*
> *for a return code.
>

Note that this still has the "using su fucks up the terminal" bug present in
3.4.

When makepkg uses su for any reason, fallback or not, the terminal will no
longer display stdin and has to be reset(1).

To reproduce:
# mv /usr/bin/sudo{,~}

Then use a makepkg operation that requires root; e.g. -i or -s.

I can reproduce outside of makepkg:
$ fakeroot bash -c "su -c 'pacman -Q foo'"

But this is *just* an example. These calls do not involve fakeroot.

Andres P
 
Old 06-19-2010, 06:29 AM
Allan McRae
 
Default makepkg: simplify su/sudo calling logic

On 19/06/10 10:50, Andres P wrote:

Note that this still has the "using su fucks up the terminal" bug present in
3.4.


Still has? This is the first I am hearing of it... Is there a bug
report about this?



When makepkg uses su for any reason, fallback or not, the terminal will no
longer display stdin and has to be reset(1).

To reproduce:
# mv /usr/bin/sudo{,~}

Then use a makepkg operation that requires root; e.g. -i or -s.


I just tested this and there is even worse things happening.

I have a PKGBUILD which has depends=('pacman>4') in it for testing out
another bug.


When using su I get:

--start output--
> makepkg -sf
==> WARNING: Sudo can not be found. Will use su to acquire root privileges.
==> Making package: pacman-contrib 3.4.0-1 (Sat Jun 19 16:24:35 EST 2010)
==> Checking Runtime Dependencies...
==> Installing missing dependencies...
Password:
Proceed with installation? [Y/n]
==> Missing Dependencies:
-> pacman>4
==> Checking Buildtime Dependencies...
==> ERROR: Could not resolve all dependencies.
--end output--

Note it processed trying to install pacman, even though >4 does not
exist. Then if find a file called "4" in my $startdir with:


--start 4--
warning: pacman-3.4.0-1 is up to date -- reinstalling
resolving dependencies...
looking for inter-conflicts...

Targets (1): pacman-3.4.0-1

Total Download Size: 0.00 MB
Total Installed Size: 1.98 MB

checking package integrity...
checking for file conflicts...
upgrading pacman...
--end 4--

It appears that the 'pacman>4' is not staying quoted and is causing the
output to be redirected.




I can reproduce outside of makepkg:
$ fakeroot bash -c "su -c 'pacman -Q foo'"


I can not see anything wrong when using that.

Allan
 

Thread Tools




All times are GMT. The time now is 07:28 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org