|
|
@@ -39,8 +39,8 @@
|
|
|
# o any cc(1)
|
|
|
|
|
|
# the package version and release
|
|
|
-%define V_openpkg 20020203
|
|
|
-%define R_openpkg 20020203
|
|
|
+%define V_openpkg 20020204
|
|
|
+%define R_openpkg 20020204
|
|
|
|
|
|
# the used software versions
|
|
|
%define V_rpm 4.0.2
|
|
|
@@ -91,8 +91,8 @@ Source20: rpmtool.pod
|
|
|
Source21: lsync
|
|
|
Source22: lsync.8
|
|
|
Source23: lsync.pod
|
|
|
-Source24: wrap1.sh
|
|
|
-Source25: wrap2.sh
|
|
|
+Source24: aux.wrapsrc.sh
|
|
|
+Source25: aux.wrapbin.sh
|
|
|
Source26: openpkg.pgp
|
|
|
Source27: shtool
|
|
|
Source28: rpmx.sh
|
|
|
@@ -108,6 +108,8 @@ Source37: dot.bash_login
|
|
|
Source38: dot.lsyncrc
|
|
|
Source39: db-%{V_db}.patch
|
|
|
Source40: rc.conf
|
|
|
+Source41: aux.prereq.sh
|
|
|
+Source42: aux.usrgrp.sh
|
|
|
|
|
|
# build information
|
|
|
Prefix: %{l_prefix}
|
|
|
@@ -185,54 +187,41 @@ Provides: OpenPKG
|
|
|
exit 1
|
|
|
fi
|
|
|
echo "l_cc=\"$l_cc\"; export l_cc" >>.buildenv
|
|
|
-
|
|
|
- # determine user and group for installed files
|
|
|
- if [ ".%{?l_fsusr:set}" = .set ]; then
|
|
|
- fsusr="%{l_fsusr}"
|
|
|
- else
|
|
|
- fsusr=`(id -un) 2>/dev/null ||\
|
|
|
- (whoami) 2>/dev/null ||\
|
|
|
- (who am i | cut "-d " -f1) 2>/dev/null ||\
|
|
|
- echo $LOGNAME`
|
|
|
- fi
|
|
|
- echo "fsusr=\"$fsusr\"; export fsusr" >>.buildenv
|
|
|
- if [ ".%{?l_fsgrp:set}" = .set ]; then
|
|
|
- fsgrp="%{l_fsgrp}"
|
|
|
- else
|
|
|
- fsgrp=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
|
|
|
- grep "^${fsusr}:" | head -1 | awk -F: '{ print $4; }'`
|
|
|
- fsgrp=`(cat /etc/group; ypcat group) 2>/dev/null |\
|
|
|
- grep ":${fsgrp}:" | head -1 | awk -F: '{ print $1; }'`
|
|
|
- fi
|
|
|
- fsgid=`(cat /etc/group; ypcat group) 2>/dev/null |\
|
|
|
- grep "^${fsgrp}:" | head -1 | awk -F: '{ print $3; }'`
|
|
|
- echo "fsgrp=\"$fsgrp\"; export fsgrp" >>.buildenv
|
|
|
- echo "fsgid=\"$fsgid\"; export fsgid" >>.buildenv
|
|
|
-
|
|
|
- # determine user and group for non-priviledged operations
|
|
|
- npusr=nobody
|
|
|
- npuid=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
|
|
|
- grep "^${npusr}:" | head -1 | awk -F: '{ print $3; }'`
|
|
|
- if [ ".$npuid" = . ]; then
|
|
|
- echo "Ops, your system lacks a 'nobody' user!"
|
|
|
- exit 1
|
|
|
- fi
|
|
|
- echo "npusr=\"$npusr\"; export npusr" >>.buildenv
|
|
|
- echo "npuid=\"$npuid\"; export npuid" >>.buildenv
|
|
|
- for npgrp in nobody nogroup; do
|
|
|
- npgid=`(cat /etc/group; ypcat group) 2>/dev/null |\
|
|
|
- grep "^${npgrp}:" | head -1 | awk -F: '{ print $3; }'`
|
|
|
- if [ ".$npgid" != . ]; then
|
|
|
- break
|
|
|
- fi
|
|
|
- done
|
|
|
- if [ ".$npgid" = . ]; then
|
|
|
- echo "Ops, your system lacks a 'nobody' or 'nogroup' group!"
|
|
|
- exit 1
|
|
|
- fi
|
|
|
- echo "npgrp=\"$npgrp\"; export npgrp" >>.buildenv
|
|
|
- echo "npgid=\"$npgid\"; export npgid" >>.buildenv
|
|
|
|
|
|
+ # determine path to aux.usrgrp.sh script
|
|
|
+ usrgrp=`SOURCE aux.usrgrp.sh`
|
|
|
+ echo "usrgrp=$usrgrp" >>./.buildenv
|
|
|
+
|
|
|
+ # determine user/group name/id pairs
|
|
|
+ # - bootstrapping: %{l_[smrn]{usr,grp}} is set via sed(1)
|
|
|
+ # - upgrading new: %{l_[smrn]{usr,grp}} is set via rpmmacros
|
|
|
+ # - upgrading old: %{l_[smrn]{usr,grp}} is not set at all
|
|
|
+ susr=""; [ ".%{?l_susr:set}" = .set ] && susr="%{l_susr}"
|
|
|
+ sgrp=""; [ ".%{?l_sgrp:set}" = .set ] && sgrp="%{l_sgrp}"
|
|
|
+ musr=""; [ ".%{?l_musr:set}" = .set ] && musr="%{l_musr}"
|
|
|
+ mgrp=""; [ ".%{?l_mgrp:set}" = .set ] && mgrp="%{l_mgrp}"
|
|
|
+ rusr=""; [ ".%{?l_rusr:set}" = .set ] && rusr="%{l_rusr}"
|
|
|
+ rgrp=""; [ ".%{?l_rgrp:set}" = .set ] && rgrp="%{l_rgrp}"
|
|
|
+ nusr=""; [ ".%{?l_nusr:set}" = .set ] && nusr="%{l_nusr}"
|
|
|
+ ngrp=""; [ ".%{?l_ngrp:set}" = .set ] && ngrp="%{l_ngrp}"
|
|
|
+ # compat:
|
|
|
+ usr=""; [ ".%{?l_fsusr:set}" = .set ] && usr="%{l_fsusr}"
|
|
|
+ grp=""; [ ".%{?l_fsgrp:set}" = .set ] && grp="%{l_fsgrp}"
|
|
|
+ eval `sh $usrgrp \
|
|
|
+ --usr="$usr" --grp="$grp" \
|
|
|
+ --susr="$susr" --sgrp="$sgrp" \
|
|
|
+ --musr="$musr" --mgrp="$mgrp" \
|
|
|
+ --rusr="$rusr" --rgrp="$rgrp" \
|
|
|
+ --nusr="$nusr" --ngrp="$ngrp"`
|
|
|
+ echo "susr=\"$susr\"; export susr" >>.buildenv
|
|
|
+ echo "sgrp=\"$sgrp\"; export sgrp" >>.buildenv
|
|
|
+ echo "musr=\"$musr\"; export musr" >>.buildenv
|
|
|
+ echo "mgrp=\"$mgrp\"; export mgrp" >>.buildenv
|
|
|
+ echo "rusr=\"$rusr\"; export rusr" >>.buildenv
|
|
|
+ echo "rgrp=\"$rgrp\"; export rgrp" >>.buildenv
|
|
|
+ echo "nusr=\"$nusr\"; export nusr" >>.buildenv
|
|
|
+ echo "ngrp=\"$ngrp\"; export ngrp" >>.buildenv
|
|
|
+
|
|
|
# determine installation location id
|
|
|
if [ ".%{?l_location:set}" = .set ]; then
|
|
|
loc="%{l_location}"
|
|
|
@@ -532,10 +521,10 @@ Provides: OpenPKG
|
|
|
cp bash $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bash
|
|
|
strip $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bash
|
|
|
)
|
|
|
- sed -e 's;@l_prefix@;%{l_prefix};g' \
|
|
|
+ sed -e "s;@l_prefix@;%{l_prefix};g" \
|
|
|
<`SOURCE rpmx.sh` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmx.sh
|
|
|
chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmx.sh
|
|
|
- sed -e 's;@l_prefix@;%{l_prefix};g' \
|
|
|
+ sed -e "s;@l_prefix@;%{l_prefix};g" \
|
|
|
<`SOURCE rpmx.pl` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmx.pl
|
|
|
chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmx.pl
|
|
|
|
|
|
@@ -595,19 +584,21 @@ Provides: OpenPKG
|
|
|
>$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/rpmrc
|
|
|
sed -e "s:@l_prefix@:%{l_prefix}:g" \
|
|
|
-e "s:@LOC@:$loc:g" \
|
|
|
- -e "s:@FSUSR@:$fsusr:g" \
|
|
|
- -e "s:@FSGRP@:$fsgrp:g" \
|
|
|
- -e "s:@NPUSR@:$npusr:g" \
|
|
|
- -e "s:@NPUID@:$npuid:g" \
|
|
|
- -e "s:@NPGRP@:$npgrp:g" \
|
|
|
- -e "s:@NPGID@:$npgid:g" \
|
|
|
+ -e "s:@SUSR@:$susr:g" \
|
|
|
+ -e "s:@SGRP@:$sgrp:g" \
|
|
|
+ -e "s:@MUSR@:$musr:g" \
|
|
|
+ -e "s:@MGRP@:$mgrp:g" \
|
|
|
+ -e "s:@RUSR@:$rusr:g" \
|
|
|
+ -e "s:@RGRP@:$rgrp:g" \
|
|
|
+ -e "s:@NUSR@:$nusr:g" \
|
|
|
+ -e "s:@NGRP@:$ngrp:g" \
|
|
|
<`SOURCE rpmmacros` \
|
|
|
>$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/rpmmacros
|
|
|
cp `SOURCE openpkg.pgp` \
|
|
|
$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/openpkg.pgp
|
|
|
|
|
|
%files
|
|
|
- %defattr(-,%{l_fsusr},%{l_fsgrp})
|
|
|
+ %defattr(-,%{l_musr},%{l_mgrp})
|
|
|
%{l_prefix}/README
|
|
|
%{l_prefix}/.bashrc
|
|
|
%{l_prefix}/.bash_login
|
|
|
@@ -726,106 +717,165 @@ Provides: OpenPKG
|
|
|
rm -rf %{name}-%{version}
|
|
|
|
|
|
%pre
|
|
|
- [ ".$1" != .1 ] && exit 0
|
|
|
+ # always performed for upgrades and because it doesn't harm!
|
|
|
+ #[ ".$1" != .1 ] && exit 0
|
|
|
|
|
|
# this procedure is only usable with root priviledges
|
|
|
# (for non-root installations it is not required at all)
|
|
|
- thisuser=`(id -un) 2>/dev/null ||\
|
|
|
- (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
|
|
|
- (whoami) 2>/dev/null ||\
|
|
|
- (who am i | cut "-d " -f1) 2>/dev/null ||\
|
|
|
- echo $LOGNAME`
|
|
|
+ cusr=`(id -un) 2>/dev/null ||\
|
|
|
+ (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
|
|
|
+ (whoami) 2>/dev/null ||\
|
|
|
+ (who am i | cut "-d " -f1) 2>/dev/null ||\
|
|
|
+ echo $LOGNAME`
|
|
|
|
|
|
# determine runtime details (for both inside and outside RPM!!)
|
|
|
- user="$fsusr"; [ ".$fsusr" = . ] && fsusr="%{l_fsusr}"
|
|
|
- group="$fsgrp"; [ ".$fsgrp" = . ] && fsgrp="%{l_fsgrp}"
|
|
|
- prefix="$p"; [ ".$prefix" = . ] && prefix="%{l_prefix}"
|
|
|
+ # bootstrapping: $xxx is set
|
|
|
+ # upgrading: %{l_xxx} is set
|
|
|
+ [ ".$susr" = . ] && susr="%{l_susr}"
|
|
|
+ [ ".$sgrp" = . ] && sgrp="%{l_sgrp}"
|
|
|
+ [ ".$musr" = . ] && musr="%{l_musr}"
|
|
|
+ [ ".$mgrp" = . ] && mgrp="%{l_mgrp}"
|
|
|
+ [ ".$rusr" = . ] && rusr="%{l_rusr}"
|
|
|
+ [ ".$rgrp" = . ] && rgrp="%{l_rgrp}"
|
|
|
+ [ ".$nusr" = . ] && nusr="%{l_nusr}"
|
|
|
+ [ ".$ngrp" = . ] && ngrp="%{l_ngrp}"
|
|
|
+
|
|
|
+ # determine prefix
|
|
|
+ prefix="%{l_prefix}"
|
|
|
prefix=`echo "$prefix" | sed -e 's;//*;/;g' -e 's;/$;;'`
|
|
|
- name=`echo "$prefix" | sed -e 's;/;;g'`
|
|
|
+
|
|
|
+ # determine user/group ids
|
|
|
+ for class in s m r n; do
|
|
|
+ eval "xusr=\"\$${class}usr\""
|
|
|
+ eval "xgrp=\"\$${class}grp\""
|
|
|
+ eval "xuid=\"\$${class}uid\""
|
|
|
+ eval "xgid=\"\$${class}gid\""
|
|
|
+ if [ ".$xuid" = . ]; then
|
|
|
+ xuid=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
|
|
|
+ grep "^${xusr}:" | awk -F: '{ print $3; }'`
|
|
|
+ if [ ".$xuid" = . ]; then
|
|
|
+ # seek for a reasonably uid/gid pair
|
|
|
+ xuid=1000
|
|
|
+ ok=0
|
|
|
+ while [ ".$ok" = .0 ]; do
|
|
|
+ eval "u_exists=\$u_exists_$xuid"
|
|
|
+ if [ ".$u_exists" = . ]; then
|
|
|
+ u_exists=`(cat /etc/passwd; ypcat passwd) 2>/dev/null | grep "^[^:]*:[^:]*:$xuid:"`
|
|
|
+ fi
|
|
|
+ eval "g_exists=\$g_exists_$xuid"
|
|
|
+ if [ ".$g_exists" = . ]; then
|
|
|
+ g_exists=`(cat /etc/group; ypcat group) 2>/dev/null | grep "^[^:]*:[^:]*:$xuid:"`
|
|
|
+ fi
|
|
|
+ if [ ".$u_exists" = . -a ".$g_exists" = . ]; then
|
|
|
+ ok=1
|
|
|
+ break
|
|
|
+ fi
|
|
|
+ xuid=`expr $xuid + 1`
|
|
|
+ done
|
|
|
+ eval "u_exists_$xuid=yes"
|
|
|
+ eval "g_exists_$xuid=yes"
|
|
|
+ fi
|
|
|
+ fi
|
|
|
+ if [ ".$xgid" = . ]; then
|
|
|
+ xgid=`(cat /etc/group; ypcat group) 2>/dev/null |\
|
|
|
+ grep "^${xgrp}:" | awk -F: '{ print $3; }'`
|
|
|
+ if [ ".$xgid" = . ]; then
|
|
|
+ xgid="$xuid"
|
|
|
+ fi
|
|
|
+ fi
|
|
|
+ eval "${class}uid=\"$xuid\""
|
|
|
+ eval "${class}gid=\"$xgid\""
|
|
|
+ done
|
|
|
|
|
|
# determine platform id
|
|
|
s=`(uname -s) 2>/dev/null` || s='Unknown'
|
|
|
r=`(uname -r) 2>/dev/null` || r='0.0'
|
|
|
plid="${s}/${r}"
|
|
|
|
|
|
- # create the hierarchy user/group
|
|
|
- exists=`(cat /etc/passwd; ypcat passwd) 2>/dev/null | grep "^$user:"`
|
|
|
- if [ ".$exists" = . ]; then
|
|
|
- if [ ".$thisuser" != ".root" ]; then
|
|
|
- echo "openpkg:WARNING: skipping creation of dedicated OpenPKG user/group $ugid" 1>&2
|
|
|
- echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
|
|
|
- else
|
|
|
- # seek for a reasonably uid/gid pair
|
|
|
- ugid=1000
|
|
|
- ok=0
|
|
|
- while [ ".$ok" = .0 ]; do
|
|
|
- u_exists=`(cat /etc/passwd; ypcat passwd) 2>/dev/null | grep "^[^:]*:[^:]*:$ugid:"`
|
|
|
- g_exists=`(cat /etc/group; ypcat group) 2>/dev/null | grep "^[^:]*:[^:]*:$ugid:"`
|
|
|
- if [ ".$u_exists" = . -a ".$g_exists" = . ]; then
|
|
|
- ok=1
|
|
|
- break
|
|
|
- fi
|
|
|
- ugid=`expr $ugid + 1`
|
|
|
- done
|
|
|
-
|
|
|
- # add entry to passwd database
|
|
|
- shell="${prefix}/lib/openpkg/bash"
|
|
|
- realname="${prefix} OpenPKG"
|
|
|
- case "$plid" in
|
|
|
- FreeBSD/* | NetBSD/* )
|
|
|
- file=/etc/master.passwd
|
|
|
- entry="${user}:*:${ugid}:${ugid}::0:0:${realname}:${prefix}:${shell}"
|
|
|
- update="(PATH=\$PATH:/usr/sbin; pwd_mkdb -p /etc/master.passwd)"
|
|
|
- ;;
|
|
|
- Linux/* )
|
|
|
- file=/etc/passwd
|
|
|
- entry="${user}:*:${ugid}:${ugid}:${realname}:${prefix}:${shell}"
|
|
|
- update="(PATH=\$PATH:/usr/sbin; pwconv)"
|
|
|
- ;;
|
|
|
- SunOS/5.* )
|
|
|
- file=/etc/passwd
|
|
|
- entry="${user}:*:${ugid}:${ugid}:${realname}:${prefix}:${shell}"
|
|
|
- update="(PATH=\$PATH:/usr/sbin; pwconv)"
|
|
|
- ;;
|
|
|
- OSF1/V5.* )
|
|
|
- file=/etc/passwd
|
|
|
- entry="${user}:*:${ugid}:${ugid}:${realname}:${prefix}:${shell}"
|
|
|
- update="(PATH=\$PATH:/usr/sbin; mkpasswd /etc/passwd)"
|
|
|
- ;;
|
|
|
- HP-UX/* )
|
|
|
- file=/etc/passwd
|
|
|
- entry="${user}:*:${ugid}:${ugid}:${realname}:${prefix}:${shell}"
|
|
|
- update=":"
|
|
|
- ;;
|
|
|
- esac
|
|
|
- cp $file $file.old
|
|
|
- (grep -v '^+:' $file.old; echo $entry; grep '^+:' $file.old) >$file
|
|
|
- rm -f $file.old >/dev/null 2>&1
|
|
|
- eval $update
|
|
|
-
|
|
|
- # add entry to group database
|
|
|
- file=/etc/group
|
|
|
- entry="${user}:*:${ugid}:${user}"
|
|
|
- cp $file $file.old
|
|
|
- (grep -v '^+:' $file.old; echo $entry; grep '^+:' $file.old) >$file
|
|
|
- rm -f $file.old >/dev/null 2>&1
|
|
|
- fi
|
|
|
- fi
|
|
|
-
|
|
|
# add entry to /etc/shells
|
|
|
shell="${prefix}/lib/openpkg/bash"
|
|
|
exists=`cat /etc/shells 2>/dev/null | grep "^$shell"`
|
|
|
if [ ".$exists" = . ]; then
|
|
|
- if [ ".$thisuser" != ".root" ]; then
|
|
|
+ if [ ".$cusr" != ".root" ]; then
|
|
|
echo "openpkg:WARNING: skipping addition of $shell to /etc/shells" 1>&2
|
|
|
echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
|
|
|
else
|
|
|
echo "${shell}" >>/etc/shells
|
|
|
fi
|
|
|
fi
|
|
|
-
|
|
|
+
|
|
|
+ # create the hierarchy user/group
|
|
|
+ for req in "superuser:${susr}:${suid}:${sgrp}:${sgid}" \
|
|
|
+ "management:${musr}:${muid}:${mgrp}:${mgid}" \
|
|
|
+ "restricted:${rusr}:${ruid}:${rgrp}:${rgid}" \
|
|
|
+ "non-priviledged:${nusr}:${nuid}:${ngrp}:${ngid}"; do
|
|
|
+ # split request into class/usr/uid/grp/gid
|
|
|
+ OIFS="$IFS"; IFS=":"; set -- $req; IFS="$OIFS"
|
|
|
+ class="$1"; usr="$2"; uid="$3"; grp="$4"; gid="$5"
|
|
|
+
|
|
|
+ # check whether user already exists
|
|
|
+ exists=`(cat /etc/passwd; cat /etc/master.passwd; ypcat passwd) 2>/dev/null | grep "^$usr:"`
|
|
|
+ if [ ".$exists" = . ]; then
|
|
|
+ if [ ".$cusr" != ".root" ]; then
|
|
|
+ echo "openpkg:WARNING: skipping creation of OpenPKG $class user $usr" 1>&2
|
|
|
+ echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
|
|
|
+ else
|
|
|
+ # add entry to passwd database
|
|
|
+ realname="${prefix} OpenPKG ($class)"
|
|
|
+ case "$plid" in
|
|
|
+ FreeBSD/* | NetBSD/* )
|
|
|
+ file=/etc/master.passwd
|
|
|
+ entry="${usr}:*:${uid}:${gid}::0:0:${realname}:${prefix}:${shell}"
|
|
|
+ update="(PATH=\$PATH:/usr/sbin; pwd_mkdb -p /etc/master.passwd)"
|
|
|
+ ;;
|
|
|
+ Linux/* )
|
|
|
+ file=/etc/passwd
|
|
|
+ entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
|
|
|
+ update="(PATH=\$PATH:/usr/sbin; pwconv)"
|
|
|
+ ;;
|
|
|
+ SunOS/5.* )
|
|
|
+ file=/etc/passwd
|
|
|
+ entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
|
|
|
+ update="(PATH=\$PATH:/usr/sbin; pwconv)"
|
|
|
+ ;;
|
|
|
+ OSF1/V5.* )
|
|
|
+ file=/etc/passwd
|
|
|
+ entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
|
|
|
+ update="(PATH=\$PATH:/usr/sbin; mkpasswd /etc/passwd)"
|
|
|
+ ;;
|
|
|
+ HP-UX/* )
|
|
|
+ file=/etc/passwd
|
|
|
+ entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
|
|
|
+ update=":"
|
|
|
+ ;;
|
|
|
+ esac
|
|
|
+ cp $file $file.bak && \
|
|
|
+ (grep -v '^+:' $file.bak; echo $entry; grep '^+:' $file.bak) >$file
|
|
|
+ rm -f $file.bak >/dev/null 2>&1
|
|
|
+ eval $update
|
|
|
+ fi
|
|
|
+ fi
|
|
|
+
|
|
|
+ # check whether group already exists
|
|
|
+ exists=`(cat /etc/group; ypcat group) 2>/dev/null | grep "^$grp:"`
|
|
|
+ if [ ".$exists" = . ]; then
|
|
|
+ if [ ".$cusr" != ".root" ]; then
|
|
|
+ echo "openpkg:WARNING: skipping creation of OpenPKG $class group $grp" 1>&2
|
|
|
+ echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
|
|
|
+ else
|
|
|
+ # add entry to group database
|
|
|
+ file=/etc/group
|
|
|
+ entry="${grp}:*:${gid}:${usr}"
|
|
|
+ cp $file $file.bak && \
|
|
|
+ (grep -v '^+:' $file.bak; echo $entry; grep '^+:' $file.bak) >$file
|
|
|
+ rm -f $file.bak >/dev/null 2>&1
|
|
|
+ fi
|
|
|
+ fi
|
|
|
+ done
|
|
|
+
|
|
|
# create the startup/shutdown transfer script
|
|
|
- if [ ".$thisuser" != ".root" ]; then
|
|
|
+ name=`echo "$prefix" | sed -e 's;/;;g'`
|
|
|
+ if [ ".$cusr" != ".root" ]; then
|
|
|
echo "openpkg:WARNING: skipping creation of system run-command hooks" 1>&2
|
|
|
echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
|
|
|
else
|
|
|
@@ -993,7 +1043,7 @@ Provides: OpenPKG
|
|
|
fi
|
|
|
|
|
|
# create the cron transfer entries
|
|
|
- if [ ".$thisuser" != ".root" ]; then
|
|
|
+ if [ ".$cusr" != ".root" ]; then
|
|
|
echo "openpkg:WARNING: skipping creation of system cron hooks" 1>&2
|
|
|
echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
|
|
|
else
|
|
|
@@ -1046,7 +1096,7 @@ Provides: OpenPKG
|
|
|
if [ ".$1" = .2 ]; then
|
|
|
( sleep 2
|
|
|
%{l_prefix}/bin/rpm --rebuilddb
|
|
|
- chown %{l_fsusr}:%{l_fsgrp} %{l_prefix}/RPM/DB/* || true
|
|
|
+ chown %{l_musr}:%{l_mgrp} %{l_prefix}/RPM/DB/* || true
|
|
|
) </dev/null >/dev/null 2>/dev/null &
|
|
|
fi
|
|
|
|
|
|
@@ -1073,72 +1123,99 @@ Provides: OpenPKG
|
|
|
##
|
|
|
|
|
|
# determine current user
|
|
|
- thisuser=`(id -un) 2>/dev/null ||\
|
|
|
- (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
|
|
|
- (whoami) 2>/dev/null ||\
|
|
|
- (who am i | cut "-d " -f1) 2>/dev/null ||\
|
|
|
- echo $LOGNAME`
|
|
|
+ cusr=`(id -un) 2>/dev/null ||\
|
|
|
+ (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
|
|
|
+ (whoami) 2>/dev/null ||\
|
|
|
+ (who am i | cut "-d " -f1) 2>/dev/null ||\
|
|
|
+ echo $LOGNAME`
|
|
|
|
|
|
# determine runtime details (for both inside and outside RPM!!)
|
|
|
- user="%{l_fsusr}"
|
|
|
- group="%{l_fsgrp}"
|
|
|
+ user="%{l_musr}"
|
|
|
+ group="%{l_mgrp}"
|
|
|
prefix="%{l_prefix}"
|
|
|
prefix=`echo "$prefix" | sed -e 's;//*;/;g' -e 's;/$;;'`
|
|
|
- name=`echo "$prefix" | sed -e 's;/;;g'`
|
|
|
|
|
|
# determine platform id
|
|
|
s=`(uname -s) 2>/dev/null` || s='Unknown'
|
|
|
r=`(uname -r) 2>/dev/null` || r='0.0'
|
|
|
plid="${s}/${r}"
|
|
|
|
|
|
- # remove the hierarchy user/group
|
|
|
- exists=`(cat /etc/passwd; cat /etc/master.passwd; ypcat passwd) 2>/dev/null | grep "^$user:"`
|
|
|
- if [ ".$exists" != . ]; then
|
|
|
- if [ ".$thisuser" != ".root" ]; then
|
|
|
- echo "openpkg:WARNING: skipping deletion of dedicated OpenPKG user/group $ugid" 1>&2
|
|
|
- echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
|
|
|
- else
|
|
|
- case "$plid" in
|
|
|
- FreeBSD/* | NetBSD/* )
|
|
|
- cp /etc/master.passwd /etc/master.passwd.bak
|
|
|
- grep -v "^${user}:" /etc/master.passwd.bak >/etc/master.passwd
|
|
|
- (PATH="$PATH:/usr/sbin"; pwd_mkdb -p /etc/master.passwd)
|
|
|
- ;;
|
|
|
- Linux/* | SunOS/5.* )
|
|
|
- cp /etc/passwd /etc/passwd.bak
|
|
|
- grep -v "^${user}:" /etc/passwd.bak >/etc/passwd
|
|
|
- (PATH="$PATH:/usr/sbin"; pwconv)
|
|
|
- ;;
|
|
|
- OSF1/V5.* )
|
|
|
- cp /etc/passwd /etc/passwd.bak
|
|
|
- grep -v "^${user}:" /etc/passwd.bak >/etc/passwd
|
|
|
- (PATH="$PATH:/usr/sbin"; mkpasswd /etc/passwd)
|
|
|
- ;;
|
|
|
- HP-UX/* )
|
|
|
- cp /etc/passwd /etc/passwd.bak
|
|
|
- grep -v "^${user}:" /etc/passwd.bak >/etc/passwd
|
|
|
- ;;
|
|
|
- esac
|
|
|
- cp /etc/group /etc/group.bak
|
|
|
- grep -v "^${user}:" /etc/group.bak >/etc/group
|
|
|
- fi
|
|
|
- fi
|
|
|
-
|
|
|
# remove entry in /etc/shells
|
|
|
shell="${prefix}/lib/openpkg/bash"
|
|
|
exists=`cat /etc/shells 2>/dev/null | grep "^$shell"`
|
|
|
if [ ".$exists" != . ]; then
|
|
|
- if [ ".$thisuser" != ".root" ]; then
|
|
|
+ if [ ".$cusr" != ".root" ]; then
|
|
|
echo "openpkg:WARNING: skipping deletion of $shell from /etc/shells" 1>&2
|
|
|
echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
|
|
|
else
|
|
|
- cp /etc/shells /etc/shells.bak
|
|
|
+ cp /etc/shells /etc/shells.bak && \
|
|
|
grep -v "^${shell}" /etc/shells.bak >/etc/shells
|
|
|
fi
|
|
|
fi
|
|
|
|
|
|
+ # remove the hierarchy user/group
|
|
|
+ for req in "super-user:%{l_susr}:%{l_suid}:%{l_sgrp}:%{l_sgid}" \
|
|
|
+ "management:%{l_musr}:%{l_muid}:%{l_mgrp}:%{l_mgid}" \
|
|
|
+ "restricted:%{l_rusr}:%{l_ruid}:%{l_rgrp}:%{l_rgid}" \
|
|
|
+ "non-priviledged:%{l_nusr}:%{l_nuid}:%{l_ngrp}:%{l_ngid}"; do
|
|
|
+ # split request into class/usr/uid/grp/gid
|
|
|
+ OIFS="$IFS"; IFS=":"; set -- $req; IFS="$OIFS"
|
|
|
+ class="$1"; usr="$2"; uid="$3"; grp="$4"; gid="$5"
|
|
|
+
|
|
|
+ # check whether user already exists
|
|
|
+ exists=`(cat /etc/passwd; cat /etc/master.passwd; ypcat passwd) 2>/dev/null | grep "^$usr:"`
|
|
|
+ if [ ".$exists" != . ]; then
|
|
|
+ if [ ".$cusr" != ".root" ]; then
|
|
|
+ echo "openpkg:WARNING: skipping deletion of OpenPKG $class user $usr" 1>&2
|
|
|
+ echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
|
|
|
+ elif [ ".$usr" = ".root" ]; then
|
|
|
+ echo "openpkg:WARNING: skipping deletion of OpenPKG $class user $usr" 1>&2
|
|
|
+ echo "openpkg:WARNING: (would remove system standard user)" 1>&2
|
|
|
+ else
|
|
|
+ case "$plid" in
|
|
|
+ FreeBSD/* | NetBSD/* )
|
|
|
+ cp /etc/master.passwd /etc/master.passwd.bak && \
|
|
|
+ grep -v "^${usr}:" /etc/master.passwd.bak >/etc/master.passwd
|
|
|
+ (PATH="$PATH:/usr/sbin"; pwd_mkdb -p /etc/master.passwd)
|
|
|
+ ;;
|
|
|
+ Linux/* | SunOS/5.* )
|
|
|
+ cp /etc/passwd /etc/passwd.bak && \
|
|
|
+ grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
|
|
|
+ (PATH="$PATH:/usr/sbin"; pwconv)
|
|
|
+ ;;
|
|
|
+ OSF1/V5.* )
|
|
|
+ cp /etc/passwd /etc/passwd.bak && \
|
|
|
+ grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
|
|
|
+ (PATH="$PATH:/usr/sbin"; mkpasswd /etc/passwd)
|
|
|
+ ;;
|
|
|
+ HP-UX/* )
|
|
|
+ cp /etc/passwd /etc/passwd.bak && \
|
|
|
+ grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
|
|
|
+ ;;
|
|
|
+ esac
|
|
|
+ fi
|
|
|
+ fi
|
|
|
+
|
|
|
+ # check whether group already exists
|
|
|
+ exists=`(cat /etc/group; ypcat group) 2>/dev/null | grep "^$grp:"`
|
|
|
+ if [ ".$exists" = . ]; then
|
|
|
+ if [ ".$cusr" != ".root" ]; then
|
|
|
+ echo "openpkg:WARNING: skipping deletion of OpenPKG $class group $grp" 1>&2
|
|
|
+ echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
|
|
|
+ elif [ ".$usr" = ".root" ] || [ ".$grp" = ".root" ] || [ ".$grp" = ".wheel" ]; then
|
|
|
+ echo "openpkg:WARNING: skipping deletion of OpenPKG $class group $grp" 1>&2
|
|
|
+ echo "openpkg:WARNING: (would remove system standard group)" 1>&2
|
|
|
+ else
|
|
|
+ # delete group entry
|
|
|
+ cp /etc/group /etc/group.bak && \
|
|
|
+ grep -v "^${grp}:" /etc/group.bak >/etc/group
|
|
|
+ fi
|
|
|
+ fi
|
|
|
+ done
|
|
|
+
|
|
|
# remove the startup/shutdown transfer ripts
|
|
|
- if [ ".$thisuser" != ".root" ]; then
|
|
|
+ name=`echo "$prefix" | sed -e 's;/;;g'`
|
|
|
+ if [ ".$cusr" != ".root" ]; then
|
|
|
echo "openpkg:WARNING: skipping deletion of system run-command hooks" 1>&2
|
|
|
echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
|
|
|
else
|
|
|
@@ -1190,7 +1267,7 @@ Provides: OpenPKG
|
|
|
fi
|
|
|
|
|
|
# remove the cron transfer entries
|
|
|
- if [ ".$thisuser" != ".root" ]; then
|
|
|
+ if [ ".$cusr" != ".root" ]; then
|
|
|
echo "openpkg:WARNING: skipping deletion of system cron hooks" 1>&2
|
|
|
echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
|
|
|
else
|
|
|
@@ -1211,9 +1288,9 @@ Provides: OpenPKG
|
|
|
export EDITOR
|
|
|
export VISUAL
|
|
|
p=`echo $prefix | sed -e 's;/;\\\\\\\\/;g'`
|
|
|
- ( echo "cp \$1 \$1.old"
|
|
|
- echo "cat \$1.old | sed -e \"/<OpenPKG prefix=$p pkg=openpkg>/,/<\\\\/OpenPKG>/d\" >\$1"
|
|
|
- echo "rm -f \$1.old"
|
|
|
+ ( echo "cp \$1 \$1.bak"
|
|
|
+ echo "cat \$1.bak | sed -e \"/<OpenPKG prefix=$p pkg=openpkg>/,/<\\\\/OpenPKG>/d\" >\$1"
|
|
|
+ echo "rm -f \$1.bak"
|
|
|
) >$EDITOR
|
|
|
chmod a+x $EDITOR
|
|
|
(PATH="$PATH:/usr/bin"; crontab -e)
|