pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/mk/install Use the meta-data directory as the location...
details: https://anonhg.NetBSD.org/pkgsrc/rev/44a8b66815ae
branches: trunk
changeset: 512113:44a8b66815ae
user: jlam <jlam%pkgsrc.org@localhost>
date: Mon May 01 14:56:23 2006 +0000
description:
Use the meta-data directory as the location for all temporary files
used by the various scriptlets. Also, consistently use the idiom of
creating a temporary directory with mode 700 and creating temporary
files underneath that directory to avoid race conditions.
diffstat:
mk/install/dirs | 15 +++++----
mk/install/files | 15 +++++----
mk/install/usergroup | 3 +-
mk/install/usergroupfuncs | 56 ++++++++++++++++++++----------------
mk/install/usergroupfuncs.DragonFly | 56 ++++++++++++++++++++----------------
mk/install/usergroupfuncs.FreeBSD | 56 ++++++++++++++++++++----------------
6 files changed, 111 insertions(+), 90 deletions(-)
diffs (truncated from 402 to 300 lines):
diff -r 97377db12182 -r 44a8b66815ae mk/install/dirs
--- a/mk/install/dirs Mon May 01 13:52:55 2006 +0000
+++ b/mk/install/dirs Mon May 01 14:56:23 2006 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: dirs,v 1.14 2006/04/25 22:35:46 jlam Exp $
+# $NetBSD: dirs,v 1.15 2006/05/01 14:56:23 jlam Exp $
#
# Generate a +DIRS script that reference counts directories that are
# required for the proper functioning of the package.
@@ -281,9 +281,9 @@
;;
CHECK-PERMS)
- tmpdir="${TMPDIR:-/tmp}/pkginstall.$$"
+ tmpdir="./.pkginstall.$$"
${MKDIR} -p $tmpdir 2>/dev/null || exit 1
- ${CHMOD} 700 $tmpdir
+ ${CHMOD} 0700 $tmpdir
${SED} -n "/^\# DIR: /{s/^\# DIR: //;p;}" ${SELF} | ${SORT} -ru |
{ while read dir d_flags d_mode d_user d_group; do
case $dir in
@@ -296,9 +296,10 @@
esac
perms=`${LS} -ld $dir | ${AWK} '{ print $1":"$3":"$4 }'`
- ${MKDIR} -p $tmpdir/tmp
- ${CHMOD} $d_mode $tmpdir/tmp 2>/dev/null
- longmode=`${LS} -ld $tmpdir/tmp | ${AWK} '{ print $1 }'`
+ testpath="$tmpdir/dir_perms"
+ ${MKDIR} -p $testpath
+ ${CHMOD} $d_mode $testpath 2>/dev/null
+ longmode=`${LS} -ld $testpath | ${AWK} '{ print $1 }'`
case $d_mode:$d_user:$d_group in
:[!:]*:)
case "$perms" in
@@ -354,7 +355,7 @@
exit 1
;;
esac; }
- rm -rf $tmpdir
+ ${RM} -fr $tmpdir
${TEST} $? -eq 0 || exitcode=1
;;
diff -r 97377db12182 -r 44a8b66815ae mk/install/files
--- a/mk/install/files Mon May 01 13:52:55 2006 +0000
+++ b/mk/install/files Mon May 01 14:56:23 2006 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files,v 1.13 2006/04/25 22:35:46 jlam Exp $
+# $NetBSD: files,v 1.14 2006/05/01 14:56:23 jlam Exp $
#
# Generate a +FILES script that reference counts config files that are
# required for the proper functioning of the package.
@@ -365,9 +365,9 @@
;;
CHECK-PERMS)
- tmpdir="${TMPDIR:-/tmp}/pkginstall.$$"
+ tmpdir="./.pkginstall.$$"
${MKDIR} -p $tmpdir 2>/dev/null || exit 1
- ${CHMOD} 700 $tmpdir
+ ${CHMOD} 0700 $tmpdir
${SED} -n "/^\# FILE: /{s/^\# FILE: //;p;}" ${SELF} | ${SORT} -ru |
{ while read file f_flags f_eg f_mode f_user f_group; do
case $file in
@@ -380,9 +380,10 @@
esac
perms=`${LS} -l $file | ${AWK} '{ print $1":"$3":"$4 }'`
- ${ECHO} > $tmpdir/tmp
- ${CHMOD} $f_mode $tmpdir/tmp 2>/dev/null
- longmode=`${LS} -l $tmpdir/tmp | ${AWK} '{ print $1 }'`
+ testpath="$tmpdir/file_perms"
+ ${ECHO} > $testpath
+ ${CHMOD} $f_mode $testpath 2>/dev/null
+ longmode=`${LS} -l $testpath | ${AWK} '{ print $1 }'`
case $f_mode:$f_user:$f_group in
:[!:]*:)
case "$perms" in
@@ -438,7 +439,7 @@
exit 1
;;
esac; }
- rm -rf $tmpdir
+ ${RM} -fr $tmpdir
${TEST} $? -eq 0 || exitcode=1
;;
diff -r 97377db12182 -r 44a8b66815ae mk/install/usergroup
--- a/mk/install/usergroup Mon May 01 13:52:55 2006 +0000
+++ b/mk/install/usergroup Mon May 01 14:56:23 2006 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: usergroup,v 1.15 2006/04/23 00:00:44 jlam Exp $
+# $NetBSD: usergroup,v 1.16 2006/05/01 14:56:23 jlam Exp $
#
# Generate a +USERGROUP script that reference-counts users and groups
# that are required for the proper functioning of the package.
@@ -47,6 +47,7 @@
AWK="@AWK@"
CAT="@CAT@"
CHGRP="@CHGRP@"
+CHMOD="@CHMOD@"
CHOWN="@CHOWN@"
ECHO="@ECHO@"
GREP="@GREP@"
diff -r 97377db12182 -r 44a8b66815ae mk/install/usergroupfuncs
--- a/mk/install/usergroupfuncs Mon May 01 13:52:55 2006 +0000
+++ b/mk/install/usergroupfuncs Mon May 01 14:56:23 2006 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: usergroupfuncs,v 1.8 2006/04/29 03:49:12 jlam Exp $
+# $NetBSD: usergroupfuncs,v 1.9 2006/05/01 14:56:23 jlam Exp $
#
# Default implementations of user_exists() and group_exists() shell
# functions for checking the existence of users and groups, and of
@@ -23,29 +23,32 @@
${TEST} -n "$_group" || return 3
# Check using chgrp to work properly in an NSS/NIS environment.
- _testfile="./grouptest.tmp.$$"
- ${ECHO} > $_testfile
- if ${CHGRP} $_group $_testfile >/dev/null 2>&1; then
+ _tmpdir="./.pkginstall.$$"
+ ${MKDIR} -p $_tmpdir 2>/dev/null || return 3
+ ${CHMOD} 0700 $_tmpdir
+ _testpath="$_tmpdir/group_exists"
+ ${ECHO} > $_testpath
+ if ${CHGRP} $_group $_testpath >/dev/null 2>&1; then
# $_group exists
- _id=`${LS} -ln $_testfile 2>/dev/null | ${AWK} '{ print $4 }'`
+ _id=`${LS} -ln $_testpath 2>/dev/null | ${AWK} '{ print $4 }'`
${TEST} -n "$_groupid" || _groupid=$_id
if ${TEST} "$_groupid" = "$_id"; then
- ${RM} -f $_testfile; return 0
+ ${RM} -fr $_tmpdir; return 0
fi
- ${RM} -f $_testfile; return 2
+ ${RM} -fr $_tmpdir; return 2
elif ${TEST} -z "$_groupid"; then
# $_group doesn't exist and $_groupid is not set
- ${RM} -f $_testfile; return 1
- elif ${CHGRP} $_groupid $_testfile >/dev/null 2>&1; then
- _name=`${LS} -l $_testfile 2>/dev/null | ${AWK} '{ print $4 }'`
+ ${RM} -fr $_tmpdir; return 1
+ elif ${CHGRP} $_groupid $_testpath >/dev/null 2>&1; then
+ _name=`${LS} -l $_testpath 2>/dev/null | ${AWK} '{ print $4 }'`
if ${TEST} "$_name" != "$_groupid"; then
# $_group doesn't exist, but $_groupid exists
- ${RM} -f $_testfile; return 2
+ ${RM} -fr $_tmpdir; return 2
fi
# neither $_group nor $_groupid exist
- ${RM} -f $_testfile; return 1
+ ${RM} -fr $_tmpdir; return 1
fi
- ${RM} -f $_testfile; return 3
+ ${RM} -fr $_tmpdir; return 3
}
# user_exists user [userid]
@@ -60,29 +63,32 @@
${TEST} -n "$_user" || return 3
# Check using chown to work properly in an NSS/NIS environment.
- _testfile="./usertest.tmp.$$"
- ${ECHO} > $_testfile
- if ${CHOWN} $_user $_testfile >/dev/null 2>&1; then
+ _tmpdir="./.pkginstall.$$"
+ ${MKDIR} -p $_tmpdir 2>/dev/null || return 3
+ ${CHMOD} 0700 $_tmpdir
+ _testpath="$_tmpdir/user_exists"
+ ${ECHO} > $_testpath
+ if ${CHOWN} $_user $_testpath >/dev/null 2>&1; then
# $_user exists
- _id=`${LS} -ln $_testfile 2>/dev/null | ${AWK} '{ print $3 }'`
+ _id=`${LS} -ln $_testpath 2>/dev/null | ${AWK} '{ print $3 }'`
${TEST} -n "$_userid" || _userid=$_id
if ${TEST} "$_userid" = "$_id"; then
- ${RM} -f $_testfile; return 0
+ ${RM} -fr $_tmpdir; return 0
fi
- ${RM} -f $_testfile; return 2
+ ${RM} -fr $_tmpdir; return 2
elif ${TEST} -z "$_userid"; then
# $_user doesn't exist and $_userid is not set
- ${RM} -f $_testfile; return 1
- elif ${CHOWN} $_userid $_testfile >/dev/null 2>&1; then
- _name=`${LS} -l $_testfile 2>/dev/null | ${AWK} '{ print $3 }'`
+ ${RM} -fr $_tmpdir; return 1
+ elif ${CHOWN} $_userid $_testpath >/dev/null 2>&1; then
+ _name=`${LS} -l $_testpath 2>/dev/null | ${AWK} '{ print $3 }'`
if ${TEST} "$_name" != "$_userid"; then
# $_user doesn't exist, but $_userid exists
- ${RM} -f $_testfile; return 2
+ ${RM} -fr $_tmpdir; return 2
fi
# neither $_user nor $_userid exist
- ${RM} -f $_testfile; return 1
+ ${RM} -fr $_tmpdir; return 1
fi
- ${RM} -f $_testfile; return 3
+ ${RM} -fr $_tmpdir; return 3
}
# adduser user group [userid] [descr] [home] [shell]
diff -r 97377db12182 -r 44a8b66815ae mk/install/usergroupfuncs.DragonFly
--- a/mk/install/usergroupfuncs.DragonFly Mon May 01 13:52:55 2006 +0000
+++ b/mk/install/usergroupfuncs.DragonFly Mon May 01 14:56:23 2006 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: usergroupfuncs.DragonFly,v 1.6 2006/04/29 03:49:12 jlam Exp $
+# $NetBSD: usergroupfuncs.DragonFly,v 1.7 2006/05/01 14:56:23 jlam Exp $
#
# Platform-specific adduser and addgroup functionality
# on top of pw(8).
@@ -15,29 +15,32 @@
${TEST} -n "$_group" || return 3
# Check using chgrp to work properly in an NSS/NIS environment.
- _testfile="./grouptest.tmp.$$"
- ${ECHO} > $_testfile
- if ${CHGRP} $_group $_testfile >/dev/null 2>&1; then
+ _tmpdir="./.pkginstall.$$"
+ ${MKDIR} -p $_tmpdir 2>/dev/null || return 3
+ ${CHMOD} 0700 $_tmpdir
+ _testpath="$_tmpdir/group_exists"
+ ${ECHO} > $_testpath
+ if ${CHGRP} $_group $_testpath >/dev/null 2>&1; then
# $_group exists
- _id=`${LS} -ln $_testfile 2>/dev/null | ${AWK} '{ print $4 }'`
+ _id=`${LS} -ln $_testpath 2>/dev/null | ${AWK} '{ print $4 }'`
${TEST} -n "$_groupid" || _groupid=$_id
if ${TEST} "$_groupid" = "$_id"; then
- ${RM} -f $_testfile; return 0
+ ${RM} -fr $_tmpdir; return 0
fi
- ${RM} -f $_testfile; return 2
+ ${RM} -fr $_tmpdir; return 2
elif ${TEST} -z "$_groupid"; then
# $_group doesn't exist and $_groupid is not set
- ${RM} -f $_testfile; return 1
- elif ${CHGRP} $_groupid $_testfile >/dev/null 2>&1; then
- _name=`${LS} -l $_testfile 2>/dev/null | ${AWK} '{ print $4 }'`
+ ${RM} -fr $_tmpdir; return 1
+ elif ${CHGRP} $_groupid $_testpath >/dev/null 2>&1; then
+ _name=`${LS} -l $_testpath 2>/dev/null | ${AWK} '{ print $4 }'`
if ${TEST} "$_name" != "$_groupid"; then
# $_group doesn't exist, but $_groupid exists
- ${RM} -f $_testfile; return 2
+ ${RM} -fr $_tmpdir; return 2
fi
# neither $_group nor $_groupid exist
- ${RM} -f $_testfile; return 1
+ ${RM} -fr $_tmpdir; return 1
fi
- ${RM} -f $_testfile; return 3
+ ${RM} -fr $_tmpdir; return 3
}
# user_exists user [userid]
@@ -52,29 +55,32 @@
${TEST} -n "$_user" || return 3
# Check using chown to work properly in an NSS/NIS environment.
- _testfile="./usertest.tmp.$$"
- ${ECHO} > $_testfile
- if ${CHOWN} $_user $_testfile >/dev/null 2>&1; then
+ _tmpdir="./.pkginstall.$$"
+ ${MKDIR} -p $_tmpdir 2>/dev/null || return 3
+ ${CHMOD} 0700 $_tmpdir
+ _testpath="$_tmpdir/user_exists"
+ ${ECHO} > $_testpath
+ if ${CHOWN} $_user $_testpath >/dev/null 2>&1; then
# $_user exists
- _id=`${LS} -ln $_testfile 2>/dev/null | ${AWK} '{ print $3 }'`
+ _id=`${LS} -ln $_testpath 2>/dev/null | ${AWK} '{ print $3 }'`
${TEST} -n "$_userid" || _userid=$_id
if ${TEST} "$_userid" = "$_id"; then
- ${RM} -f $_testfile; return 0
+ ${RM} -fr $_tmpdir; return 0
fi
- ${RM} -f $_testfile; return 2
+ ${RM} -fr $_tmpdir; return 2
elif ${TEST} -z "$_userid"; then
# $_user doesn't exist and $_user is not set
- ${RM} -f $_testfile; return 1
- elif ${CHOWN} $_userid $_testfile >/dev/null 2>&1; then
- _name=`${LS} -l $_testfile 2>/dev/null | ${AWK} '{ print $3 }'`
+ ${RM} -fr $_tmpdir; return 1
+ elif ${CHOWN} $_userid $_testpath >/dev/null 2>&1; then
+ _name=`${LS} -l $_testpath 2>/dev/null | ${AWK} '{ print $3 }'`
if ${TEST} "$_name" != "$_userid"; then
# $_user doesn't exist, but $_userid exists
- ${RM} -f $_testfile; return 2
+ ${RM} -fr $_tmpdir; return 2
fi
# neither $_user nor $_userid exist
- ${RM} -f $_testfile; return 1
+ ${RM} -fr $_tmpdir; return 1
fi
- ${RM} -f $_testfile; return 3
+ ${RM} -fr $_tmpdir; return 3
Home |
Main Index |
Thread Index |
Old Index