diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2015-06-18 17:00:55 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-06-19 15:57:44 +0200 |
commit | c15b96a4b9ad0c37e7848e8460732e7d088529e3 (patch) | |
tree | d6c0e1d4ebc479329cd544ff1fc27ecfe80130eb /desktop/source/pkgchk | |
parent | 56813553a39716f710d1406cbc1c90435ca2e223 (diff) |
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 723e099972c1645 and
9444ffc93a3335
Change-Id: I0b4425d1c9eff8e51e5d9a4dab35775084106a23
(cherry picked from commit faa2c06226146e3ab4b7fa8096cf213ea9d52a23)
Diffstat (limited to 'desktop/source/pkgchk')
-rw-r--r-- | desktop/source/pkgchk/unopkg/unopkg_app.cxx | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx index b1330daec5d9..dc79adce6534 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx @@ -42,6 +42,9 @@ #include <com/sun/star/ui/dialogs/XDialogClosedListener.hpp> #include <com/sun/star/bridge/BridgeFactory.hpp> #include <stdio.h> +#if defined(UNX) + #include <unistd.h> +#endif #include <vector> @@ -186,6 +189,7 @@ extern "C" int unopkg_main() bool option_verbose = false; bool option_bundled = false; bool option_suppressLicense = false; + bool option_help = false; bool subcmd_gui = false; OUString logFile; OUString repository; @@ -252,6 +256,7 @@ extern "C" int unopkg_main() !readOption( &option_force, info_force, &nPos ) && !readOption( &option_bundled, info_bundled, &nPos ) && !readOption( &option_suppressLicense, info_suppressLicense, &nPos ) && + !readOption( &option_help, info_help, &nPos ) && !readArgument( &repository, info_context, &nPos ) && !isBootstrapVariable(&nPos)) { @@ -304,6 +309,20 @@ extern "C" int unopkg_main() 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") { |