pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk/flavor/pkg Fix error with just-in-time su when inst...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/e0f13cd4aacb
branches:  trunk
changeset: 514547:e0f13cd4aacb
user:      jlam <jlam%pkgsrc.org@localhost>
date:      Wed Jun 14 03:00:03 2006 +0000

description:
Fix error with just-in-time su when installing dependencies.  The code
to install dependencies looked roughly like this:

        ${CAT} ${_DEPENDS_FILE} |
        while read type pattern dir; do
                cd $$dir && ${MAKE} install
        done

In the code above, tghe recursive make invoked to install each dependency
does a just-in-time su to acquire root privileges for the installation,
but the su tries to get terminal settings for standard input (from
the pipe) using tcgetattr(), which fails and subsequently causes su
to exit with a puzzling "conversation failure" error.  Rewrite the
loop to look (roughly) like this:

        set -- `${CAT} ${_DEPENDS_FILE}`
        while test $# -gt 0; do
                type=$1; pattern=$2; dir=$3; shift 3
                cd $$dir && ${MAKE} install
        done

Note that this is potentially bad for shells with very low limits on
the maximum command line length, but at least this preserves file
descriptor 1 to reference the controlling tty unless the user does
something weird with input redirection when invoking make.

diffstat:

 mk/flavor/pkg/depends.mk |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (21 lines):

diff -r 4144ed4ff020 -r e0f13cd4aacb mk/flavor/pkg/depends.mk
--- a/mk/flavor/pkg/depends.mk  Wed Jun 14 00:14:24 2006 +0000
+++ b/mk/flavor/pkg/depends.mk  Wed Jun 14 03:00:03 2006 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: depends.mk,v 1.6 2006/06/09 16:41:09 jlam Exp $
+# $NetBSD: depends.mk,v 1.7 2006/06/14 03:00:03 jlam Exp $
 
 _DEPENDS_FILE=         ${WRKDIR}/.depends
 _REDUCE_DEPENDS_CMD=   ${SETENV} CAT=${CAT:Q}                          \
@@ -67,8 +67,9 @@
 .PHONY: depends-install
 depends-install: ${_DEPENDS_FILE}
        ${_PKG_SILENT}${_PKG_DEBUG}set -e;                              \
-       ${CAT} ${_DEPENDS_FILE} |                                       \
-       while read type pattern dir; do                                 \
+       set -- dummy `${CAT} ${_DEPENDS_FILE}`; shift;                  \
+       while ${TEST} $$# -gt 0; do                                     \
+               type="$$1"; pattern="$$2"; dir="$$3"; shift 3;          \
                pkg=`${_PKG_BEST_EXISTS} "$$pattern" || ${TRUE}`;       \
                case "$$pkg" in                                         \
                "")                                                     \



Home | Main Index | Thread Index | Old Index