Skip to content

Commit a6cdf43

Browse files
committed
lakka: reconsideration for samba service enable disable
1 parent cba2a2c commit a6cdf43

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
@@ -3072,7 +3072,7 @@ void config_set_defaults(void *data)
30723072
configuration_set_bool(settings,
30733073
settings->bools.ssh_enable, filestream_exists(LAKKA_SSH_PATH));
30743074
configuration_set_bool(settings,
3075-
settings->bools.samba_enable, filestream_exists(LAKKA_SAMBA_PATH));
3075+
settings->bools.samba_enable, !filestream_exists(LAKKA_SAMBA_DISABLED_FILE_PATH));
30763076
configuration_set_bool(settings,
30773077
settings->bools.bluetooth_enable, filestream_exists(LAKKA_BLUETOOTH_PATH));
30783078
configuration_set_bool(settings, settings->bools.localap_enable, false);
@@ -4442,7 +4442,7 @@ static bool config_load_file(global_t *global,
44424442
configuration_set_bool(settings,
44434443
settings->bools.ssh_enable, filestream_exists(LAKKA_SSH_PATH));
44444444
configuration_set_bool(settings,
4445-
settings->bools.samba_enable, filestream_exists(LAKKA_SAMBA_PATH));
4445+
settings->bools.samba_enable, !filestream_exists(LAKKA_SAMBA_DISABLED_FILE_PATH));
44464446
configuration_set_bool(settings,
44474447
settings->bools.bluetooth_enable, filestream_exists(LAKKA_BLUETOOTH_PATH));
44484448
#ifdef HAVE_RETROFLAG
@@ -5700,11 +5700,11 @@ bool config_save_file(const char *path)
57005700
else
57015701
filestream_delete(LAKKA_SSH_PATH);
57025702
if (settings->bools.samba_enable)
5703-
filestream_close(filestream_open(LAKKA_SAMBA_PATH,
5703+
filestream_delete(LAKKA_SAMBA_DISABLED_FILE_PATH);
5704+
else
5705+
filestream_close(filestream_open(LAKKA_SAMBA_DISABLED_FILE_PATH,
57045706
RETRO_VFS_FILE_ACCESS_WRITE,
57055707
RETRO_VFS_FILE_ACCESS_HINT_NONE));
5706-
else
5707-
filestream_delete(LAKKA_SAMBA_PATH);
57085708
if (settings->bools.bluetooth_enable)
57095709
filestream_close(filestream_open(LAKKA_BLUETOOTH_PATH,
57105710
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
@@ -9465,6 +9465,33 @@ static void systemd_service_toggle(const char *path, char *unit, bool enable)
94659465
}
94669466
}
94679467

9468+
static void systemd_samba_service_toggle(const char *path, char *unit, bool enable)
9469+
{
9470+
/* There is difference between samba and ssh/bluetooth.
9471+
* - samba.service is disabled if "/storage/.cache/services/samba.disabled" file is exist.
9472+
* - ssh.service is enabled if "/storage/.cache/services/sshd.conf" file is exist.
9473+
* - bluetooth.service is enabled if "/storage/.cache/services/bluez.conf" file is exist.
9474+
* So it separates the systemd_service_toggle for samba.service. */
9475+
9476+
pid_t pid = fork();
9477+
char* args[] = {(char*)"systemctl",
9478+
enable ? (char*)"start" : (char*)"stop",
9479+
unit,
9480+
NULL};
9481+
9482+
if (pid == 0)
9483+
{
9484+
if (enable)
9485+
filestream_delete(path);
9486+
else
9487+
filestream_close(filestream_open(path,
9488+
RETRO_VFS_FILE_ACCESS_WRITE,
9489+
RETRO_VFS_FILE_ACCESS_HINT_NONE));
9490+
9491+
execvp(args[0], args);
9492+
}
9493+
}
9494+
94689495
#ifdef HAVE_LAKKA_SWITCH
94699496
static void switch_oc_enable_toggle_change_handler(rarch_setting_t *setting)
94709497
{
@@ -9513,7 +9540,7 @@ static void ssh_enable_toggle_change_handler(rarch_setting_t *setting)
95139540

95149541
static void samba_enable_toggle_change_handler(rarch_setting_t *setting)
95159542
{
9516-
systemd_service_toggle(LAKKA_SAMBA_PATH, (char*)"smbd.service",
9543+
systemd_samba_service_toggle(LAKKA_SAMBA_DISABLED_FILE_PATH, (char*)"smbd.service",
95179544
*setting->value.target.boolean);
95189545
}
95199546

0 commit comments

Comments
 (0)