Commit Graph

53 Commits

Author SHA1 Message Date
Shubham Jangra 6f7cea6b27 Quit application if bus is not connected, interface not registered
Reviewers: stikonas, cjlcarvalho

Reviewed By: stikonas

Subscribers: #kde_partition_manager

Tags: #kde_partition_manager

Differential Revision: https://phabricator.kde.org/D21616
2019-06-08 15:43:24 +05:30
Andrius Štikonas ba48851d34 Merge branch '4.0' 2019-06-07 19:12:07 +01:00
Harald Sitter 9b45e25f81 manually quit kauth's mainloop
Summary:
kauth helpers have a qcoreapplication started which auto-terminates after
10 seconds of idle time. this would be an added time out on top of our
life time management that is not necessary. to prevent this additional
delay simply quit the qapplication directly.

this makes helper termination almost instantaneous even when the dbus
client disappears due to crash or SIGINT, and largely removes the
need to call stopHelper altogether.

BUG: 408245

Test Plan:
both partitionmanager and calamares instantly quit the helper no matter how the client process gets terminated

other than that everything seems to work as before

Reviewers: stikonas

Differential Revision: https://phabricator.kde.org/D21559
2019-06-05 18:34:35 +01:00
Harald Sitter 5413150c67 manually quit kauth's mainloop
Summary:
kauth helpers have a qcoreapplication started which auto-terminates after
10 seconds of idle time. this would be an added time out on top of our
life time management that is not necessary. to prevent this additional
delay simply quit the qapplication directly.

this makes helper termination almost instantaneous even when the dbus
client disappears due to crash or SIGINT, and largely removes the
need to call stopHelper altogether.

BUG: 408245

Test Plan:
both partitionmanager and calamares instantly quit the helper no matter how the client process gets terminated

other than that everything seems to work as before

Reviewers: stikonas

Differential Revision: https://phabricator.kde.org/D21559
2019-06-03 15:08:10 +02:00
Shubham Jangra 68cf1efd6b Notify user when they enter non whitelisted command
Reviewers: stikonas, cjlcarvalho

Reviewed By: stikonas

Subscribers: #kde_partition_manager

Tags: #kde_partition_manager

Differential Revision: https://phabricator.kde.org/D21504
2019-05-30 23:27:04 +05:30
Shubham Jangra a7532d4041 Scrap Public Key Cryptography code based on QCA as QDbus is secure enough
Summary: QDbus already provides enough security to the calls made by the application to the helper. Hence no need to encrypt, sign the requests of the application and verify their integrity at the helper side.

Reviewers: stikonas, cjlcarvalho

Reviewed By: stikonas

Subscribers: #kde_partition_manager

Tags: #kde_partition_manager

Differential Revision: https://phabricator.kde.org/D21275
2019-05-19 22:53:13 +05:30
Shubham Jangra 73a21e6739 Simplify test conditions
Reviewers: stikonas, cjlcarvalho

Reviewed By: stikonas

Subscribers: #kde_partition_manager

Tags: #kde_partition_manager

Differential Revision: https://phabricator.kde.org/D21241
2019-05-17 23:03:15 +05:30
Shubham Jangra 997f425030 Remove redundant include
Reviewers: stikonas, cjlcarvalho

Reviewed By: stikonas

Subscribers: #kde_partition_manager

Tags: #kde_partition_manager

Differential Revision: https://phabricator.kde.org/D21251
2019-05-17 23:00:58 +05:30
Shubham Jangra 281289dfbb Constantify nonce and some cleanup
Reviewers: stikonas, #kde_partition_manager, cjlcarvalho

Reviewed By: stikonas, #kde_partition_manager, cjlcarvalho

Subscribers: varunp, tctara, teo, abhijeet2096, caiovosilva, cjlcarvalho, #kde_partition_manager

Tags: #kde_partition_manager

Differential Revision: https://phabricator.kde.org/D20108
2019-03-29 12:00:13 -06:00
Shubham Jangra 9c5b582ed0 Constantify function parameters
Summary: Even though constantifying these parameters won't change anything(since they are being passed by value), it is done to assure they conform to rest of the coding style

Reviewers: stikonas, cjlcarvalho, #kde_partition_manager

Reviewed By: cjlcarvalho

Subscribers: #kde_partition_manager

Tags: #kde_partition_manager

Differential Revision: https://phabricator.kde.org/D20106
2019-03-29 11:52:55 -06:00
Andrius Štikonas 80f5a32dc0 Remove remaining cases of call to dd binary.
BUG: 398154
2018-11-29 22:32:07 +00:00
Andrius Štikonas 09e4d47e07 Do not use external process dd.
BUG: 398154
2018-11-25 20:50:22 +00:00
Andrius Štikonas 2007f2b8ea Allow copyblocks to be used together with small QByteArrays.
Add CopyTargetByteArray. CopySourceByteArray is not implemented yet.

This is only suitable for reading small amount of data such as GPT header
or FAT boot sector location. Not meant for copying whole partition because
data has to be transfered over DBus.

Differential Revision: https://phabricator.kde.org/D16487
2018-10-29 00:02:12 +00:00
Caio Carvalho 7853424a62 Use std::find instead of iterating to search in allowedCommands. 2018-08-24 12:14:49 -03:00
Simon Depiets e74fcb29e4 Fix parameters and markers in xi18n call
Reviewers: #kde_partition_manager

Subscribers: stikonas

Tags: #kde_partition_manager

Differential Revision: https://phabricator.kde.org/D14968
2018-08-21 17:18:02 +08:00
Caio Carvalho 6c703e122a Checking if the command is not an empty string. 2018-08-16 23:42:21 +02:00
Andrius Štikonas eb099bd477 Add command whitelist to kpmcore kauth helper. 2018-08-11 20:32:02 +01:00
Harald Sitter 87dc44dab8 use QDBusServiceWatcher instead of pinging the client
Summary:
the motivation here is to terminate the "server" helper when the client
disappears. dbus supports this use case natively via service registration
events which we can easily handle via QDBusServiceWatcher.
instead of repeatedly poking the client we'll simply monitor its dbus
service now. this is cheaper, less code and doesn't risk timing out
randomly.

Test Plan:
- on neon ISO build kpmcore & calamares & pm
- calamares manages to actually partition stuff
- partitionmanager also starts properly

- also the same again on the installed system.

Reviewers: stikonas, bshah

Reviewed By: bshah

Subscribers: bshah

Differential Revision: https://phabricator.kde.org/D14646
2018-08-06 15:46:11 +02:00
Andrius Štikonas 872715f4e0 Switch DBus calls to classes generated from XML. 2018-08-05 21:15:33 +01:00
Andrius Štikonas a7b640da4c Delay creation of QEventLoop object until after QCoreApplication starts
Fixes: QEventLoop: Cannot be used without QApplication
2018-08-03 19:49:32 +01:00
Andrius Štikonas 938ec7fa8b Make ExternalCommandHelper::getNonce() reentrant.
Store previously generated values of nonce, and remove them from
the container when they are used.

BUG: 396312
2018-07-21 11:03:25 +01:00
Andrius Štikonas c50e04c9d1 Use cryptographic nonce instead of counters. 2018-07-20 21:12:13 +01:00
Andrius Štikonas e5b63b0d6f Fix support for QProcess::ProcessChannelMode. 2018-07-15 17:37:29 +01:00
Andrius Štikonas ce425ee04d Exit if the previous KAuth helper is still running. 2018-07-15 01:13:54 +01:00
Andrius Štikonas 9a8166fe65 Remove qDebug message.
It shouldn't be necessary now. Helper exits reliably.
2018-07-15 00:35:55 +01:00
Andrius Štikonas 51780a6297 Stop KAuth helper if application crashes.
This is implemented by pinging application from KAuth helper via DBus.
If it is busy  then KAuth helper also waits for the current job to finish.
2018-07-15 00:09:39 +01:00
Andrius Štikonas 65ef6ab83d Fix error message.
It was incorrectly saying DBus session bus instead of system bus.
2018-07-14 21:36:13 +01:00
Andrius Štikonas a6100aaa37 Add an error message in case of invalid signature. 2018-04-13 14:26:44 +03:00
Andrius Štikonas 231bfbd331 Cryptographically sign copyblocks and exit KAuth helper calls. 2018-04-13 14:24:05 +03:00
Andrius Štikonas 24e1e83152 Try to fix QString encoding issues in KAuth helper.
For now set text codec to UTF-8
Needs more investigation if locale of the GUI program is not UTF-8.
2018-04-13 02:44:12 +03:00
Andrius Štikonas e0be8fae83 Initialize m_Counter variable on startup. 2018-04-13 00:51:08 +03:00
Andrius Štikonas 428ee5b6c8 First attempt at using RSA to sign requests to KAuth helper. 2018-04-13 00:43:12 +03:00
Andrius Štikonas 5e85f0b974 Remove ping interface in KAuth helper as it is blocking KPM GUI. 2018-03-31 18:01:00 +01:00
Andrius Štikonas f04416beba Simplify Qtimer code in ExternalCommandHelper. 2018-03-23 22:47:21 +00:00
Andrius Štikonas 8cdf70171e Start QTimer before enteting event loop. 2018-03-23 22:08:23 +00:00
Caio Carvalho 47a1519699 - Including Watchdog Timer in CoreBackendManager to ping DBus service.
- Including ExternalCommandHelper::ping slot to receive pings.
- Including timer to watch last ping in the service to unregister it after reaching 42 seconds without pings.
2018-03-23 18:19:33 -03:00
Andrius Štikonas 39d3592c23 Actually check if the caller is authorized. 2018-03-22 17:41:49 +01:00
Caio Carvalho dac3372a78 - Including ExternalCommandHelper asynchronous DBus call in ExternalCommand::execute
- Stop helper before starting a new in CoreBackendManager::startExternalCommandHelper
- Unregister org.kde.kpmcore.helperinterface service in ExternalCommandHelper::exit
2018-03-22 02:32:59 -03:00
Andrius Štikonas 4b91f2c07e Convert copyblocks dbus call to asynchronous call. 2018-03-21 21:51:30 +01:00
Andrius Štikonas bd54ba7c5d Convert copyblocks code from KAuth to DBus calls to helper daemon. 2018-03-21 18:01:40 +01:00
Andrius Štikonas ef2b61d2ec Wait until the helper started.
Ideally we should not block at this stage and wait before the first command
is executed. But this is much better than nothing.
2018-03-19 16:21:57 +01:00
Andrius Štikonas 645e16bb20 WIP: add some experimental code where helper is used as daemon
Caveats:
 * copyblocks are not converted yet, but should be similar.
 * There is no signaling back to main application which tells when even loop has started, so after password is entered, you need to click F5 to rescan devices
 * There are some security checks but are they sufficient
2018-03-19 11:42:49 +01:00
Huzaifa Faruqui 72da110996 Fix copyblocks exit status check 2018-02-06 22:32:26 +05:30
Andrius Štikonas ac6dc0eb87 Remove backend readData/writeData functions. 2018-02-06 16:48:02 +00:00
Huzaifa Faruqui 00d47c6417 Use QFile for ExternalCommandHelper::readData. 2018-02-05 12:58:37 +00:00
Andrius Štikonas b79f713ed8 Fix ExternalCommandHelper::writeData function.
QFile::open needs QIODevice::Append flag.
2018-02-05 12:46:13 +00:00
Andrius Štikonas f426f59799 Use QFile for writing data in ExternalCommandHelper::writeData
dd works much slower when writing to files, especially files on SSD.
Thanks to Huzaifa Faruqui for suggestion.
2018-02-03 15:58:36 +00:00
Andrius Štikonas 5c307c1cc7 Use toLongLong in KAuth helper.
Otherwise all integers simply overflow.
2018-02-02 18:33:35 +00:00
Huzaifa Faruqui b143c139e5 Fix Report in copyBlocks 2018-01-29 16:45:21 +05:30
Andrius Štikonas 61fed73a5d Remove some debug output. 2018-01-24 15:35:11 +00:00