Skip to content

Commit bfc4d09

Browse files
committed
Fix loading payloads from USB root
- Allow /mnt/usb paths in is_allowed_payload_path - Expose pldmgr_read_config_bool globally Closes #18
1 parent 1ebcf98 commit bfc4d09

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

include/pldmgr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
/* Logging */
4343
void pldmgr_log(const char *fmt, ...);
4444
int pldmgr_server_is_active();
45+
int pldmgr_read_config_bool(const char *key, int default_val);
4546

4647
#include "autoload.h"
4748
#include "notification.h"

src/main.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,16 @@ static int is_allowed_payload_path(const char *path) {
240240
return 1;
241241
}
242242
}
243+
244+
/* Allow USB root payloads if SCAN_USB_PAYLOADS is enabled in config */
245+
if (strncmp(path, "/mnt/usb", 8) == 0 &&
246+
path[8] >= '0' && path[8] <= '7' &&
247+
path[9] == '/') {
248+
if (pldmgr_read_config_bool("SCAN_USB_PAYLOADS", 0)) {
249+
return 1;
250+
}
251+
}
252+
243253
return 0;
244254
}
245255

src/payload_mgr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ static int is_allowed_usb_path(const char *path) {
831831
return -1;
832832
}
833833

834-
static int read_config_bool(const char *key, int default_val) {
834+
int pldmgr_read_config_bool(const char *key, int default_val) {
835835
FILE *f = fopen(PLDMGR_CONFIG_PATH, "r");
836836
if (!f) return default_val;
837837
char line[256];
@@ -866,7 +866,7 @@ static int is_allowed_usb_path(const char *path) {
866866
scan_payloads_recursive(scan_dirs[i], 0, 5, &jb);
867867
}
868868

869-
if (read_config_bool("SCAN_USB_PAYLOADS", 0)) {
869+
if (pldmgr_read_config_bool("SCAN_USB_PAYLOADS", 0)) {
870870
for (int i = 0; i < 8; i++) {
871871
char usb_root[32];
872872
snprintf(usb_root, sizeof(usb_root), "/mnt/usb%d", i);

0 commit comments

Comments
 (0)