Kaydet (Commit) c15b96a4 authored tarafından Katarina Behrens's avatar Katarina Behrens Kaydeden (comit) Stephan Bergmann

C++ solution of 'unopkg can't be used by root'

This way should cover all un*x-like OSes (unopkg.sh excludes
e.g. OS X)
This effectively reverts commits 723e0999 and
9444ffc9

Change-Id: I0b4425d1c9eff8e51e5d9a4dab35775084106a23
(cherry picked from commit faa2c06226146e3ab4b7fa8096cf213ea9d52a23)
üst 56813553
...@@ -49,8 +49,6 @@ AIX) ...@@ -49,8 +49,6 @@ AIX)
;; ;;
esac esac
help_mode=0
isnotuser=0
for arg in $@ for arg in $@
do do
case "$arg" in case "$arg" in
...@@ -59,25 +57,10 @@ do ...@@ -59,25 +57,10 @@ do
-env:*) BOOTSTRAPVARS=$BOOTSTRAPVARS" ""$arg";; -env:*) BOOTSTRAPVARS=$BOOTSTRAPVARS" ""$arg";;
# make sure shared extensions will be readable by all users # make sure shared extensions will be readable by all users
--shared) --shared) umask 0022;;
umask 0022
isnotuser=1
;;
--bundled) isnotuser=1;;
-h|--help) help_mode=1;;
esac esac
done done
# we don't really want root to run unopkg without --shared or --bundled option
# but we might at least let him read help
if [ "$(id -u)" -eq "0" ]; then
if [ $isnotuser -eq 0 ] && [ $help_mode -eq 0 ]; then
echo "Cannot run '${0} $*' as root without --shared or --bundled option."
exit 1
fi
fi
# extend the ld_library_path for java: javaldx checks the sofficerc for us # extend the ld_library_path for java: javaldx checks the sofficerc for us
if [ -x "${sd_prog}/javaldx" ] ; then if [ -x "${sd_prog}/javaldx" ] ; then
my_path=`"${sd_prog}/javaldx" $BOOTSTRAPVARS \ my_path=`"${sd_prog}/javaldx" $BOOTSTRAPVARS \
......
...@@ -42,6 +42,9 @@ ...@@ -42,6 +42,9 @@
#include <com/sun/star/ui/dialogs/XDialogClosedListener.hpp> #include <com/sun/star/ui/dialogs/XDialogClosedListener.hpp>
#include <com/sun/star/bridge/BridgeFactory.hpp> #include <com/sun/star/bridge/BridgeFactory.hpp>
#include <stdio.h> #include <stdio.h>
#if defined(UNX)
#include <unistd.h>
#endif
#include <vector> #include <vector>
...@@ -186,6 +189,7 @@ extern "C" int unopkg_main() ...@@ -186,6 +189,7 @@ extern "C" int unopkg_main()
bool option_verbose = false; bool option_verbose = false;
bool option_bundled = false; bool option_bundled = false;
bool option_suppressLicense = false; bool option_suppressLicense = false;
bool option_help = false;
bool subcmd_gui = false; bool subcmd_gui = false;
OUString logFile; OUString logFile;
OUString repository; OUString repository;
...@@ -252,6 +256,7 @@ extern "C" int unopkg_main() ...@@ -252,6 +256,7 @@ extern "C" int unopkg_main()
!readOption( &option_force, info_force, &nPos ) && !readOption( &option_force, info_force, &nPos ) &&
!readOption( &option_bundled, info_bundled, &nPos ) && !readOption( &option_bundled, info_bundled, &nPos ) &&
!readOption( &option_suppressLicense, info_suppressLicense, &nPos ) && !readOption( &option_suppressLicense, info_suppressLicense, &nPos ) &&
!readOption( &option_help, info_help, &nPos ) &&
!readArgument( &repository, info_context, &nPos ) && !readArgument( &repository, info_context, &nPos ) &&
!isBootstrapVariable(&nPos)) !isBootstrapVariable(&nPos))
{ {
...@@ -304,6 +309,20 @@ extern "C" int unopkg_main() ...@@ -304,6 +309,20 @@ extern "C" int unopkg_main()
toString( info_shared ) + "!\n" ); toString( info_shared ) + "!\n" );
} }
} }
#if defined(UNX)
if ( geteuid() == 0 )
{
if ( !(option_shared || option_bundled || option_help) )
{
dp_misc::writeConsoleError(
"ERROR: cannot run " APP_NAME " as root without " +
toString( info_shared ) + " or " + toString( info_bundled )
+ " option.\n");
return 1;
}
}
#endif
if (subCommand == "reinstall") if (subCommand == "reinstall")
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment