Skip to content

Commit a5d1741

Browse files
authored
lakka: reconsideration for samba service enable disable (#18696)
1 parent 030cef0 commit a5d1741

3 files changed

Lines changed: 42 additions & 14 deletions

File tree

configuration.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3069,7 +3069,7 @@ void config_set_defaults(void *data)
30693069
configuration_set_bool(settings,
30703070
settings->bools.ssh_enable, filestream_exists(LAKKA_SSH_PATH));
30713071
configuration_set_bool(settings,
3072-
settings->bools.samba_enable, filestream_exists(LAKKA_SAMBA_PATH));
3072+
settings->bools.samba_enable, !filestream_exists(LAKKA_SAMBA_DISABLED_FILE_PATH));
30733073
configuration_set_bool(settings,
30743074
settings->bools.bluetooth_enable, filestream_exists(LAKKA_BLUETOOTH_PATH));
30753075
configuration_set_bool(settings, settings->bools.localap_enable, false);
@@ -4439,7 +4439,7 @@ static bool config_load_file(global_t *global,
44394439
configuration_set_bool(settings,
44404440
settings->bools.ssh_enable, filestream_exists(LAKKA_SSH_PATH));
44414441
configuration_set_bool(settings,
4442-
settings->bools.samba_enable, filestream_exists(LAKKA_SAMBA_PATH));
4442+
settings->bools.samba_enable, !filestream_exists(LAKKA_SAMBA_DISABLED_FILE_PATH));
44434443
configuration_set_bool(settings,
44444444
settings->bools.bluetooth_enable, filestream_exists(LAKKA_BLUETOOTH_PATH));
44454445
#ifdef HAVE_RETROFLAG
@@ -5781,11 +5781,11 @@ bool config_save_file(const char *path)
57815781
else
57825782
filestream_delete(LAKKA_SSH_PATH);
57835783
if (settings->bools.samba_enable)
5784-
filestream_close(filestream_open(LAKKA_SAMBA_PATH,
5784+
filestream_delete(LAKKA_SAMBA_DISABLED_FILE_PATH);
5785+
else
5786+
filestream_close(filestream_open(LAKKA_SAMBA_DISABLED_FILE_PATH,
57855787
RETRO_VFS_FILE_ACCESS_WRITE,
57865788
RETRO_VFS_FILE_ACCESS_HINT_NONE));
5787-
else
5788-
filestream_delete(LAKKA_SAMBA_PATH);
57895789
if (settings->bools.bluetooth_enable)
57905790
filestream_close(filestream_open(LAKKA_BLUETOOTH_PATH,
57915791
RETRO_VFS_FILE_ACCESS_WRITE,

lakka.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@
1818
#ifndef __RARCH_LAKKA_H
1919
#define __RARCH_LAKKA_H
2020

21-
#define LAKKA_SSH_PATH "/storage/.cache/services/sshd.conf"
22-
#define LAKKA_SAMBA_PATH "/storage/.cache/services/samba.conf"
23-
#define LAKKA_BLUETOOTH_PATH "/storage/.cache/services/bluez.conf"
21+
#define LAKKA_SSH_PATH "/storage/.cache/services/sshd.conf"
22+
#define LAKKA_SAMBA_PATH "/storage/.cache/services/samba.conf"
23+
#define LAKKA_SAMBA_DISABLED_FILE_PATH "/storage/.cache/services/samba.disabled"
24+
#define LAKKA_BLUETOOTH_PATH "/storage/.cache/services/bluez.conf"
2425
#ifdef HAVE_RETROFLAG
25-
#define LAKKA_SAFESHUTDOWN_PATH "/storage/.cache/services/safeshutdown.conf"
26+
#define LAKKA_SAFESHUTDOWN_PATH "/storage/.cache/services/safeshutdown.conf"
2627
#endif
27-
#define LAKKA_UPDATE_DIR "/storage/.update/"
28-
#define LAKKA_CONNMAN_DIR "/storage/.cache/connman/"
29-
#define LAKKA_LOCALAP_PATH "/storage/.cache/services/localap.conf"
30-
#define LAKKA_TIMEZONE_PATH "/storage/.cache/timezone"
28+
#define LAKKA_UPDATE_DIR "/storage/.update/"
29+
#define LAKKA_CONNMAN_DIR "/storage/.cache/connman/"
30+
#define LAKKA_LOCALAP_PATH "/storage/.cache/services/localap.conf"
31+
#define LAKKA_TIMEZONE_PATH "/storage/.cache/timezone"
3132

3233
#define DEFAULT_TIMEZONE "UTC"
3334
#define TIMEZONE_LENGTH 255

menu/menu_setting.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9495,6 +9495,33 @@ static void systemd_service_toggle(const char *path, char *unit, bool enable)
94959495
}
94969496
}
94979497

9498+
static void systemd_samba_service_toggle(const char *path, char *unit, bool enable)
9499+
{
9500+
/* There is difference between samba and ssh/bluetooth.
9501+
* - samba.service is disabled if "/storage/.cache/services/samba.disabled" file is exist.
9502+
* - ssh.service is enabled if "/storage/.cache/services/sshd.conf" file is exist.
9503+
* - bluetooth.service is enabled if "/storage/.cache/services/bluez.conf" file is exist.
9504+
* So it separates the systemd_service_toggle for samba.service. */
9505+
9506+
pid_t pid = fork();
9507+
char* args[] = {(char*)"systemctl",
9508+
enable ? (char*)"start" : (char*)"stop",
9509+
unit,
9510+
NULL};
9511+
9512+
if (pid == 0)
9513+
{
9514+
if (enable)
9515+
filestream_delete(path);
9516+
else
9517+
filestream_close(filestream_open(path,
9518+
RETRO_VFS_FILE_ACCESS_WRITE,
9519+
RETRO_VFS_FILE_ACCESS_HINT_NONE));
9520+
9521+
execvp(args[0], args);
9522+
}
9523+
}
9524+
94989525
#ifdef HAVE_LAKKA_SWITCH
94999526
static void switch_oc_enable_toggle_change_handler(rarch_setting_t *setting)
95009527
{
@@ -9543,7 +9570,7 @@ static void ssh_enable_toggle_change_handler(rarch_setting_t *setting)
95439570

95449571
static void samba_enable_toggle_change_handler(rarch_setting_t *setting)
95459572
{
9546-
systemd_service_toggle(LAKKA_SAMBA_PATH, (char*)"smbd.service",
9573+
systemd_samba_service_toggle(LAKKA_SAMBA_DISABLED_FILE_PATH, (char*)"smbd.service",
95479574
*setting->value.target.boolean);
95489575
}
95499576

0 commit comments

Comments
 (0)