Prevent the user from running wineinstall as root, add script commands

so we 'su root' for installing and other commands that require root
access.  Fix modification time comparison of wrong file.  Added
missing sed line. Always 'make' before we run make install so no build
files become owned by root.
This commit is contained in:
Chris Morgan 2002-04-01 20:56:51 +00:00 committed by Alexandre Julliard
parent 869b044249
commit ee626fe6fd
1 changed files with 136 additions and 91 deletions

View File

@ -68,6 +68,12 @@
# Feb 20 2002 - Adam D. Moss # Feb 20 2002 - Adam D. Moss
# Partially revert previous changes, force configure to write an # Partially revert previous changes, force configure to write an
# old-style config.cache # old-style config.cache
# Mar 27 2002 - Chris Morgan
# prevent the user from running wineinstall as root
# add script commands so we su root for 'make install' and other commands
# that require root access
# add text to tell the user we need to run stuff as root so they don't
# think we are trying to pull something funny
#--- defaults (change these if you are a packager) #--- defaults (change these if you are a packager)
CONFARGS="--enable-opengl" # configure args, e.g. --prefix=/usr --sysconfdir=/etc CONFARGS="--enable-opengl" # configure args, e.g. --prefix=/usr --sysconfdir=/etc
@ -167,7 +173,7 @@ function create_windows_directories {
# startup... # startup...
echo "WINE Installer v0.71" echo "WINE Installer v0.72"
echo echo
if [ "$BINDIST" = 'no' ] if [ "$BINDIST" = 'no' ]
@ -181,6 +187,14 @@ then {
} }
fi fi
if [ `whoami` == 'root' ]
then {
echo "You are running wineinstall as root, this is not advisable. Please rerun as a user."
echo "Aborting."
exit 1
}
fi
# check whether RPM installed, and if it is, remove any old wine rpm. # check whether RPM installed, and if it is, remove any old wine rpm.
hash rpm &>/dev/null hash rpm &>/dev/null
RET=$? RET=$?
@ -189,8 +203,10 @@ if [ $RET -eq 0 ]; then
echo "Warning: Old Wine RPM install detected. Do you want to remove it first?" echo "Warning: Old Wine RPM install detected. Do you want to remove it first?"
conf_yesno_answer "(yes/no) " conf_yesno_answer "(yes/no) "
if [ "$ANSWER" = 'yes' ]; then if [ "$ANSWER" = 'yes' ]; then
echo "We need to remove the rpm as root, please enter your root password"
echo
echo Starting wine rpm removal... echo Starting wine rpm removal...
rpm -e wine; RET=$? su -c "rpm -e wine; RET=$?"
if [ $RET -eq 0 ]; then if [ $RET -eq 0 ]; then
echo Done. echo Done.
else else
@ -199,7 +215,8 @@ if [ $RET -eq 0 ]; then
fi fi
else else
echo "Sorry, I won't install Wine when an rpm version is still installed." echo "Sorry, I won't install Wine when an rpm version is still installed."
echo "(Wine support suffered from way too many conflicts)" echo "(Wine support suffered from way too many conflicts between RPM"
echo "and source installs)"
echo "Have a nice day !" echo "Have a nice day !"
exit 1 exit 1
fi fi
@ -218,6 +235,7 @@ fi
if [ -f config.cache ] && [ -f Makefile ] && [ Makefile -nt configure ] if [ -f config.cache ] && [ -f Makefile ] && [ Makefile -nt configure ]
then { then {
echo
echo "I see that WINE has already been configured, so I'll skip that." echo "I see that WINE has already been configured, so I'll skip that."
std_sleep std_sleep
# load configure results # load configure results
@ -248,82 +266,109 @@ else {
} }
fi fi
# now do the compilation # now do the compilation and install, we need to always do this because we
# don't want the 'make install' command we might run to run 'make' as root
if [ -f wine ] && [ wine -nt config.cache ]
then {
echo "Hmm, looks like WINE is already compiled. I'll skip that too, I guess."
std_sleep
}
else {
echo "Compiling WINE. Grab a lunch or two, rent a video, or whatever,"
echo "in the meantime..."
echo
std_sleep
if ! { make depend && make; }
then {
echo
echo "Compilation failed, aborting install."
exit 1
}
fi
echo
}
fi
# and installation, if root
if [ `whoami` != 'root' ] if [ `whoami` != 'root' ]
then { then {
echo "You aren't root, so I'll skip the make install." # ask the user if they want to build and install wine
# setup to run from current directory
DLLPATH="$PWD/dlls"
if [ -z "$LD_LIBRARY_PATH" ]
then LD_LIBRARY_PATH="$PWD:$DLLPATH"
else LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD:$DLLPATH"
fi
export LD_LIBRARY_PATH
DEBUGGER="$PWD/$HDEBUGGER"
echo
echo "NOTE! To run Wine without installing, you must set the environment variable"
echo "LD_LIBRARY_PATH to $PWD:$DLLPATH"
echo "in your logon scripts."
echo echo
echo "We need to install wine as root user, do you want us to build wine,"
echo "'su root' and install Wine? Enter 'no' to continue without installing"
conf_yesno_answer "(yes/no) "
if [ "$ANSWER" = "yes" ]
then {
# start out with the basic command
sucommand="make install"
# if the user doesn't have $libdir in their ld.so.conf add this
# to our sucommand string
if [ -f /etc/ld.so.conf ] && ! grep -qs "$libdir" /etc/ld.so.conf
then {
echo
echo "$libdir doesn't exist in your /etc/ld.so.conf, it will be added"
echo "when we perform the install..."
sucommand="echo $libdir>>/etc/ld.so.conf;ldconfig;$sucommand"
}
fi
# see if wine is installed on the users system, if not prompt them
# and then exit
if [ ! `which wine` ]
then
echo "Could not find wine on your system. Run wineinstall as root to install wine"
echo "before re-running wineinstall as a user."
echo echo
echo "Exiting wineinstall"
exit 1; echo "Compiling WINE. Grab a lunch or two, rent a video, or whatever,"
echo "in the meantime..."
echo
std_sleep
# try to just make wine, if this fails 'make depend' and try to remake
if ! { make; }
then {
if ! { make depend && make; }
then {
echo
echo "Compilation failed, aborting install."
exit 1
}
fi
}
fi
echo
echo "Performing 'make install' as root to install binaries, enter root password"
std_sleep
if ! su root -c"$sucommand"
then {
echo
echo "Either you entered an incorrect password or we failed to run"
echo "'$sucommand' correctly."
echo "If you didn't enter an incorrect password then please report this"
echo "error to wine-devel@winehq.com."
echo
echo "Installation failed, aborting."
exit 1
}
fi
echo
# see if wine is installed on the users system, if not prompt them
# and then exit
if [ ! `which wine` ]
then
echo "Could not find wine on your system. Run wineinstall as root to install wine"
echo "before re-running wineinstall as a user."
echo
echo "Exiting wineinstall"
exit 1;
fi
}
else {
# user didn't want to install wine so tell them about running from the
# current directory and set some stuff up for them
# setup to run from current directory
DLLPATH="$PWD/dlls"
if [ -z "$LD_LIBRARY_PATH" ]
then LD_LIBRARY_PATH="$PWD:$DLLPATH"
else LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD:$DLLPATH"
fi
export LD_LIBRARY_PATH
DEBUGGER="$PWD/$HDEBUGGER"
echo
echo "NOTE! To run Wine without installing, you must set the environment variable"
echo "LD_LIBRARY_PATH to $PWD:$DLLPATH"
echo "in your logon scripts."
echo
}
fi fi
} }
else { else {
echo "Now installing binaries onto the system..." echo "You are running wineinstall as root, this is not advisable. Please rerun as a user."
echo echo "Aborting."
std_sleep exit 1
if ! make install
then {
echo
echo "Installation failed, aborting."
exit 1
}
fi
if [ -f /etc/ld.so.conf ] && ! grep -qs "$libdir" /etc/ld.so.conf
then {
echo
echo "$libdir didn't exist in your /etc/ld.so.conf, adding it now..."
echo "$libdir" >>/etc/ld.so.conf
echo "Re-running ldconfig..."
eval "$ac_cv_path_LDCONFIG"
}
fi
} }
fi fi # [ `whoami` != 'root' ]
} }
fi # BINDIST fi # BINDIST
@ -359,28 +404,27 @@ then {
conf_yesno_answer "(yes/no) " conf_yesno_answer "(yes/no) "
DOLOCALCONF="$ANSWER" DOLOCALCONF="$ANSWER"
else else
echo "Create local config file ~/.wine/config?" # if the user has an existing config file ask them if they want us to
conf_yesno_answer "(yes/no) " # overwrite it, otherwise just ask them if they want to create one
echo if [ -f "$LCONF" ]
DOLOCALCONF="$ANSWER"
if [ "$ANSWER" = 'no' ]
then then
conf_question high need_root \ echo "Found existing $LCONF, do you want to overwrite this"
"Aborting install. Try again as root to generate a system wine.conf." echo "existing Wine configuration file?"
exit 1 conf_yesno_answer "(yes/no) "
fi DOLOCALCONF="$ANSWER"
fi echo
else {
if [ -f "$LCONF" ] echo "Create local config file ~/.wine/config?"
then conf_yesno_answer "(yes/no) "
echo "Found existing $LCONF, if you continue this file will be" DOLOCALCONF="$ANSWER"
echo "overwritten. Continue running wineinstall?" echo
conf_yesno_answer "(yes/no) " if [ "$ANSWER" = 'no' ]
echo then
if [ "$ANSWER" = 'no' ] conf_question high need_root \
then "Aborting install. Try again as root to generate a system wine.conf."
echo "Exiting wineinstall" exit 1
exit 1 fi
}
fi fi
fi fi
} }
@ -534,6 +578,7 @@ fi
# (not to be done if windows registry exists) # (not to be done if windows registry exists)
if [ "$DOREG" = 'auto' ] if [ "$DOREG" = 'auto' ]
then { then {
CROOT=`sed -n '/^\[Drive C\]$/,/^\[.*\]$/ s/^Path=\(.*\)/\1/p' $CONF`
echo "Checking for real Windows registry..." echo "Checking for real Windows registry..."
if [ -f "$CROOT/windows/system.dat" ] if [ -f "$CROOT/windows/system.dat" ]
then DOREG=no then DOREG=no