summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorjlam <jlam>2006-05-01 14:56:23 +0000
committerjlam <jlam>2006-05-01 14:56:23 +0000
commita8f09b83b9830620ef8cd675d78810399770bd5c (patch)
tree9623d69fd732ddcb58e1e9178d6346160c9b4313 /mk
parent46cbce1c93fc52038c54d490ea1297aba3d783b2 (diff)
downloadpkgsrc-a8f09b83b9830620ef8cd675d78810399770bd5c.tar.gz
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 (limited to 'mk')
-rw-r--r--mk/install/dirs15
-rw-r--r--mk/install/files15
-rw-r--r--mk/install/usergroup3
-rw-r--r--mk/install/usergroupfuncs56
-rw-r--r--mk/install/usergroupfuncs.DragonFly56
-rw-r--r--mk/install/usergroupfuncs.FreeBSD56
6 files changed, 111 insertions, 90 deletions
diff --git a/mk/install/dirs b/mk/install/dirs
index 581e93b038d..f4c50dc1a57 100644
--- a/mk/install/dirs
+++ b/mk/install/dirs
@@ -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-REMOVE)
;;
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 @@ CHECK-PERMS)
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 @@ CHECK-PERMS)
exit 1
;;
esac; }
- rm -rf $tmpdir
+ ${RM} -fr $tmpdir
${TEST} $? -eq 0 || exitcode=1
;;
diff --git a/mk/install/files b/mk/install/files
index aa41df32d24..8494d24ee43 100644
--- a/mk/install/files
+++ b/mk/install/files
@@ -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-REMOVE)
;;
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 @@ CHECK-PERMS)
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 @@ CHECK-PERMS)
exit 1
;;
esac; }
- rm -rf $tmpdir
+ ${RM} -fr $tmpdir
${TEST} $? -eq 0 || exitcode=1
;;
diff --git a/mk/install/usergroup b/mk/install/usergroup
index 958e2aa5575..bce7dec15e6 100644
--- a/mk/install/usergroup
+++ b/mk/install/usergroup
@@ -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 @@ UNPACK,|UNPACK,+USERGROUP)
AWK="@AWK@"
CAT="@CAT@"
CHGRP="@CHGRP@"
+CHMOD="@CHMOD@"
CHOWN="@CHOWN@"
ECHO="@ECHO@"
GREP="@GREP@"
diff --git a/mk/install/usergroupfuncs b/mk/install/usergroupfuncs
index e01758ddc6c..951c505225f 100644
--- a/mk/install/usergroupfuncs
+++ b/mk/install/usergroupfuncs
@@ -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 @@ group_exists()
${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 @@ user_exists()
${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 --git a/mk/install/usergroupfuncs.DragonFly b/mk/install/usergroupfuncs.DragonFly
index 3d3ddaae250..0711ecaa665 100644
--- a/mk/install/usergroupfuncs.DragonFly
+++ b/mk/install/usergroupfuncs.DragonFly
@@ -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 @@ group_exists()
${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 @@ user_exists()
${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
}
# adduser user group [userid] [descr] [home] [shell]
diff --git a/mk/install/usergroupfuncs.FreeBSD b/mk/install/usergroupfuncs.FreeBSD
index 82aa3735a83..dbf5b4d3116 100644
--- a/mk/install/usergroupfuncs.FreeBSD
+++ b/mk/install/usergroupfuncs.FreeBSD
@@ -1,4 +1,4 @@
-# $NetBSD: usergroupfuncs.FreeBSD,v 1.6 2006/04/29 03:49:12 jlam Exp $
+# $NetBSD: usergroupfuncs.FreeBSD,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 @@ group_exists()
${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 @@ user_exists()
${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
}
# adduser user group [userid] [descr] [home] [shell]