Index: denali.qrc
===================================================================
diff -u -r49b21798fb65ce44a04ae4e771ef7c3c1c119fa6 -r5a4a26f106ba03759e3a89b19690fa678f8a3aca
--- denali.qrc (.../denali.qrc) (revision 49b21798fb65ce44a04ae4e771ef7c3c1c119fa6)
+++ denali.qrc (.../denali.qrc) (revision 5a4a26f106ba03759e3a89b19690fa678f8a3aca)
@@ -19,6 +19,7 @@
sources/gui/qml/pages/settings/SettingsDeviceRegistration.qml
sources/gui/qml/pages/settings/SettingsInformation.qml
sources/gui/qml/pages/settings/SettingsROInput.qml
+ sources/gui/qml/pages/settings/SettingsRootSSHAccess.qml
sources/gui/qml/pages/settings/SettingsServicePassword.qml
sources/gui/qml/pages/settings/SettingsManufacturingSetup.qml
sources/gui/qml/pages/settings/SettingsFactoryReset.qml
Index: sources/cloudsync/CloudSyncController.cpp
===================================================================
diff -u -rf0ffeb8c9ec7a838f039b904ce253b001561b5db -r5a4a26f106ba03759e3a89b19690fa678f8a3aca
--- sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision f0ffeb8c9ec7a838f039b904ce253b001561b5db)
+++ sources/cloudsync/CloudSyncController.cpp (.../CloudSyncController.cpp) (revision 5a4a26f106ba03759e3a89b19690fa678f8a3aca)
@@ -347,9 +347,8 @@
case eError_LogFolder : text = tr( "CS The log folder cannot be created." ) ; break;
case eError_LogFileInp : text = tr( "CS Error writing to the input file." ) ; break;
case eError_CredentialFile : text = tr( "CS The credentials file does not exist." ) ; break;
- case eError_CredentialMake : text = tr( "CS The credentials folder make failed." ) ; break;
- case eError_CredentialCopy : text = tr( "CS The credentials file copy failed." ) ; break;
- case eError_CredentialRemove: text = tr( "CS The credentials file remove failed." ) ; break;
+ case eError_CredentialPath : text = tr( "CS The credentials folder is incorrect." ) ; break;
+ case eError_CredentialCount : text = tr( "CS No credential file name provided." ) ; break;
case eError_CredentialEmpty : text = tr( "CS The credentials folder is empty." ) ; break;
case eError_TxCodeNoParam : text = tr( "CS No Treatment Code provided." ) ; break;
case eError_TxCodeEmpty : text = tr( "CS The provided Treatment Code is empty." ) ; break;
@@ -392,9 +391,8 @@
case eError_LogFolder : ; break;
case eError_LogFileInp : ; break;
case eError_CredentialFile : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break;
- case eError_CredentialMake : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break;
- case eError_CredentialCopy : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break;
- case eError_CredentialRemove: info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break;
+ case eError_CredentialPath : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break;
+ case eError_CredentialCount : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break;
case eError_CredentialEmpty : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break;
case eError_TxCodeNoParam : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break;
case eError_TxCodeEmpty : info = QString( "[%1:%2]" ).arg( vErrorID ).arg( item(0) ) ; break;
@@ -528,15 +526,17 @@
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// writing the message into the buffer.
LOG_APPED_UI( vInpBuff );
- // TODO TBD - Need to determine if need to add this code or change factory_reset.sh script
-// if(!QFile::exists(_date_inp_File)){
-// Storage::FileHandler::makeFolder(_location);
-// }
+ if(!QFile::exists(_date_inp_File)){
+ Storage::FileHandler::makeFolder(_location);
+ }
if ( ! Storage::FileHandler::write(_date_inp_File, vInpBuff + "\n") ) { error = eError_LogFileInp; args = { _date_inp_File }; ok = false; goto lErr; }
return ok;
lErr:
- toLog(error, args);
+ // don't send the error back to the CS
+ // it calls this same function if the error is in this function
+ // and creates a loop
+ LOG_DEBUG(toText(error) + " " + toInfo(error, args));
return ok;
}
@@ -672,8 +672,6 @@
qint32 messageID = UI2CS(static_cast( eMessageID_TxReport ));
if ( ! isRegistered() ) { error = eError_NotRegistered ; args = { vFileName }; ok = false; goto lErr; }
-
- sendCredentialsSend(); // TODO: This has to be removed later, it is a workaround for Cloud issue, during our talk with KBM.
sendUIBuff(makeUIBuff( messageID , { vFileName } ));
return;
@@ -696,7 +694,6 @@
case eMessageID_DeviceInfo : ok = sendDeviceInfo ( ); break;
case eMessageID_CredentialsSave : ok = sendCredentialsSave( vMessage ); break;
- case eMessageID_CredentialsSend : ok = sendCredentialsSend( ); break;
case eMessageID_ResetFactory : ok = sendResetFactory ( ); break;
case eMessageID_DeviceState : ok = sendDeviceState ( ); break;
@@ -730,7 +727,6 @@
bool CloudSyncController::sendDeviceState()
{
bool ok = false;
- sendCredentialsSend(); // TODO: This has to be removed later, it is a workaround for Cloud issue, during our talk with KBM.
ok = sendUIHistory(eMessageID_DeviceState);
return ok;
}
@@ -768,37 +764,24 @@
/*!
* \brief CloudSyncController::sendCredentialsSave
- * \details saves the credentials files which their location have been sent.
+ * \details validates the credentials files which their sent location.
* \param vMessage - the message received from CloudSync
- * \return true on successfully saving the files.
+ * \return true on successfully validate the files.
*/
bool CloudSyncController::sendCredentialsSave( const Message &vMessage)
{
bool ok = true;
QString destination = QString(Storage::CloudSync_Base_Path_Name) + Storage::CloudSync_Credentials_Folder_Name;
- // create the destination folder if does not exist.
- if ( ! Storage::FileHandler::makeFolder( destination ) ) { toLog(eError_CredentialMake , { }); ok = false; goto lOut; }
-
// file existence has been separated from copy remove to avoid partial copy.
+ if ( ! vMessage.params.count() ) { toLog(eError_CredentialCount , { }); ok = false; goto lOut; }
for ( auto fileName : vMessage.params ) {
- if ( ! QFileInfo::exists(fileName) ) { toLog(eError_CredentialFile , {fileName }); ok = false; goto lOut; }
+ QFileInfo fileinfo(fileName);
+ if ( ! fileinfo.exists() ) { toLog(eError_CredentialFile , {fileName }); ok = false; goto lOut; }
+ if ( fileinfo.absolutePath() != destination ) { toLog(eError_CredentialPath , {fileName }); ok = false; goto lOut; }
}
+ // no need to call for isRegistered() function, we are testing for the count, location, and existence.
- if ( ok ) {
- for ( auto sourceFile : vMessage.params ) {
- QString fileName = QFileInfo(sourceFile).fileName();
- // NOTE: If a file with the name newName already exists, copy() returns false (i.e., QFile will not overwrite it).
- // For the current scenario it is ideal, since that folder will turn RO after the successful registration and copying the files and reboot.
- if ( ! QFile::copy (sourceFile, destination + fileName) ) { toLog(eError_CredentialCopy , {fileName }); ok = false; goto lOut; }
- }
- // if all the copies are successful then remove them.
- for ( auto sourceFile : vMessage.params ) {
- QString fileName = QFileInfo(sourceFile).fileName();
- if ( ! QFile::remove(sourceFile ) ) { toLog(eError_CredentialRemove , {fileName }); ok = false; goto lOut; }
- }
- }
-
lOut:
if ( ok ) sendCredentialsResponse();
emit didRegisterDone(ok);
@@ -807,27 +790,6 @@
}
/*!
- * \brief CloudSyncController::sendSaveCredentials
- * \details saves the credentials files which their location have been sent.
- * \param vMessage - the message received from CloudSync
- * \return true on successfully saving the files.
- */
-bool CloudSyncController::sendCredentialsSend()
-{
- bool ok = true;
- qint32 messageID = UI2CS(eMessageID_CredentialsSend);
- QString source = QString(Storage::CloudSync_Base_Path_Name) + Storage::CloudSync_Credentials_Folder_Name;
- QString destination = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/" + Storage::CloudSync_Credentials_Folder_Name;
-
- if ( Storage::FileHandler::copyFolder(source, destination) != 0 ) { toLog(eError_CredentialCopy , {destination }); ok = false; goto lOut; }
- ok = sendUIBuff({QString("%1").arg( messageID ), "1", destination});
-
-lOut:
- emit didRegisterStart(ok);
- return ok;
-}
-
-/*!
* \brief CloudSyncController::sendCredentialsResponse
* \return send the confirmation of the credential save on the device from UI to CS to let CS know when to delete them.
*/
@@ -858,7 +820,7 @@
if ( mTxCode.isEmpty() ) { toLog(eError_TxCodeEmpty , {}); ok = false; goto lOut; }
emit didTxCodeReceive ( mTxCode );
- qDebug() << " ---------- " << mTxCode;
+ //DEBUG qDebug() << " ---------- " << mTxCode;
lOut:
return ok;
Index: sources/device/DeviceController.cpp
===================================================================
diff -u -r2a0e56982ad45cdd98a6d0425c53e52610c29961 -r5a4a26f106ba03759e3a89b19690fa678f8a3aca
--- sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 2a0e56982ad45cdd98a6d0425c53e52610c29961)
+++ sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 5a4a26f106ba03759e3a89b19690fa678f8a3aca)
@@ -30,6 +30,8 @@
#include "ApplicationController.h"
#include "FileHandler.h"
#include "DeviceModels.h"
+#include "Settings.h"
+#include "encryption.h"
// namespace
using namespace Model;
@@ -106,11 +108,20 @@
connect(&_fileSystemWatcher , SIGNAL( fileChanged(const QString &)),
this , SLOT( onWatchFileChanged(const QString &)));
- connect(&_ApplicationController , SIGNAL(didPOSTInformationReady(const QString &, const QString &, const QString &)),
- this , SLOT( onPOSTInformationReady(const QString &, const QString &, const QString &)));
+ connect(&_ApplicationController , SIGNAL(didPOSTEthernetData (const QString &)),
+ this , SLOT( onPOSTEthernetData (const QString &)));
+ connect(&_ApplicationController , SIGNAL(didPOSTWirelessData (const QString &)),
+ this , SLOT( onPOSTWirelessData (const QString &)));
+ connect(&_ApplicationController , SIGNAL(didPOSTBluetoothData (const QString &)),
+ this , SLOT( onPOSTBluetoothData (const QString &)));
+ connect(&_ApplicationController , SIGNAL(didPOSTCloudSyncData (const QString &)),
+ this , SLOT( onPOSTCloudSyncData (const QString &)));
DEVICE_DEV_INIT_CONNECTIONS_LIST
+ connect(this, SIGNAL(didEventThreadChange()),
+ this, SLOT( onEventThreadChange()));
+
}
/*!
@@ -129,6 +140,8 @@
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(quit()));
_thread->start();
moveToThread(_thread);
+
+ emit didEventThreadChange( QPrivateSignal() );
}
/*!
@@ -552,6 +565,74 @@
}
}
+
+///////////////////////////////////////////// DeviceRootSSHAccess
+/*!
+ * \brief DeviceController::onAttributeRequest
+ * \details Sets the RootSSHAccess
+ * \param vRootSSHAccess
+ */
+void DeviceController::onAttributeRequest(const DeviceRootSSHAccessRequestData &vData)
+{
+ // ----- initializing the member variable models
+ _deviceRootSSHAccessRequest._data = vData;
+ LOG_APPED( _deviceRootSSHAccessRequest.toString());
+
+ // ----- check that script exists.
+ QString script;
+ if ( checkError( DeviceError::checkScript(script, vData.mIsGet ? RootSSHAccess_Get : RootSSHAccess_Set), _deviceRootSSHAccessResponse, script) )
+ return;
+
+ // ----- check if the process is not running
+ if ( _processRootSSHAccess.state() != QProcess::NotRunning ) {
+ checkError(DeviceError::eDevice_Scripts_Error_IsRunning, _deviceRootSSHAccessResponse);
+ return;
+ }
+
+ // ----- run the process
+
+ TimedProcess *timedProcess = new TimedProcess(&_processRootSSHAccess, script, 1000, { _deviceRootSSHAccessRequest._data.mRootSSHAccess ? "YES": "no" });
+ timedProcess->start();
+}
+
+/*!
+ * \brief DeviceController::onProcessRootSSHAccessFinished
+ * \details Called when the process to set the RootSSHAccess has finished
+ * \param vExitCode (int) the exit code
+ * \note exit code -> 0 : set Accept [MBase] -> Log -> emit
+ * !0 : set Attrib [MBrgh] -> Log -> emit
+ * 1 - get an error when in onAttributeRequest : scriptErrorText([Gui Enum ])
+ * 2 - get an error when in onProcessRootSSHAccessExitCode : scriptErrorText([vExitCode])
+ * 3 - get no error when in onProcessRootSSHAccessExitCode : MDeviceResponse.toString()
+ * - in case 3 the specific model _data has to be filled prior to the toString to have it in the log.
+ */
+void DeviceController::onProcessRootSSHAccessExitCode(int vExitCode, QProcess::ExitStatus)
+{
+ if ( ! checkError(static_cast(vExitCode), _deviceRootSSHAccessResponse, _deviceRootSSHAccessResponse.toString()) ) { // has no error
+ if (_deviceRootSSHAccessRequest._data.mIsGet) {
+ bool ok = false;
+ bool rootSSHAccess = _processRootSSHAccess.readLine().toUInt(&ok);
+ if ( ok ) {
+ _deviceRootSSHAccessResponse._data.mMessage = _deviceRootSSHAccessResponse.toString();
+ _deviceRootSSHAccessResponse._data.mRootSSHAccess = rootSSHAccess;
+ }
+ else {
+ checkError(DeviceError::eDevice_Scripts_Error_Incorrect_Rsp, _deviceRootSSHAccessResponse, _deviceRootSSHAccessResponse.toString());
+ return;
+ }
+ }
+ else {
+ _deviceRootSSHAccessResponse._data.mMessage = _deviceRootSSHAccessResponse.toString();
+ _deviceRootSSHAccessResponse._data.mRootSSHAccess = _deviceRootSSHAccessRequest._data.mRootSSHAccess;
+ }
+ LOG_APPED(_deviceRootSSHAccessResponse._data.mMessage);
+ emit didAttributeResponse(_deviceRootSSHAccessResponse._data);
+ }
+ else {
+ // the error in this case is handled in the checkError
+ }
+}
+
///////////////////////////////////////////// DeviceCryptSetup
/*!
* \brief DeviceController::onAttributeRequest
@@ -560,6 +641,8 @@
*/
void DeviceController::onAttributeRequest(const DeviceCryptSetupRequestData &vData)
{
+ //DEBUG qDebug() << " ---------- " << vData.mCommand << vData.mPassword;
+
_deviceCryptSetupRequest._data = vData;
// ----- check that script exists.
@@ -580,10 +663,11 @@
_processCryptSetup.setEnvironment(QProcess::systemEnvironment() << QString("PASSWORD=%1").arg(_deviceCryptSetupRequest._data.mPassword));
timedProcess->start();
+ // Update UI with a response
MDeviceCryptSetupResponse model;
- model._data.mAccepted = false;
- model._data.mMessage = tr("Encrypted Partition %1 started.").arg(_deviceCryptSetupRequest._data.mCommand);
- didAttributeResponse(model.data());
+ model._data.mAccepted = false;
+ model._data.mMessage = tr("Encrypted Partition %1 started.").arg(_deviceCryptSetupRequest._data.mCommand);
+ emit didAttributeResponse(model.data());
}
/*!
@@ -602,8 +686,26 @@
else deviceInfo = _processCryptSetup.readAll();
model.fromByteArray( deviceInfo, &vExitCode );
// DEBUG: qDebug() << model._data.mEchoInfo;
- didAttributeResponse(model.data());
+ emit didAttributeResponse(model.data());
LOG_APPED_UI(model.data().mMessage);
+
+ if ( _deviceCryptSetupRequest._data.mCommand == "mount" ) emit didCryptSetupMount(model._data.mAccepted);
+
+ // move the configuration files if the encrypted partition creation was successful.
+ if ( _deviceCryptSetupRequest._data.mCommand != "setup" ) return;
+ if ( ! model._data.mAccepted ) return;
+ QString msg = "";
+ int err = 0 ;
+ //TODO The Settings shall be the Singleton SettingsController and modify the MSettings like the others.
+ Storage::Settings settings;
+ err = settings.configurationsMove(&msg);
+ if ( err ) {
+ model._data.mAccepted = false ;
+ model._data.mReason = err ;
+ model._data.mMessage = msg ;
+ emit didAttributeResponse(model.data());
+ LOG_APPED_UI(model.data().mMessage);
+ }
}
///////////////////////////////////////////// DeviceBluetoothPaired
@@ -634,7 +736,7 @@
else deviceInfo = _processBluetoothPairedReset.readAll();
model.fromByteArray( deviceInfo, &vExitCode );
LOG_APPED_UI(model.data().mMessage);
- didAttributeResponse(model.data());
+ emit didAttributeResponse(model.data());
}
///////////////////////////////////////////// DeviceBluetoothPairedQuery
@@ -666,7 +768,7 @@
if ( vStatus ) vExitCode = Device::DeviceError::eDevice_Scripts_Error_Status;
else deviceInfo = _processBluetoothPairedQuery.readAll();
model.fromByteArray( deviceInfo, &vExitCode );
- didAttributeResponse(model.data());
+ emit didAttributeResponse(model.data());
LOG_APPED_UI(model.data().mMessage);
}
@@ -718,13 +820,73 @@
emit didWatchFileChange(vFile);
}
-void DeviceController::onPOSTInformationReady(const QString &vMacEthernet, const QString &vMacWireless, const QString &vMacBluetooth)
+void DeviceController::onEventThreadChange()
{
- _macEthernet = vMacEthernet .trimmed();
- _macWireless = vMacWireless .trimmed();
- _macBluetooth = vMacBluetooth .trimmed();
+ //DEBUG qDebug() << " ---------- " << __FUNCTION__ << QThread::currentThread()->objectName() << QThread::currentThread() << qApp->thread();
+ if ( QThread::currentThread() != &Threads::_DeviceController_Thread ) {
+ qCritical() << " ***** Device controller thread not initialized correctly ***** ";
+ return;
+ }
+ _hasThread = true;
+ checkConfugurationMountReady();
}
+void DeviceController::onPOSTEthernetData(const QString &vMacAddress) {
+ _macEthernet = vMacAddress;
+ emit didPOSTEthernetData (vMacAddress);
+}
+
+void DeviceController::onPOSTWirelessData(const QString &vMacAddress) {
+ _macWireless = vMacAddress;
+
+ encryption::varSalt(vMacAddress);
+ _hasSalt = ! vMacAddress.trimmed().isEmpty();
+ checkConfugurationMountReady();
+
+ emit didPOSTWirelessData (vMacAddress);
+}
+
+void DeviceController::onPOSTBluetoothData(const QString &vMacAddress) {
+ _macBluetooth = vMacAddress;
+ emit didPOSTBluetoothData (vMacAddress);
+}
+
+void DeviceController::onPOSTCloudSyncData(const QString &vNetAddress) {
+ _netCloudSync = vNetAddress;
+ emit didPOSTCloudSyncData (vNetAddress);
+}
+
+void DeviceController::checkConfugurationMountReady()
+{
+ /// in manufacturing the system is logged with root and configurations are in /home/root
+ /// therefore no need to mount the cononfiguraiton partition.
+ /// also for in manufacturing the partition is being set up
+ /// and is less steps for setup if the partition is not mounted.
+ if ( gEnableManufacturing ) return;
+
+
+ if ( ! ( _hasThread && _hasSalt ) ) return;
+
+ DeviceCryptSetupRequestData data;
+ data.mCommand = "mount";
+ bool ok = false;
+ data.mPassword = encryption::configurationsPassword( ok );
+ if ( ! ok ) { // not enough infromation to create a secure passowrd
+ // status(tr("Not enough secure information provided"));
+ }
+ else {
+ onAttributeRequest(data);
+ }
+
+ // I_AM_HERE
+ // HERE move the settings read from ApplicationController to here
+ // here is when the DeviceController is moved to its thread
+ // and now can start mounting the encrypted partition
+ // and then read the settings.
+ // TODO don't forget to check for the required configurations files and parameters in the settings class.
+ // and take care of the security flag in the Storage class.
+}
+
///////////////////////////////////////////// DeviceFactoryReset
/*!
* \brief DeviceController::onAttributeRequest
Index: sources/device/DeviceError.h
===================================================================
diff -u -r49b21798fb65ce44a04ae4e771ef7c3c1c119fa6 -r5a4a26f106ba03759e3a89b19690fa678f8a3aca
--- sources/device/DeviceError.h (.../DeviceError.h) (revision 49b21798fb65ce44a04ae4e771ef7c3c1c119fa6)
+++ sources/device/DeviceError.h (.../DeviceError.h) (revision 5a4a26f106ba03759e3a89b19690fa678f8a3aca)
@@ -38,7 +38,7 @@
public:
enum Scripts_Error_Enum {
- eDevice_OK = 0 ,
+ eDevice_OK = 0 ,
// The scripts can use the exit code of each commands they execute and the assumption is most of Linux commands exit codes are less than 1000.
// so any error less that 1000 will be identified as device error
Index: sources/device/DeviceGlobals.h
===================================================================
diff -u -r49b21798fb65ce44a04ae4e771ef7c3c1c119fa6 -r5a4a26f106ba03759e3a89b19690fa678f8a3aca
--- sources/device/DeviceGlobals.h (.../DeviceGlobals.h) (revision 49b21798fb65ce44a04ae4e771ef7c3c1c119fa6)
+++ sources/device/DeviceGlobals.h (.../DeviceGlobals.h) (revision 5a4a26f106ba03759e3a89b19690fa678f8a3aca)
@@ -19,12 +19,6 @@
// Project
#include "StorageGlobals.h"
-namespace Device {
-
-const QString _scriptsFolder = Storage::Scripts_Path_Name;
-
-}
-
/* DEVICE ATTRIBUTE PROPERTY DEFINITION */
// The FLC in vATTRIBUTEFLC means First Letter Capital
#define ATTRIBUTE( vTYPE, vATTRIBUTE, vDEFAULT, vATTRIBUTEFLC) \
@@ -175,6 +169,7 @@
DEVICE_DEV_PARENT ( BluetoothPairedReset ) \
DEVICE_DEV_PARENT ( BluetoothPairedQuery ) \
DEVICE_DEV_PARENT ( CryptSetup ) \
+ DEVICE_DEV_PARENT ( RootSSHAccess ) \
DEVICE_DEV_PARENT ( FactoryReset ) \
DEVICE_DEV_PARENT ( Decommission ) \
@@ -183,6 +178,7 @@
DEVICE_DEV_INIT_CONNECTIONS ( BluetoothPairedReset ) \
DEVICE_DEV_INIT_CONNECTIONS ( BluetoothPairedQuery ) \
DEVICE_DEV_INIT_CONNECTIONS ( CryptSetup ) \
+ DEVICE_DEV_INIT_CONNECTIONS ( RootSSHAccess ) \
DEVICE_DEV_INIT_CONNECTIONS ( FactoryReset ) \
DEVICE_DEV_INIT_CONNECTIONS ( Decommission ) \
@@ -191,6 +187,7 @@
DEVICE_DEV_DEFINITION ( BluetoothPairedReset ) \
DEVICE_DEV_DEFINITION ( BluetoothPairedQuery ) \
DEVICE_DEV_DEFINITION ( CryptSetup ) \
+ DEVICE_DEV_DEFINITION ( RootSSHAccess ) \
DEVICE_DEV_DEFINITION ( FactoryReset ) \
DEVICE_DEV_DEFINITION ( Decommission ) \
@@ -201,6 +198,7 @@
DEVICE_APP_INIT_CONNECTIONS ( BluetoothPairedReset ) \
DEVICE_APP_INIT_CONNECTIONS ( BluetoothPairedQuery ) \
DEVICE_APP_INIT_CONNECTIONS ( CryptSetup ) \
+ DEVICE_APP_INIT_CONNECTIONS ( RootSSHAccess ) \
DEVICE_APP_INIT_CONNECTIONS ( FactoryReset ) \
DEVICE_APP_INIT_CONNECTIONS ( Decommission ) \
@@ -209,6 +207,7 @@
DEVICE_APP_BRIDGE_DEFINITION( BluetoothPairedReset ) \
DEVICE_APP_BRIDGE_DEFINITION( BluetoothPairedQuery ) \
DEVICE_APP_BRIDGE_DEFINITION( CryptSetup ) \
+ DEVICE_APP_BRIDGE_DEFINITION( RootSSHAccess ) \
DEVICE_APP_BRIDGE_DEFINITION( FactoryReset ) \
DEVICE_APP_BRIDGE_DEFINITION( Decommission ) \
@@ -218,6 +217,7 @@
DEVICE_GUI_BRIDGE_DEFINITION( BluetoothPairedReset ) \
DEVICE_GUI_BRIDGE_DEFINITION( BluetoothPairedQuery ) \
DEVICE_GUI_BRIDGE_DEFINITION( CryptSetup ) \
+ DEVICE_GUI_BRIDGE_DEFINITION( RootSSHAccess ) \
DEVICE_GUI_BRIDGE_DEFINITION( FactoryReset ) \
DEVICE_GUI_BRIDGE_DEFINITION( Decommission ) \
@@ -226,6 +226,7 @@
DEVICE_GUI_INIT_CONNECTIONS ( BluetoothPairedReset ) \
DEVICE_GUI_INIT_CONNECTIONS ( BluetoothPairedQuery ) \
DEVICE_GUI_INIT_CONNECTIONS ( CryptSetup ) \
+ DEVICE_GUI_INIT_CONNECTIONS ( RootSSHAccess ) \
DEVICE_GUI_INIT_CONNECTIONS ( FactoryReset ) \
DEVICE_GUI_INIT_CONNECTIONS ( Decommission ) \
@@ -235,6 +236,7 @@
DEVICE_VIEW_INIT_CONNECTIONS( BluetoothPairedReset ) \
DEVICE_VIEW_INIT_CONNECTIONS( BluetoothPairedQuery ) \
DEVICE_VIEW_INIT_CONNECTIONS( CryptSetup ) \
+ DEVICE_VIEW_INIT_CONNECTIONS( RootSSHAccess ) \
DEVICE_VIEW_INIT_CONNECTIONS( FactoryReset ) \
DEVICE_VIEW_INIT_CONNECTIONS( Decommission ) \
Index: sources/device/DeviceModels.h
===================================================================
diff -u -r2a0e56982ad45cdd98a6d0425c53e52610c29961 -r5a4a26f106ba03759e3a89b19690fa678f8a3aca
--- sources/device/DeviceModels.h (.../DeviceModels.h) (revision 2a0e56982ad45cdd98a6d0425c53e52610c29961)
+++ sources/device/DeviceModels.h (.../DeviceModels.h) (revision 5a4a26f106ba03759e3a89b19690fa678f8a3aca)
@@ -244,8 +244,40 @@
bool fromByteArray(const QByteArray &vByteArray, int *vExitCode = nullptr) override;
};
+// ---------- MDeviceRootSSHAccess ---------- //
+/*!
+ * \brief The MDeviceRootSSHAccessRequest class
+ * \details The model for the device RootSSHAccess value modification request.
+ */
+class MDeviceRootSSHAccessRequest : public MDeviceRequestBase {
+public:
+ struct Data {
+ bool mRootSSHAccess = false;
+ bool mIsGet = true ;
+ } _data;
+ QString toString() {
+ return MDeviceRequestBase::toString("RootSSHAccess", { _data.mRootSSHAccess });
+ }
+};
+/*!
+ * \brief The MDeviceRootSSHAccessResponse class
+ * \details The model for the device RootSSHAccess value request.
+ */
+class MDeviceRootSSHAccessResponse : public MDeviceResponseBase {
+public:
+ struct Data : MDeviceResponseBase::Data {
+ bool mRootSSHAccess = false;
+ } _data;
+
+ QVariantList parameters () const override { return { _data.mRootSSHAccess }; }
+ QString infoText () const override { return QString("RootSSHAccess"); }
+ Data data () const { return _data; }
+};
+
+
+
// ---------- MDeviceFactoryReset ---------- //
/*!
* \brief The MDeviceFactoryResetRequest class
@@ -257,7 +289,7 @@
} _data;
QString toString() {
- return MDeviceRequestBase::toString("DeviceFactoryReset", { });
+ return MDeviceRequestBase::toString("FactoryReset", { });
}
};
@@ -288,7 +320,7 @@
} _data;
QString toString() {
- return MDeviceRequestBase::toString("DeviceDecommission", { });
+ return MDeviceRequestBase::toString("Decommission", { });
}
};
@@ -309,6 +341,7 @@
typedef Model::MDeviceResponseBase ::Data DeviceResponseBaseData ;
+
typedef Model::MDeviceBrightnessRequest ::Data DeviceBrightnessRequestData ;
typedef Model::MDeviceBrightnessResponse::Data DeviceBrightnessResponseData ;
@@ -321,6 +354,9 @@
typedef Model::MDeviceCryptSetupRequest ::Data DeviceCryptSetupRequestData ;
typedef Model::MDeviceCryptSetupResponse::Data DeviceCryptSetupResponseData;
+typedef Model::MDeviceRootSSHAccessRequest ::Data DeviceRootSSHAccessRequestData ;
+typedef Model::MDeviceRootSSHAccessResponse::Data DeviceRootSSHAccessResponseData ;
+
typedef Model::MDeviceFactoryResetRequest ::Data DeviceFactoryResetRequestData ;
typedef Model::MDeviceFactoryResetResponse::Data DeviceFactoryResetResponseData;
Index: sources/device/DeviceView.cpp
===================================================================
diff -u -r2a0e56982ad45cdd98a6d0425c53e52610c29961 -r5a4a26f106ba03759e3a89b19690fa678f8a3aca
--- sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision 2a0e56982ad45cdd98a6d0425c53e52610c29961)
+++ sources/device/DeviceView.cpp (.../DeviceView.cpp) (revision 5a4a26f106ba03759e3a89b19690fa678f8a3aca)
@@ -72,7 +72,7 @@
DeviceCryptSetupRequestData data;
data.mCommand = vCommand;
bool ok = false;
- data.mPassword = encryption::defaultServicePassword( ok );
+ data.mPassword = encryption::configurationsPassword( ok );
if ( ! ok ) { // not enough infromation to create a secure passowrd
status(tr("Not enough secure information provided"));
}
@@ -145,6 +145,41 @@
response(true);
}
+/// ---------- RootSSHAccess
+void VDevice::doInitRootSSHAccess() {
+ // DEBUG : qDebug() << "HERE Request" << vValue;
+ DeviceRootSSHAccessRequestData data;
+ data.mIsGet = true;
+ emit didAttributeRequest(data);
+}
+
+void VDevice::rootSSHAccessRequest(const bool &vValue) {
+ // DEBUG : qDebug() << "HERE Request" << vValue;
+ DeviceRootSSHAccessRequestData data;
+ data.mIsGet = false;
+ data.mRootSSHAccess = vValue;
+ emit didAttributeRequest(data);
+}
+
+void VDevice::onAttributeResponse(const DeviceRootSSHAccessResponseData &vData) {
+ // DEBUG : qDebug() << "HERE Response" << vData.mBrightnessPercent;
+ if ( vData.mAccepted ) {
+ rootSSHAccess(vData.mRootSSHAccess);
+ status("");
+ }
+ else {
+ // this has to be called to let Gui to set to old value that device controller provided.
+ emit rootSSHAccessChanged(vData.mRootSSHAccess);
+ status(vData.mMessage);
+ }
+
+ accepted(vData.mAccepted);
+ reason (vData.mReason );
+
+ // has to be the last one
+ response(true);
+}
+
// ================================================= Factory Reset
void VDevice::doInitFactoryReset() {
// Nothing for now.
@@ -182,7 +217,7 @@
// DEBUG : qDebug() << "HERE Request" << vCommand;
DeviceDecommissionRequestData data;
bool ok = false;
- data.mPassword = encryption::defaultServicePassword( ok );
+ data.mPassword = encryption::configurationsPassword( ok );
if ( ! ok ) { // not enough infromation to create a secure passowrd
status(tr("Not enough secure information provided"));
}
Index: sources/device/DeviceView.h
===================================================================
diff -u -r49b21798fb65ce44a04ae4e771ef7c3c1c119fa6 -r5a4a26f106ba03759e3a89b19690fa678f8a3aca
--- sources/device/DeviceView.h (.../DeviceView.h) (revision 49b21798fb65ce44a04ae4e771ef7c3c1c119fa6)
+++ sources/device/DeviceView.h (.../DeviceView.h) (revision 5a4a26f106ba03759e3a89b19690fa678f8a3aca)
@@ -50,6 +50,8 @@
ATTRIBUTE ( QString , cryptSetup , "", CryptSetup )
PROPERTY ( bool , cryptSetupEnabled , true )
+ ATTRIBUTE ( bool , rootSSHAccess , false, RootSSHAccess )
+
ATTRIBUTE ( QString , factoryReset , "", FactoryReset )
PROPERTY ( bool , factoryResetEnabled , true )
Index: sources/gui/qml/pages/settings/SettingsStack.qml
===================================================================
diff -u -ra7693f04e693294338aa9829d14f4ed7aa99a7a5 -r5a4a26f106ba03759e3a89b19690fa678f8a3aca
--- sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision a7693f04e693294338aa9829d14f4ed7aa99a7a5)
+++ sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision 5a4a26f106ba03759e3a89b19690fa678f8a3aca)
@@ -54,6 +54,7 @@
DeviceConfiguration ,
DeviceRegistration ,
SWUpdate ,
+ RootSSHAccess ,
FactoryReset ,
Decommission
}
@@ -72,6 +73,7 @@
qsTr("Device Configuration" ), // Device Configuration
qsTr("Device Registration" ), // DeviceRegistration
qsTr("Software Update" ), // SWUpdate
+ qsTr("Enable Root SSH" ), // RootSSHAccess
qsTr("Factory Reset" ), // FactoryReset
qsTr("Decommission" ), // Decommission
]
@@ -90,6 +92,7 @@
_GuiView.manufactMode , // Device Configuration
true , // DeviceRegistration
false , // SWUpdate
+ serviceMode , // RootSSHAccess
serviceMode , // FactoryReset
serviceMode , // Decommission
]
@@ -106,8 +109,9 @@
false /* serviceMode phase 1 */ , // Language
false /* serviceMode phase 1 */ , // Calibration
_GuiView.manufactMode && serviceMode , // Device Configuration // && serviceMode added to make sure the service mode is confirmed by HD
- _GuiView.manufactMode && serviceMode , // DeviceRegistration // && serviceMode added to make sure the service mode is confirmed by HD
+ /*_GuiView.manufactMode &&*/ serviceMode , // DeviceRegistration // && serviceMode added to make sure the service mode is confirmed by HD // *** manyfactMode removed for testing
false /* serviceMode phase 1 */ , // SWUpdate
+ serviceMode , // RootSSHAccess
serviceMode , // FactoryReset
serviceMode , // Decommission
]
@@ -173,6 +177,11 @@
push( _settingsDeviceConfiguration )
break
+ case SettingsStack.RootSSHAccess:
+ vDevice.doInitRootSSHAccess()
+ push( _SettingsRootSSHAccess)
+ break
+
case SettingsStack.FactoryReset:
push( _serviceFactoryReset )
break
@@ -198,6 +207,7 @@
SettingsROInput { id: _settingsRoInput }
SettingsManufacturingSetup { id: _settingsDeviceConfiguration }
SettingsDeviceRegistration { id: _settingsDeviceRegistration }
+ SettingsRootSSHAccess { id: _SettingsRootSSHAccess }
SettingsServicePassword { id: _servicePassword }
SettingsFactoryReset { id: _serviceFactoryReset }
SettingsDecommission { id: _serviceDecommission }
Index: sources/model/MModel.h
===================================================================
diff -u -r49b21798fb65ce44a04ae4e771ef7c3c1c119fa6 -r5a4a26f106ba03759e3a89b19690fa678f8a3aca
--- sources/model/MModel.h (.../MModel.h) (revision 49b21798fb65ce44a04ae4e771ef7c3c1c119fa6)
+++ sources/model/MModel.h (.../MModel.h) (revision 5a4a26f106ba03759e3a89b19690fa678f8a3aca)
@@ -286,10 +286,12 @@
REGISTER_METATYPE( DeviceBluetoothPairedQueryResponseData ) \
REGISTER_METATYPE( DeviceCryptSetupRequestData ) \
REGISTER_METATYPE( DeviceCryptSetupResponseData ) \
- REGISTER_METATYPE( DeviceFactoryResetRequestData) \
- REGISTER_METATYPE( DeviceFactoryResetResponseData) \
- REGISTER_METATYPE( DeviceDecommissionRequestData) \
- REGISTER_METATYPE( DeviceDecommissionResponseData) \
+ REGISTER_METATYPE( DeviceRootSSHAccessRequestData ) \
+ REGISTER_METATYPE( DeviceRootSSHAccessResponseData ) \
+ REGISTER_METATYPE( DeviceFactoryResetRequestData ) \
+ REGISTER_METATYPE( DeviceFactoryResetResponseData ) \
+ REGISTER_METATYPE( DeviceDecommissionRequestData ) \
+ REGISTER_METATYPE( DeviceDecommissionResponseData ) \
/* Settings */ \
REGISTER_METATYPE( SettingsData ) \
REGISTER_METATYPE( WifiNetworkData ) \
Index: sources/storage/StorageGlobals.cpp
===================================================================
diff -u -r2a0e56982ad45cdd98a6d0425c53e52610c29961 -r5a4a26f106ba03759e3a89b19690fa678f8a3aca
--- sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision 2a0e56982ad45cdd98a6d0425c53e52610c29961)
+++ sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision 5a4a26f106ba03759e3a89b19690fa678f8a3aca)
@@ -13,10 +13,15 @@
*
*/
// Qt
+#include
#include
// Project
#include "StorageGlobals.h"
+
+extern bool gEnableManufacturing ;
+extern bool gUseRootHome ;
+
/*!
* \brief Storage
* \details The container of the constant global variable withing Storage namespace members.
@@ -60,13 +65,20 @@
#endif
// Screenshot store folder
-const char *Screenshot_Base_Path_Name = "Screenshots/"; // this is the base path which will use the USB_Mount_Point to store the screenshots.
+ const char *Screenshot_Base_Path_Name = "Screenshots/"; // this is the base path which will use the USB_Mount_Point to store the screenshots.
// Settings
+ static bool settings_secured = false;
+ const char *Settings_Path () { return gUseRootHome ? Settings_Path_Init : ( gEnableManufacturing ? ( settings_secured ? Settings_Path_Name: Settings_Path_Init ) : Settings_Path_Name ); }
+ void Settings_Secured() { settings_secured = true; }
+
#ifdef BUILD_FOR_TARGET
- const char *Settings_Path_Name = "/home/root/.config/";
+ //WARNING: This has to match with the crypt_setup.sh
+ const char *Settings_Path_Init = "/home/root/.config/"; // this is the manufacturing setup and the user is root.
+ const char *Settings_Path_Name = "/var/configurations/";
#else
// should be in the project application folder. [is tracking by git]
+ const char *Settings_Path_Init = "/home/denali/Projects/application/resources/settings/";
const char *Settings_Path_Name = "/home/denali/Projects/application/resources/settings/";
#endif
const char *Settings_Category_Instructions = "Instructions/Instructions";
@@ -84,10 +96,10 @@
// CloudSync credentials
#ifdef BUILD_FOR_TARGET
- const char *CloudSync_Base_Path_Name = "/home/root/.cloudSync/";
+ const char *CloudSync_Base_Path_Name = gUseRootHome ? "/home/root/.cloudSync/" : "/var/configurations/CloudSync/";
#else
// on VM it is a temporary file which is not being tracked
- const char *CloudSync_Base_Path_Name = "/home/denali/Desktop/cloudsync/";
+ const char *CloudSync_Base_Path_Name = "/home/denali/Desktop/CloudSync/";
#endif
#ifdef BUILD_FOR_TARGET
@@ -98,13 +110,21 @@
#endif
// Scripts
-#ifdef BUILD_FOR_TARGET
- const char *Scripts_Path_Name = "/home/root/scripts/";
-#else
- // should be in the project application folder. [is tracking by git]
- const char *Scripts_Path_Name = "/home/denali/Projects/application/scripts/";
-#endif
+ const QString Scripts_Path_Name() {
+ #ifdef BUILD_FOR_TARGET
+ //TODO The manufacturing mode has to run as root
+ // after the lockdown.sh ran there would be no root user access
+ // and I am not sure how we reenalbe the root ssh
+ // and if it is a security risk to give denali access to sshd_config to enable the root ssh within UI App
+ // lockdown script suppose to be the last thing to do,
+ // and it is the lockdown.sh script which moves the scripts from root to denali home folder,
+ // therefore in manufacturing mode we are still running as root.
+ return QCoreApplication::applicationDirPath() + (gEnableManufacturing ? "/scripts/" : "/scripts/");
+ #else
+ return "/home/denali/Projects/application/scripts/";
+ #endif
+ }
// Please notice that is the folder not the path
// and it needs to be concatenated after SDCard_Base_Path_Name for each build configuration
@@ -117,7 +137,7 @@
// FIXME : Not sure having global settings object is a good idea.
#ifdef BUILD_FOR_TARGET
- QSettings WifiSettings("/home/root/wifi.ini", QSettings::IniFormat);
+ QSettings WifiSettings("/home/denali/wifi.ini", QSettings::IniFormat);
#else
QSettings WifiSettings("/home/denali/wifi.ini");
#endif
@@ -156,6 +176,10 @@
const char *Brightness_Set = "brightness_set.sh";
const char *Brightness_Get = "brightness_get.sh";
+ // Brightness
+ const char *RootSSHAccess_Set = "rootsshaccess_set.sh";
+ const char *RootSSHAccess_Get = "rootsshaccess_get.sh";
+
// Bluetooth
const char *Bluetooth_Paired_Reset = "bluetooth_paired_clear.sh";
const char *Bluetooth_Paired_Query = "bluetooth_paired_query.sh";
Index: sources/storage/StorageGlobals.h
===================================================================
diff -u -r2a0e56982ad45cdd98a6d0425c53e52610c29961 -r5a4a26f106ba03759e3a89b19690fa678f8a3aca
--- sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision 2a0e56982ad45cdd98a6d0425c53e52610c29961)
+++ sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision 5a4a26f106ba03759e3a89b19690fa678f8a3aca)
@@ -44,7 +44,10 @@
extern const char *Screenshot_Base_Path_Name;
// Settings
- extern const char *Settings_Path_Name;
+ extern void Settings_Secured ();
+ extern const char *Settings_Path() ;
+ extern const char *Settings_Path_Init ;
+ extern const char *Settings_Path_Name ;
extern const char *Settings_Category_Instructions ;
extern const char *Settings_Category_InstructionsImagesLoc ;
extern const char *Settings_Category_ConfigurationsDataList ;
@@ -64,7 +67,7 @@
extern const char *CloudSync_Credentials_Folder_Name;
// Scripts
- extern const char *Scripts_Path_Name;
+ extern const QString Scripts_Path_Name();
// Log Type Folders
extern const char *Log_Folder_Base; // Base Log Folder
@@ -110,6 +113,10 @@
extern const char *Brightness_Set;
extern const char *Brightness_Get;
+ // RootSSHAccess
+ extern const char *RootSSHAccess_Set;
+ extern const char *RootSSHAccess_Get;
+
// Bluetooth
extern const char *Bluetooth_Paired_Reset;
extern const char *Bluetooth_Paired_Query;