Index: main.cpp =================================================================== diff -u -r389f028cb9d4d320eae393de7c4408a58a619356 -r9ef6badf8e172436bba2bfad1642ae7e469e0361 --- main.cpp (.../main.cpp) (revision 389f028cb9d4d320eae393de7c4408a58a619356) +++ main.cpp (.../main.cpp) (revision 9ef6badf8e172436bba2bfad1642ae7e469e0361) @@ -41,6 +41,7 @@ #include "Compatible.h" // Project +#include "FileHandler.h" #include "MainTimer.h" #include "CanInterface.h" #include "FrameInterface.h" @@ -371,6 +372,37 @@ QCoreApplication::setApplicationVersion(version); } +/*! + * \brief lockdown + * \details runs the lockdown shellscript as a detached process + * and ment to be executed just before the application quits + * and only when application running in manufacturing mode. + * Must not stop application shutdown in any way. + * If any error happens it only logs. + */ +void lockdown() { + // there are two setup scenarios: + // only during setup mode which is -E (manufacturing setup) application is running under the root user permissions + // and all the files are copied to the /home/root/ te later be copied to secured locations + // and that will be done by lockdown.sh script running within application after the user is done with the setup and QUIT s the application. + if ( gEnableManufacturing ) { + QString scriptName = Storage::Device_Lockdown; + quint16 errorCode; + QString errorText; + errorCode = Device::DeviceError::checkScript (scriptName, Storage::Device_Lockdown ); + errorText = Device::DeviceError::deviceErrorText( errorCode, 1 ); + qDebug() << errorText; // since we are in the manufacturing mode it is possible to probably take a look at the serial, if not that is being logged. +#ifdef BUILD_FOR_TARGET + Storage::FileHandler::write("/home/root/lockdown.log" , errorText, false); +#else + Storage::FileHandler::write("/home/denali/lockdown.log" , errorText, false); +#endif + if ( ! errorCode ) { + QProcess::startDetached( scriptName, { qApp->applicationName() + ":" + QString::number(qApp->applicationPid()) }); + } + } +} + #ifdef UNIT_TEST #include TEST_CLASS_INCLUDE QTEST_MAIN(TEST_CLASS_NAME) @@ -500,6 +532,8 @@ Gui::_viewer->deleteLater(); + lockdown(); + return app_exec; } #endif