diff --git a/debian/applauncherd-testapps.install b/debian/applauncherd-testapps.install index a3f5b4b..8e7727b 100644 --- a/debian/applauncherd-testapps.install +++ b/debian/applauncherd-testapps.install @@ -22,6 +22,7 @@ usr/bin/fala_focus usr/bin/fala_multi-window usr/bin/fala_windowless usr/bin/fala_multi-window +usr/bin/fala_dbus usr/bin/xsendevent usr/share/dbus-1/services/com.nokia.fala_testapp.service usr/share/dbus-1/services/com.nokia.fala_wl.service diff --git a/debian/changelog b/debian/changelog index 09542c8..73a3c0f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,8 +4,9 @@ applauncherd (3.0.2) stable; urgency=low * disabling xsession/crash-reporter-daemon in performance test (probably breaks test at random cases) * Changes: Fixes test test_invoker_signal_forward (extra warnings has appeared in test application) * Fixes: NB#296154 - reopened - proprietary headers to LGPL + * Fixes: NB#299083 - apps started via invoker --type m retain applauncher's privileges on D-Bus - -- Marek Ruszczak Thu, 23 Feb 2012 16:13:38 +0200 + -- Dmitry Rozenshtein Wed, 20 Mar 2012 16:55:21 +0200 applauncherd (3.0.1) stable; urgency=low diff --git a/src/invoker/invokelib.h b/src/invoker/invokelib.h index 5af9584..2268140 100644 --- a/src/invoker/invokelib.h +++ b/src/invoker/invokelib.h @@ -31,5 +31,8 @@ void invoke_send_str(int fd, char *str); #define INVOKER_QT_SOCK "/tmp/boostq" #define INVOKER_QDECL_SOCK "/tmp/boostd" #define INVOKER_EXEC_SOCK "/tmp/booste" +// Existence of the test mode control file is checked +// to enable test mode. +#define TEST_MODE_CONTROL_FILE "/root/.itm" #endif diff --git a/src/invoker/invoker.c b/src/invoker/invoker.c index 0b7fe33..96e927f 100644 --- a/src/invoker/invoker.c +++ b/src/invoker/invoker.c @@ -48,6 +48,8 @@ #include #endif +#include "whitelist.h" + // Delay before exit. static const unsigned int EXIT_DELAY = 0; static const unsigned int MIN_EXIT_DELAY = 1; @@ -473,6 +475,7 @@ static void usage(int status) " in case the device is in landscape orientation.\n" " -o, --daemon-mode Notify invoker that the launched process is a daemon.\n" " This resets the oom_adj of the process.\n" + " -T, --test-mode Invoker test mode. Also control file in root home should be in place.\n" " -h, --help Print this help.\n\n" "Example: %s --type=m /usr/bin/helloworld\n\n", PROG_NAME_INVOKER, PROG_NAME_LAUNCHER, EXIT_DELAY, RESPAWN_DELAY, MAX_RESPAWN_DELAY, PROG_NAME_INVOKER); @@ -653,15 +656,53 @@ static void invoke_fallback(char **prog_argv, char *prog_name, bool wait_term) exit(EXIT_FAILURE); } +//Check if application (MeeGo Touch) is allowed to be boosted +static bool is_application_whitelisted(const char *const prog_name) +{ + bool result = false; + + if (prog_name == 0) + { + return result; + } + + unsigned int list_size = sizeof(app_whitelist) / sizeof(char *); + unsigned int i; + + for (i = 0; i < list_size; i++) + { + const char * app = app_whitelist[i]; + if (strcmp(app, prog_name) == 0) + { + result = true; + break; + } + } + + return result; +} + // Invokes the given application static int invoke(int prog_argc, char **prog_argv, char *prog_name, enum APP_TYPE app_type, uint32_t magic_options, bool wait_term, unsigned int respawn_delay, - char *splash_file, char *landscape_splash_file) + char *splash_file, char *landscape_splash_file, bool test_mode) { int status = 0; - if (prog_name && prog_argv) { + //If TEST_MODE_CONTROL_FILE doesn't exists switch off test mode + if (test_mode && access(TEST_MODE_CONTROL_FILE, F_OK) != 0) + { + test_mode = false; + info("Invoker test mode is not enabled.\n"); + } + + // This is a check if MeeGo Touch application is not allowed to be boosted + if (app_type == M_APP && !test_mode && !is_application_whitelisted(prog_name)) + { + info("Application '%s' is not allowed to use booster '--type=m', '--type=q' will be used instead.\n", prog_name); + app_type = QT_APP; + } // This is a fallback if connection with the launcher // process is broken int fd = invoker_init(app_type); @@ -695,6 +736,7 @@ int main(int argc, char *argv[]) char *splash_file = NULL; char *landscape_splash_file = NULL; struct stat file_stat; + bool test_mode = false; // wait-term parameter by default magic_options |= INVOKER_MSG_MAGIC_OPTION_WAIT; @@ -720,6 +762,7 @@ int main(int argc, char *argv[]) {"deep-syms", no_argument, NULL, 'D'}, {"single-instance", no_argument, NULL, 's'}, {"daemon-mode", no_argument, NULL, 'o'}, + {"test-mode", no_argument, NULL, 'T'}, {"type", required_argument, NULL, 't'}, {"delay", required_argument, NULL, 'd'}, {"respawn", required_argument, NULL, 'r'}, @@ -731,7 +774,7 @@ int main(int argc, char *argv[]) // Parse options // TODO: Move to a function int opt; - while ((opt = getopt_long(argc, argv, "hcwnGDsod:t:r:S:L:", longopts, NULL)) != -1) + while ((opt = getopt_long(argc, argv, "hcwnGDsoTd:t:r:S:L:", longopts, NULL)) != -1) { switch(opt) { @@ -764,6 +807,10 @@ int main(int argc, char *argv[]) magic_options |= INVOKER_MSG_MAGIC_OPTION_DLOPEN_DEEP; break; + case 'T': + test_mode = true; + break; + case 't': if (strcmp(optarg, "m") == 0) app_type = M_APP; @@ -853,7 +900,7 @@ int main(int argc, char *argv[]) // Send commands to the launcher daemon info("Invoking execution: '%s'\n", prog_name); - int ret_val = invoke(prog_argc, prog_argv, prog_name, app_type, magic_options, wait_term, respawn_delay, splash_file, landscape_splash_file); + int ret_val = invoke(prog_argc, prog_argv, prog_name, app_type, magic_options, wait_term, respawn_delay, splash_file, landscape_splash_file, test_mode); // Sleep for delay before exiting if (delay) diff --git a/src/invoker/whitelist.h b/src/invoker/whitelist.h new file mode 100644 index 0000000..f538592 --- /dev/null +++ b/src/invoker/whitelist.h @@ -0,0 +1,49 @@ +/*************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of applauncherd +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#ifndef WHITELIST_H +#define WHITELIST_H + +const char * const app_whitelist[] = +{ + "/usr/bin/conndlgs", + "/usr/bin/call-ui", + "/usr/bin/accounts-ui", + "/usr/bin/grob", + "/usr/bin/calc", + "/usr/bin/organiser", + "/usr/bin/call-history", + "/usr/bin/camera-ui", + "/usr/bin/contacts", + "/usr/bin/duicontrolpanel.launch", + "/usr/bin/gallery", + "/usr/bin/fenix", + "/usr/bin/mediaviewer", + "/usr/bin/messaging-ui", + "/usr/bin/music-suite", + "/usr/bin/notes", + "/usr/bin/office-tools", + "/usr/bin/search", + "/usr/bin/sync-ui", + "/usr/bin/userguide", + "/usr/bin/video-suite", + "/usr/bin/videosheetplayer" +}; + +#endif // WHITELIST_H diff --git a/src/launcherlib/booster.cpp b/src/launcherlib/booster.cpp index ac10576..88c2e52 100644 --- a/src/launcherlib/booster.cpp +++ b/src/launcherlib/booster.cpp @@ -550,10 +550,6 @@ int Booster::launchProcess() if (!m_bootMode) preinit(); - // make booster specific initializations unless booster is in boot mode - if (!m_bootMode) - preinit(); - #ifdef WITH_COVERAGE __gcov_flush(); #endif diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8cd279c..8c67a68 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -97,3 +97,6 @@ add_subdirectory(common/testapps/fala_multiwindow) # Sub build: common/testapps/fala_windowless add_subdirectory(common/testapps/fala_windowless) +# Sub build: common/testapps/fala_dbus +add_subdirectory(common/testapps/fala_dbus) + diff --git a/tests/common/testapps/fala_dbus/CMakeLists.txt b/tests/common/testapps/fala_dbus/CMakeLists.txt new file mode 100644 index 0000000..dd279e6 --- /dev/null +++ b/tests/common/testapps/fala_dbus/CMakeLists.txt @@ -0,0 +1,35 @@ +# Set sources +set(SRC fala_dbus.cpp) + +link_libraries(${MEEGOTOUCH_LIBRARIES}) + +include(${QT_USE_FILE}) + +SET (QT_USE_QTDBUS true) +INCLUDE_DIRECTORIES(${QT_QTDBUS_INCLUDE_DIR}) + +# Use the compiler and linker flags given in meegotouch-boostable.pc +# in the source tree. +execute_process(COMMAND "env" + "PKG_CONFIG_PATH=${CMAKE_SOURCE_DIR}/data/pkgconfig" + "/usr/bin/pkg-config" + "--cflags" + "meegotouch-boostable" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE booster_cflags + OUTPUT_STRIP_TRAILING_WHITESPACE) +execute_process(COMMAND "env" + "PKG_CONFIG_PATH=${CMAKE_SOURCE_DIR}/data/pkgconfig" + "/usr/bin/pkg-config" "--libs" + "meegotouch-boostable" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE booster_libs + OUTPUT_STRIP_TRAILING_WHITESPACE) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${booster_cflags}") +set(CMAKE_EXE_LINKER_FLAGS ${booster_libs}) + +add_executable(fala_dbus ${SRC}) + +# Install +install(PROGRAMS fala_dbus DESTINATION /usr/bin/ ) + diff --git a/tests/common/testapps/fala_dbus/fala_dbus.cpp b/tests/common/testapps/fala_dbus/fala_dbus.cpp new file mode 100644 index 0000000..05faa3f --- /dev/null +++ b/tests/common/testapps/fala_dbus/fala_dbus.cpp @@ -0,0 +1,50 @@ +/*************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of applauncherd +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include + +#ifdef HAVE_MCOMPONENTCACHE +#include +#endif + +M_EXPORT int main(int argc, char ** argv) +{ +#ifdef HAVE_MCOMPONENTCACHE + MApplication *app = MComponentCache::mApplication(argc, argv); +#else + MApplication *app = new MApplication(argc, argv); +#endif + Q_UNUSED(app); + QDBusConnection bus = QDBusConnection::systemBus(); + QDBusMessage msg = QDBusMessage::createMethodCall("com.nokia.dsme", "/com/nokia/dsme/request", "com.nokia.dsme.request", "req_powerup"); + QDBusMessage reply = bus.call(msg,QDBus::AutoDetect, 5); + QString dbusReplyError = reply.errorName(); + openlog ("qfala_dbus", LOG_NDELAY | LOG_PID | LOG_PERROR, LOG_DAEMON); + syslog (LOG_DAEMON | LOG_NOTICE, "fala_dbus connection error: '%s'", dbusReplyError.toLocal8Bit().data()); + closelog(); + std::cerr << "fala_dbus connection error:" << dbusReplyError.toLocal8Bit().data() << "\n"; + _exit(0); +} diff --git a/tests/common/testapps/fala_multiwindow/README b/tests/common/testapps/fala_multiwindow/README index 532bfd3..2d66015 100644 --- a/tests/common/testapps/fala_multiwindow/README +++ b/tests/common/testapps/fala_multiwindow/README @@ -5,7 +5,7 @@ Multiwindow test application. Command to launch application -invoker --type=m /usr/bin/fala_multi-window [-window-not-from-cache] +invoker --test-mode --type=m /usr/bin/fala_multi-window [-window-not-from-cache] Application can be started with the switch "-output-level debug" to get information what happens inside it. diff --git a/tests/common/testapps/testapp/fala_wl.desktop b/tests/common/testapps/testapp/fala_wl.desktop index ee8466f..dc1d7b4 100644 --- a/tests/common/testapps/testapp/fala_wl.desktop +++ b/tests/common/testapps/testapp/fala_wl.desktop @@ -2,6 +2,6 @@ Type=Application Name=fala_wl Icon=icon-l-video -Exec=/usr/bin/invoker --type=m /usr/bin/fala_wl +Exec=/usr/bin/invoker --test-mode --type=m /usr/bin/fala_wl Categories=X-MeeGo;X-Demos; OnlyShowIn=X-MeeGo; diff --git a/tests/harmattan/apps-tests/tests.xml b/tests/harmattan/apps-tests/tests.xml index 0d1b02a..73f88ef 100644 --- a/tests/harmattan/apps-tests/tests.xml +++ b/tests/harmattan/apps-tests/tests.xml @@ -8,12 +8,17 @@ /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + touch /root/.itm source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-security.py test_no_aegis_invoker_creds + + rm -f /root/.itm + + true true diff --git a/tests/harmattan/art-tests/tests.xml b/tests/harmattan/art-tests/tests.xml index 0b54351..165c6bd 100644 --- a/tests/harmattan/art-tests/tests.xml +++ b/tests/harmattan/art-tests/tests.xml @@ -8,6 +8,7 @@ /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + touch /root/.itm @@ -38,6 +39,10 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_unix_signal_handlers + + rm -f /root/.itm + + false true diff --git a/tests/harmattan/daemon-tests/tests.xml b/tests/harmattan/daemon-tests/tests.xml index 66bdaab..2a0e849 100644 --- a/tests/harmattan/daemon-tests/tests.xml +++ b/tests/harmattan/daemon-tests/tests.xml @@ -10,6 +10,7 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py stop_daemons /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + touch /root/.itm @@ -41,6 +42,7 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py start_daemons + rm -f /root/.itm @@ -52,6 +54,7 @@ /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + touch /root/.itm @@ -73,6 +76,10 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-boot-mode.py test_SIGUSR2_AFTER_SIGUSR1 + + rm -f /root/.itm + + true true diff --git a/tests/harmattan/functests/tests.xml b/tests/harmattan/functests/tests.xml index cb12847..f0ae600 100644 --- a/tests/harmattan/functests/tests.xml +++ b/tests/harmattan/functests/tests.xml @@ -8,6 +8,7 @@ /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + touch /root/.itm @@ -46,6 +47,10 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_e_boosted_has_glcontext + + rm -f /root/.itm + + false true @@ -56,6 +61,7 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py stop_daemons /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + touch /root/.itm @@ -120,6 +126,7 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py start_daemons + rm -f /root/.itm @@ -132,6 +139,7 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py stop_daemons /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + touch /root/.itm source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py start_daemons + rm -f /root/.itm false @@ -208,6 +217,7 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py stop_daemons /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + touch /root/.itm source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_detect_booster_q_leaks_file_descriptor_when_invoker_is_using_app_directly + + rm -f /root/.itm + + false true @@ -249,6 +263,7 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py stop_daemons /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + touch /root/.itm source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py start_daemons + rm -f /root/.itm @@ -323,6 +339,7 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py stop_daemons /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + touch /root/.itm source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py start_daemons + rm -f /root/.itm false @@ -374,6 +392,7 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py stop_daemons /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + touch /root/.itm @@ -394,6 +413,7 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py start_daemons + rm -f /root/.itm @@ -405,6 +425,7 @@ /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + touch /root/.itm @@ -419,6 +440,10 @@ source /tmp/session_bus_address.user; DISPLAY=:0 /usr/share/applauncherd-testscripts/tc_splash.rb --name test_no_splash + + rm -f /root/.itm + + true true @@ -432,6 +457,7 @@ requirement="300168"> /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + touch /root/.itm source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_stress_boosted_apps + + rm -f /root/.itm + + + true true @@ -453,6 +484,7 @@ initctl stop xsession/pkgm-timed-checks rm /var/lib/dpkg/lock dpkg --configure -a + touch /root/.itm initctl start xsession/pkgm-timed-checks + rm -f /root/.itm false diff --git a/tests/harmattan/invoker-tests/tests.xml b/tests/harmattan/invoker-tests/tests.xml index 073fd79..673566c 100644 --- a/tests/harmattan/invoker-tests/tests.xml +++ b/tests/harmattan/invoker-tests/tests.xml @@ -9,6 +9,7 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py stop_daemons /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + touch /root/.itm @@ -95,8 +96,18 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-invoker.py test_invoker_applauncherd_dies + + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-invoker.py test_invoker_dbus_security + + + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-invoker.py test_invoker_test_mode + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py start_daemons + rm -f /root/.itm @@ -111,6 +122,7 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py stop_daemons /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + touch /root/.itm @@ -130,6 +142,7 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py start_daemons + rm -f /root/.itm false @@ -142,6 +155,7 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py stop_daemons /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + touch /root/.itm @@ -165,6 +179,7 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py start_daemons + rm -f /root/.itm false diff --git a/tests/harmattan/perftests/lmt/tests.xml b/tests/harmattan/perftests/lmt/tests.xml index 78f9fca..785c13a 100644 --- a/tests/harmattan/perftests/lmt/tests.xml +++ b/tests/harmattan/perftests/lmt/tests.xml @@ -10,10 +10,11 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py stop_applifed /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 initctl stop xsession/crash-reporter-daemon + touch /root/.itm - source /tmp/session_bus_address.user; DISPLAY=:0 /usr/share/applauncherd-testscripts/test-perf.rb name test_performance -- -c "invoker --type=m /usr/bin/fala_wl" -b "fala_wl" -s 600 -t 50 -w 10 -f "/tmp/fala_wl.log" > /tmp/perf_commandline_with_launcher.txt + source /tmp/session_bus_address.user; DISPLAY=:0 /usr/share/applauncherd-testscripts/test-perf.rb name test_performance -- -c "invoker --test-mode --type=m /usr/bin/fala_wl" -b "fala_wl" -s 600 -t 50 -w 10 -f "/tmp/fala_wl.log" > /tmp/perf_commandline_with_launcher.txt @@ -22,7 +23,8 @@ - + rm -f /root/.itm + false @@ -43,6 +45,7 @@ --> /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 initctl stop xsession/crash-reporter-daemon + touch /root/.itm @@ -53,6 +56,7 @@ initctl start xsession/crash-reporter-daemon cp /tmp/fala_wl.log /tmp/grid_fala_wl.log source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py start_applifed + rm -f /root/.itm diff --git a/tests/harmattan/red-tests/tests.xml b/tests/harmattan/red-tests/tests.xml index 17a6455..f3d2618 100644 --- a/tests/harmattan/red-tests/tests.xml +++ b/tests/harmattan/red-tests/tests.xml @@ -8,6 +8,7 @@ /usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120 + touch /root/.itm source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_m_boosted_has_glcontext + + rm -f /root/.itm + + false true @@ -39,6 +44,7 @@ initctl stop xsession/pkgm-timed-checks rm /var/lib/dpkg/lock dpkg --configure -a + touch /root/.itm initctl start xsession/pkgm-timed-checks + rm -f /root/.itm false diff --git a/tests/harmattan/testscripts/old/test-perf-mbooster.py b/tests/harmattan/testscripts/old/test-perf-mbooster.py index 3fc9567..5d63dc9 100644 --- a/tests/harmattan/testscripts/old/test-perf-mbooster.py +++ b/tests/harmattan/testscripts/old/test-perf-mbooster.py @@ -130,7 +130,7 @@ class launcher_perf_tests (unittest.TestCase): os.system('rm %s' %LOG_FILE) self.start_timer() - os.system('invoker --type=m --no-wait %s' %TESTAPP) + os.system('invoker --test-mode --type=m --no-wait %s' %TESTAPP) debug("app", TESTAPP, "started with launcher") time.sleep(5) self.read_log() @@ -146,7 +146,7 @@ class launcher_perf_tests (unittest.TestCase): os.system('pkill -STOP duihome') os.system('pkill -STOP meegotouchhome') self.start_timer() - os.system('invoker --type=m --no-wait %s' %TESTAPP) + os.system('invoker --test-mode --type=m --no-wait %s' %TESTAPP) debug("app", TESTAPP, "started with launcher") time.sleep(5) os.system('pkill -CONT duihome') diff --git a/tests/harmattan/testscripts/old/ts_prestartapp.rb b/tests/harmattan/testscripts/old/ts_prestartapp.rb index 7c9ed7e..aa087a0 100755 --- a/tests/harmattan/testscripts/old/ts_prestartapp.rb +++ b/tests/harmattan/testscripts/old/ts_prestartapp.rb @@ -63,7 +63,7 @@ class TC_PRESTARTLAUNCHTESTS < Test::Unit::TestCase system "pgrep #{@appname}"} #Prestart application using invoker - system("su - user -c '/usr/bin/invoker --type=m --no-wait #{@appname} -prestart'&") + system("su - user -c '/usr/bin/invoker --type=m --test-mode --no-wait #{@appname} -prestart'&") sleep(2) #verify that the application is prestarted and it has a valid pid @@ -78,7 +78,7 @@ class TC_PRESTARTLAUNCHTESTS < Test::Unit::TestCase verify_equal("",2,"Application was Launched"){@switcher} #Now Launch the prestarted application - system("su - user -c '/usr/bin/invoker --type=m --no-wait #{@appname}'") + system("su - user -c '/usr/bin/invoker --type=m --test-mode --no-wait #{@appname}'") sleep(2) #verify that Window state of applications is Normal as the application is launhced diff --git a/tests/harmattan/testscripts/signal-forward/fala_inv_sf.py b/tests/harmattan/testscripts/signal-forward/fala_inv_sf.py index c53e8df..b23914f 100755 --- a/tests/harmattan/testscripts/signal-forward/fala_inv_sf.py +++ b/tests/harmattan/testscripts/signal-forward/fala_inv_sf.py @@ -7,7 +7,7 @@ import commands os.system("/usr/share/applauncherd-testscripts/signal-forward/fala_sf_m.sh &") time.sleep(2) -st, op = commands.getstatusoutput("pgrep -lf 'invoker --type=m --wait-term /usr/bin/fala_ft_hello'") +st, op = commands.getstatusoutput("pgrep -lf 'invoker --test-mode --type=m --wait-term /usr/bin/fala_ft_hello'") op = op.split("\n")[0].split(" ")[0] #Killing application with a signal 11 (Segmentation Fault) diff --git a/tests/harmattan/testscripts/signal-forward/fala_sf_m.sh b/tests/harmattan/testscripts/signal-forward/fala_sf_m.sh index bb4a3a3..04bf370 100755 --- a/tests/harmattan/testscripts/signal-forward/fala_sf_m.sh +++ b/tests/harmattan/testscripts/signal-forward/fala_sf_m.sh @@ -1,3 +1,3 @@ #!/bin/sh -invoker --type=m --wait-term /usr/bin/fala_ft_hello +invoker --test-mode --type=m --wait-term /usr/bin/fala_ft_hello diff --git a/tests/harmattan/testscripts/tc_splash.rb b/tests/harmattan/testscripts/tc_splash.rb index dd01344..ceb6471 100755 --- a/tests/harmattan/testscripts/tc_splash.rb +++ b/tests/harmattan/testscripts/tc_splash.rb @@ -98,7 +98,7 @@ class TC_Splash < Test::Unit::TestCase To Test that splash parameters are set when application is launched using --splash """ - system "invoker --splash #{PortraitImg} --type=m #{TestApp} &" + system "invoker --splash #{PortraitImg} --test-mode --type=m #{TestApp} &" sleep(2) p = wait_for_app(TestApp) @@ -127,7 +127,7 @@ class TC_Splash < Test::Unit::TestCase To Test that splash-landscape parameters are set when application is launched using --splash-landscape """ - system "invoker --splash #{PortraitImg} --splash-landscape #{LandscapeImg} --type=m #{TestApp} &" + system "invoker --splash #{PortraitImg} --splash-landscape #{LandscapeImg} --test-mode --type=m #{TestApp} &" sleep(2) p = wait_for_app(TestApp) @@ -156,11 +156,11 @@ class TC_Splash < Test::Unit::TestCase To Test that splash parameters remains the same even if application is launched without using splash """ - system "invoker --splash #{PortraitImg} --splash-landscape #{LandscapeImg} --type=m #{TestApp} &" + system "invoker --splash #{PortraitImg} --splash-landscape #{LandscapeImg} --test-mode --type=m #{TestApp} &" p = wait_for_app(TestApp) system "kill -15 #{p}" sleep(2) - system "invoker --type=m #{No_Splash_App} &" + system "invoker --test-mode --type=m #{No_Splash_App} &" pid = wait_for_app(No_Splash_App) w = get_compositor_wid diff --git a/tests/harmattan/testscripts/test-boot-mode.py b/tests/harmattan/testscripts/test-boot-mode.py index 8e3c502..2020ae0 100644 --- a/tests/harmattan/testscripts/test-boot-mode.py +++ b/tests/harmattan/testscripts/test-boot-mode.py @@ -125,7 +125,7 @@ class BootModeTests(CustomTestCase): def launch_apps(self, n = 6, btype = 'm'): # check that launching works and the apps are there for i in range(n): - run_cmd_as_user('/usr/bin/invoker -n -r 2 --type=%s fala_multi-instance %d' % (btype, i)) + run_cmd_as_user('/usr/bin/invoker --test-mode -n -r 2 --type=%s fala_multi-instance %d' % (btype, i)) time.sleep(4) # give the applications time to really start diff --git a/tests/harmattan/testscripts/test-daemons.py b/tests/harmattan/testscripts/test-daemons.py index 4c27617..fafeee6 100644 --- a/tests/harmattan/testscripts/test-daemons.py +++ b/tests/harmattan/testscripts/test-daemons.py @@ -157,7 +157,7 @@ class DaemonTests(unittest.TestCase): #launch application using booster debug("launch fala_wl using booster") - status = os.system('invoker --type=m /usr/bin/fala_wl &') + status = os.system('invoker --test-mode --type=m /usr/bin/fala_wl &') #get fd of booster after launching the application debug("get fd of booster after launching the application") @@ -196,12 +196,12 @@ class DaemonTests(unittest.TestCase): Test that Booster gives warning while trying to launch non launchable applications Here fala_wid is a shell script and libebooster.so is a library """ - st, op = commands.getstatusoutput("/usr/bin/invoker --type=m /usr/bin/fala_wid") + st, op = commands.getstatusoutput("/usr/bin/invoker --test-mode --type=m /usr/bin/fala_wid") debug("The Warning is %s" %(op.split("\n")[0])) pos = op.split("\n")[0].find("Booster: Loading invoked application failed:") self.assert_(pos != -1, "The booster did not give warning") - st, op = commands.getstatusoutput("/usr/bin/invoker --type=m /usr/lib/applauncherd/libebooster.so") + st, op = commands.getstatusoutput("/usr/bin/invoker --test-mode --type=m /usr/lib/applauncherd/libebooster.so") debug("The Warning is %s" %(op.split("\n")[0])) pos = op.split("\n")[0].find("Booster: Loading symbol 'main' failed:") self.assert_(pos != -1, "The booster did not give warning") @@ -252,7 +252,7 @@ class DaemonTests(unittest.TestCase): launcher_pid = wait_for_single_applauncherd mbooster_pid = wait_for_app("booster-m") - cmd = '/usr/bin/invoker --type=m /usr/bin/fala_exit' + cmd = '/usr/bin/invoker --test-mode --type=m /usr/bin/fala_exit' st, op = commands.getstatusoutput(cmd) time.sleep(5) self.assert_(st == 0, "The application did not exit clean") diff --git a/tests/harmattan/testscripts/test-func-launcher.py b/tests/harmattan/testscripts/test-func-launcher.py index 3fb7511..af7aed8 100644 --- a/tests/harmattan/testscripts/test-func-launcher.py +++ b/tests/harmattan/testscripts/test-func-launcher.py @@ -347,7 +347,7 @@ class launcher_tests (CustomTestCase): #launch application using booster debug("launch %s using booster" % app_name) - st = os.system('invoker --type=%s --no-wait %s' % (btype, app_name)) + st = os.system('invoker --test-mode --type=%s --no-wait %s' % (btype, app_name)) self.assert_(st == 0, "failed to start %s,%s" % (app_name,st)) # wait for new booster and app to start @@ -477,7 +477,7 @@ class launcher_tests (CustomTestCase): for bType in ('m', 'd', 'e', 'q') : #Launching application with booster-m bpid = wait_for_app('booster-%s' %bType, timeout = 10) - p = run_app_as_user_with_invoker(bType!='d' and PREFERED_APP or PREFERED_APP_QML, booster = bType, arg = '--no-wait') + p = run_app_as_user_with_invoker(bType!='d' and PREFERED_APP or PREFERED_APP_QML, booster = bType, arg = '--no-wait --test-mode') app_pid = wait_for_app(bType!='d' and 'fala_ft_hello' or 'fala_qml_helloworld', timeout = 10) bpid_new = wait_for_app('booster-%s' %bType, timeout = 10) self.assertNotEqual(app_pid, None, "Application is not running") @@ -511,7 +511,7 @@ class launcher_tests (CustomTestCase): debug("The value of queue is %d" %count) return count - invokerCall = 'invoker --type=%s --no-wait %s %s' %(booster_type, + invokerCall = 'invoker --test-mode --type=%s --no-wait %s %s' %(booster_type, singleInstanceArg and "--single-instance" or "", app_name) debug("Starting stress test for boosted application with %s-boster and single-instance switch %s" @@ -561,7 +561,7 @@ class launcher_tests (CustomTestCase): #For booster-m for bType in ('m', 'd', 'q', 'e') : appName = bType != 'd' and 'fala_wl' or 'fala_qml_helloworld' - p = run_cmd_as_user('invoker --type=%s --no-wait %s -faulty' %(bType, appName)) + p = run_cmd_as_user('invoker --type=%s --test-mode --no-wait %s -faulty' %(bType, appName)) pid = wait_for_app(appName, timeout = 40) self.assert_(pid, "Fail to launch '%s' application" %appName) try : @@ -667,7 +667,7 @@ class launcher_tests (CustomTestCase): for i in range(2): debug("Running cycle %s" %i) cmd = ['su', '-', 'user', '-c'] - invoke="export QT_LOAD_TESTABILITY=1; /usr/bin/invoker --type=%s %s" %(btype, testapp) + invoke="export QT_LOAD_TESTABILITY=1; /usr/bin/invoker --test-mode --type=%s %s" %(btype, testapp) cmd.append(invoke) p = subprocess.Popen(cmd, shell = False, stdout = DEV_NULL, stderr = DEV_NULL, preexec_fn=permit_sigpipe) @@ -715,7 +715,7 @@ class launcher_tests (CustomTestCase): os.system("rm %s" % logFileName) if get_pid(testapp)!= None: kill_process(testapp) - p = run_cmd_as_user('invoker --type=%s %s/%s' % (btype, path, testapp)) + p = run_cmd_as_user('invoker --test-mode --type=%s %s/%s' % (btype, path, testapp)) pid = wait_for_app(testapp) self.assert_(pid != None, "The application was not launched") try : @@ -755,7 +755,7 @@ class launcher_tests (CustomTestCase): os.system("rm %s" % logFileName) if get_pid(testapp)!= None: kill_process(testapp) - p = run_cmd_as_user('invoker --type=%s /usr/bin/%s --log-args 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t' % (btype, testapp)) + p = run_cmd_as_user('invoker --test-mode --type=%s /usr/bin/%s --log-args 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t' % (btype, testapp)) pid = wait_for_app(testapp) self.assert_(pid != None, "The application was not launched") @@ -792,7 +792,7 @@ class launcher_tests (CustomTestCase): os.system("rm %s" % logFileName) if get_pid(testapp)!= None: kill_process(testapp) - p = run_cmd_as_user('invoker --type=%s /usr/bin/%s --log-args 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z' % (btype, testapp)) + p = run_cmd_as_user('invoker --test-mode --type=%s /usr/bin/%s --log-args 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z' % (btype, testapp)) pid = wait_for_app(testapp) self.assert_(pid != None, "The application was not launched") try: @@ -940,7 +940,7 @@ class launcher_tests (CustomTestCase): def _test_launched_app_wm_class_helper(self,btype,test_application,cmd_arguments,window_name,window_count): - run_command = 'invoker --type=%s --no-wait %s %s' %(btype, test_application, cmd_arguments) + run_command = 'invoker --test-mode --type=%s --no-wait %s %s' %(btype, test_application, cmd_arguments) p = run_cmd_as_user(run_command) pid = wait_for_app(test_application) @@ -1005,7 +1005,7 @@ class launcher_tests (CustomTestCase): self.assert_(not has_GL_context(booster_pid), "booster-%s has GL context!"%btype) # run app which has GL context - p = run_app_as_user_with_invoker(testapp, booster = btype, arg = '--no-wait') + p = run_app_as_user_with_invoker(testapp, booster = btype, arg = '--test-mode --no-wait') app_pid = wait_for_app(testapp) self.assert_(app_pid != None, "Process '%s' is not running"%testapp) self.assert_(app_pid == booster_pid, "Process '%s' is not a boosted app"%testapp) @@ -1037,7 +1037,7 @@ class launcher_tests (CustomTestCase): debug("Boster name: %s app name: %s" %(boosterName, testAppName)) # note that application is run by direct invacation not by calling the service - run_command = 'invoker --single-instance --type=%s /usr/bin/%s' %(boosterType, testAppName) + run_command = 'invoker --test-mode --single-instance --type=%s /usr/bin/%s' %(boosterType, testAppName) p = run_cmd_as_user(run_command) # wait for first use of booster diff --git a/tests/harmattan/testscripts/test-invoker.py b/tests/harmattan/testscripts/test-invoker.py index 121ab84..0fca33c 100644 --- a/tests/harmattan/testscripts/test-invoker.py +++ b/tests/harmattan/testscripts/test-invoker.py @@ -186,7 +186,7 @@ class InvokerTests(CustomTestCase): invokerDelay = 10 # launch an app with invoker --delay n debug("launching fala_ft_hello ...") - p = Popen(['/usr/bin/invoker', '--delay', str(invokerDelay), '--type=m', '--no-wait', + p = Popen(['/usr/bin/invoker', '--delay', str(invokerDelay), '--type=m', '--test-mode', '--no-wait', '/usr/bin/fala_ft_hello'], shell=False, stdout=DEV_NULL, stderr=DEV_NULL, preexec_fn=permit_sigpipe) @@ -233,7 +233,7 @@ class InvokerTests(CustomTestCase): #Run application with invoker and get the exit status - booster-m case debug("Run application with invoker and get the exit status") - st, op = commands.getstatusoutput('invoker --type=m --wait-term /usr/bin/fala_status') + st, op = commands.getstatusoutput('invoker --test-mode --type=m --wait-term /usr/bin/fala_status') app_st_w_inv = os.WEXITSTATUS(st) debug("The exit status of app with invoker (booster-m) is : %d" %app_st_w_inv) @@ -267,7 +267,7 @@ class InvokerTests(CustomTestCase): # launch with relative path - p = run_cmd_as_user('cd /usr/share/; invoker --type=m --no-wait ' + + p = run_cmd_as_user('cd /usr/share/; invoker --test-mode --type=m --no-wait ' + "../bin/fala_ft_hello") try: self.waitForAsertEqual(lambda: p.poll(), 0, "Couldn't launch fala_ft_hello" + @@ -277,7 +277,7 @@ class InvokerTests(CustomTestCase): kill_process('fala_ft_hello') # and finally, try to launch something that doesn't exist - p = run_cmd_as_user('invoker --type=m --no-wait spam_cake') + p = run_cmd_as_user('invoker --test-mode --type=m --no-wait spam_cake') try : self.waitForAsertEqual(lambda: p.poll(), 1, "spam_cake has been found!") finally: @@ -301,7 +301,7 @@ class InvokerTests(CustomTestCase): #get invokers's uid and gid by running the application using invoker in user mode debug("get invoker's uid and gid by running the application using invoker in user mode") - app = "invoker --type=m --no-wait /usr/bin/fala_status" + app = "invoker --test-mode --type=m --no-wait /usr/bin/fala_status" st, op = commands.getstatusoutput('su user -c "%s"' %app ); usr_id = op.split('\n')[1] grp_id = op.split('\n')[2] @@ -330,7 +330,7 @@ class InvokerTests(CustomTestCase): #get id by running the application using invoker in root mode debug("get invoker's uid and gid by running the application using invoker in root mode") - app = "invoker --type=m --no-wait /usr/bin/fala_status" + app = "invoker --test-mode --type=m --no-wait /usr/bin/fala_status" st, op = commands.getstatusoutput("%s" %app ); usr_id = op.split('\n')[1] grp_id = op.split('\n')[2] @@ -408,14 +408,14 @@ class InvokerTests(CustomTestCase): debug("Launch application with wrong type %s" %cmd) st, op = commands.getstatusoutput('su - user -c "%s"' %cmd) self.assert_(op.split("\n")[0] == 'invoker: error: Unknown application type: f ',"No Error displayed") - self.assert_(op.split("\n")[2] == 'Usage: invoker [options] [--type=TYPE] [file] [args]',"No usgae displayed") + self.assert_(op.split("\n")[2] == 'Usage: invoker [options] [--type=TYPE] [file] [args]',"No usage displayed") def test_unknown_parameter(self): """ Test that help is printed if unknown parameter is passed to invoker """ - cmd = '/usr/bin/invoker --type=m --x /usr/bin/fala_wl' + cmd = '/usr/bin/invoker --test-mode --type=m --x /usr/bin/fala_wl' debug("Launch application with wrong option %s" %cmd) st, op = commands.getstatusoutput('su - user -c "%s"' %cmd) self.assert_(op.split("\n")[2] == 'Usage: invoker [options] [--type=TYPE] [file] [args]',"No usage displayed") @@ -425,7 +425,7 @@ class InvokerTests(CustomTestCase): Test that invoker gives error when it tries to launch a binary that does not exist """ - cmd = '/usr/bin/invoker --type=m /usr/bin/fala_foo' + cmd = '/usr/bin/invoker --test-mode --type=m /usr/bin/fala_foo' debug("Launch a non existing application %s" %cmd) st, op = commands.getstatusoutput('su - user -c "%s"' %cmd) self.assert_(st != 0,"The application was launched") @@ -435,7 +435,7 @@ class InvokerTests(CustomTestCase): Test that the symlink of invoker is unable to launch applications """ os.system("ln -s /usr/bin/invoker /usr/bin/invoker_link") - cmd = "/usr/bin/invoker_link --type=m /usr/bin/fala_wl" + cmd = "/usr/bin/invoker_link --test-mode --type=m /usr/bin/fala_wl" st, op = commands.getstatusoutput('su - user -c "%s"' %cmd) os.system("rm /usr/bin/invoker_link") self.assert_(st != 0,"The application was launched") @@ -461,7 +461,7 @@ class InvokerTests(CustomTestCase): Test that symlink of an application can be launched. """ os.system("ln -s /usr/bin/fala_wl /usr/bin/fala_link") - cmd = "/usr/bin/invoker --type=m /usr/bin/fala_link" + cmd = "/usr/bin/invoker --test-mode --type=m /usr/bin/fala_link" os.system('su - user -c "%s"&' %cmd) pid = wait_for_app("fala_link") os.system("rm /usr/bin/fala_link") @@ -502,7 +502,7 @@ class InvokerTests(CustomTestCase): """ #Test for a directory os.system("mkdir /usr/bin/fala_dir") - st, op = commands.getstatusoutput("/usr/bin/invoker --type=m /usr/bin/fala_dir") + st, op = commands.getstatusoutput("/usr/bin/invoker --test-mode --type=m /usr/bin/fala_dir") os.system("rm -rf /usr/bin/fala_dir") self.assert_(st != 0 ,"The application was not launched") @@ -515,7 +515,7 @@ class InvokerTests(CustomTestCase): Unset the PATH env variable and try to launch an application with relative path. The launch should fail """ - st, op = commands.getstatusoutput("(unset PATH;/usr/bin/invoker --type=m fala_wl)") + st, op = commands.getstatusoutput("(unset PATH;/usr/bin/invoker --test-mode --type=m fala_wl)") self.assert_(st != 0, "The application was launched") self.assert_(op == "invoker: died: could not get PATH environment variable", "The application was launched") @@ -529,7 +529,7 @@ class InvokerTests(CustomTestCase): # launch an app with invoker --wait-term debug("launching fala_wait ...") - p = Popen(['/usr/bin/invoker', '--type=m', '--wait-term', + p = Popen(['/usr/bin/invoker', '--type=m', '--test-mode', '--wait-term', '/usr/bin/fala_wait'], shell=False, stdout=DEV_NULL, stderr=DEV_NULL, preexec_fn=permit_sigpipe) @@ -564,7 +564,7 @@ class InvokerTests(CustomTestCase): """ Test that invoker searches the application through relative path """ - os.system("(cd /usr;export PATH=bin;/usr/bin/invoker --type=m fala_wl&)") + os.system("(cd /usr;export PATH=bin;/usr/bin/invoker --test-mode --type=m fala_wl&)") pid = wait_for_app("fala_wl") kill_process("fala_wl") self.assert_(pid != None ,"The application was not launched") @@ -613,6 +613,55 @@ class InvokerTests(CustomTestCase): self.waitForAsert(lambda:p.poll() != None, "Invoker didn't terminate.") self.assert_(wait_for_process_end(PREFERED_APP), "invoker didn't kill application after applauncherd termination.") + def test_invoker_dbus_security(self, sighup = True): + """ + Test that invoker doesn't allow not-privileged application + to re-use restricted d-bus connection opened by m-booster + """ + #run without launcher + cmd = '/usr/bin/fala_dbus' + st, op = commands.getstatusoutput('su - user -c "%s"' %cmd) + errorName = op.split('\n')[0] + self.assert_(errorName.endswith('Error.AccessDenied'),"fala_dbus was able to connect to restricted d-bus service\n output: %s" %op) + + #run with launcher (m-booster). invoker not in test mode + cmd = 'invoker --type=m /usr/bin/fala_dbus' + st, op = commands.getstatusoutput('su - user -c "%s"' %cmd) + errorName = op.split('\n')[0] + self.assert_(errorName.endswith('Error.AccessDenied'),"fala_dbus was able to use m-booster to connect to restricted d-bus service \n output: %s" %op) + + #run with launcher (m-booster). invoker in test mode + cmd = 'invoker --test-mode --type=m /usr/bin/fala_dbus' + st, op = commands.getstatusoutput('su - user -c "%s"' %cmd) + errorName = op.split('\n')[0] + self.assert_(errorName.endswith('Error.NoReply'),"fala_dbus was not able to use m-booster in test-mode to connect to restricted d-bus service \n output: %s" %op) + + + if(sighup): + self.sighup_applauncherd() + self.test_invoker_dbus_security(False) + + + def test_invoker_test_mode(self, sighup = True): + """ + Test that invoker test mode is disabled if + test mode control file doesn't exist + """ + #remove test mode control file + os.system("rm -f /root/.itm") + #run with launcher (m-booster). Try to start invoker in test mode + cmd = 'invoker --test-mode --type=m /usr/bin/fala_dbus' + st, op = commands.getstatusoutput('su - user -c "%s"' %cmd) + #restore test mode control file + os.system("touch /root/.itm") + output = op.split('\n') + self.assert_(len(output) > 2, "No error reported by invoker running test mode without test mode control file. \n output: %s " %op) + error = output[2]; + self.assert_(error.endswith("Invoker test mode is not enabled."), "Incorrect error reported by invoker running test mode without test mode control file. \n output: %s " %op) + + if(sighup): + self.sighup_applauncherd() + self.test_invoker_dbus_security(False) # main if __name__ == '__main__': diff --git a/tests/harmattan/testscripts/test-security.py b/tests/harmattan/testscripts/test-security.py index ac7b177..629686b 100644 --- a/tests/harmattan/testscripts/test-security.py +++ b/tests/harmattan/testscripts/test-security.py @@ -185,7 +185,7 @@ class SecurityTests(unittest.TestCase): #launching the testapp with actual invoker debug("launching the testapp with actual invoker") - st = os.system('%s --type=m --no-wait %s'%(INVOKER_BINARY, Testapp)) + st = os.system('%s --test-mode --type=m --no-wait %s'%(INVOKER_BINARY, Testapp)) pid = get_pid(Testapp) self.assert_((st == 0), "Application was not launched using launcher") self.assert_(not (pid == None), "Application was not launched using launcher: actual pid%s" %pid) @@ -196,7 +196,7 @@ class SecurityTests(unittest.TestCase): #launching the testapp with fake invoker debug("launching the testapp with fake invoker") - st = os.system('%s --type=m --no-wait %s'%(FAKE_INVOKER_BINARY, Testapp)) + st = os.system('%s --test-mode --type=m --no-wait %s'%(FAKE_INVOKER_BINARY, Testapp)) pid = get_pid(Testapp) self.assert_(not (st == 0), "Application was launched using fake launcher") self.assert_((pid == None), "Application was launched using fake launcher") @@ -218,7 +218,7 @@ class SecurityTests(unittest.TestCase): # launch an application, leave invoker running print "launching application" - invoker = run_app_as_user_with_invoker('/usr/bin/fala_ft_hello', booster = 'm', arg = '--wait-term') + invoker = run_app_as_user_with_invoker('/usr/bin/fala_ft_hello', booster = 'm', arg = '--test-mode --wait-term') wait_for_app('fala_ft_hello') @@ -360,9 +360,9 @@ class SecurityTests(unittest.TestCase): #Hardcoding the invoker specific credentials.Needs to be changed if invoker creds changes invoker_specific_creds = ['applauncherd-invoker::applauncherd-invoker',\ 'applauncherd-launcher::access'] - p = run_app_as_user_with_invoker("/usr/bin/fala_wl") + p = run_app_as_user_with_invoker("/usr/bin/fala_wl", arg = '--test-mode') wait_for_app('fala_wl') - st, op = commands.getstatusoutput("pgrep -lf '/usr/bin/invoker --type=m /usr/bin/fala_wl'") + st, op = commands.getstatusoutput("pgrep -lf '^/usr/bin/invoker --type=m --test-mode /usr/bin/fala_wl'") pid = op.split("\n")[0].split(" ")[0] debug("The pid of Invoker is %s" % pid) diff --git a/tests/harmattan/testscripts/test-single-instance.py b/tests/harmattan/testscripts/test-single-instance.py index 0029dff..02a17b4 100644 --- a/tests/harmattan/testscripts/test-single-instance.py +++ b/tests/harmattan/testscripts/test-single-instance.py @@ -392,25 +392,25 @@ class SingleInstanceTests(CustomTestCase): self.single_instance_abnormal_lock_release('single-instance') def test_single_instance_window_raise_with_invoker(self, sighup = True): - self.single_instance_window_raise('invoker --type=m --single-instance') + self.single_instance_window_raise('invoker --test-mode --type=m --single-instance') if(sighup): self.sighup_applauncherd() self.test_single_instance_window_raise_with_invoker(False) def test_single_instance_and_non_single_instance_with_invoker(self, sighup = True): - self.single_instance_and_non_single_instance('invoker --type=m --single-instance') + self.single_instance_and_non_single_instance('invoker --test-mode --type=m --single-instance') if(sighup): self.sighup_applauncherd() self.test_single_instance_and_non_single_instance_with_invoker(False) def test_single_instance_stress_test_with_invoker(self, sighup = True): - self.single_instance_stress_test('invoker --type=m --single-instance') + self.single_instance_stress_test('invoker --test-mode --type=m --single-instance') if(sighup): self.sighup_applauncherd() self.test_single_instance_stress_test_with_invoker(False) def test_single_instance_abnormal_lock_release_with_invoker(self, sighup = True): - self.single_instance_abnormal_lock_release('invoker --type=m --single-instance') + self.single_instance_abnormal_lock_release('invoker --test-mode --type=m --single-instance') if(sighup): self.sighup_applauncherd() self.test_single_instance_abnormal_lock_release_with_invoker(False)