You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Prevent Magisk database race condition
The database should only be accessed by a single process, which is magiskd. This means 'magisk --sqlite [SQL]' has to be updated to pass the SQL command to the daemon. In addition, open the database connection with SQLITE_OPEN_FULLMUTEX to support multithread in magiskd.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "utils.h"
|
||||
#include "daemon.h"
|
||||
#include "selinux.h"
|
||||
#include "db.h"
|
||||
#include "flags.h"
|
||||
|
||||
static void get_client_cred(int fd, struct ucred *cred) {
|
||||
@@ -39,6 +40,7 @@ static void *request_handler(void *args) {
|
||||
case POST_FS_DATA:
|
||||
case LATE_START:
|
||||
case BOOT_COMPLETE:
|
||||
case SQLITE_CMD:
|
||||
if (credential.uid != 0) {
|
||||
write_int(client, ROOT_REQUIRED);
|
||||
close(client);
|
||||
@@ -75,6 +77,10 @@ static void *request_handler(void *args) {
|
||||
case HANDSHAKE:
|
||||
/* Do NOT close the client, make it hold */
|
||||
break;
|
||||
case SQLITE_CMD:
|
||||
exec_sql(client);
|
||||
close(client);
|
||||
break;
|
||||
default:
|
||||
close(client);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user