From 07051e66491de7245e9c1aba4c2d73adce4b08e1 Mon Sep 17 00:00:00 2001 From: atheik Date: Sat, 3 Sep 2022 03:20:51 +0300 Subject: [PATCH] ksmbd-tools: add smb.conf fallback functionality Give existing users a chance to switch from `sysconfdir/ksmbd/smb.conf' to `sysconfdir/ksmbd/ksmbd.conf' by falling back to the former if the latter does not exist. This fallback functionality may be removed in any future release. Signed-off-by: atheik --- include/ksmbdtools.h | 7 ++++--- lib/config_parser.c | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/include/ksmbdtools.h b/include/ksmbdtools.h index 4ddecef5..3be953ee 100644 --- a/include/ksmbdtools.h +++ b/include/ksmbdtools.h @@ -84,9 +84,10 @@ extern struct smbconf_global global_conf; #define KSMBD_CONF_FILE_MAX 10000 -#define PATH_PWDDB SYSCONFDIR "/ksmbd/ksmbdpwd.db" -#define PATH_SMBCONF SYSCONFDIR "/ksmbd/ksmbd.conf" -#define PATH_SUBAUTH SYSCONFDIR "/ksmbd/ksmbd.subauth" +#define PATH_PWDDB SYSCONFDIR "/ksmbd/ksmbdpwd.db" +#define PATH_SMBCONF SYSCONFDIR "/ksmbd/ksmbd.conf" +#define PATH_SMBCONF_FALLBACK SYSCONFDIR "/ksmbd/smb.conf" +#define PATH_SUBAUTH SYSCONFDIR "/ksmbd/ksmbd.subauth" #define KSMBD_HEALTH_START (0) #define KSMBD_HEALTH_RUNNING (1 << 0) diff --git a/lib/config_parser.c b/lib/config_parser.c index 2dbc0c76..76aba60e 100644 --- a/lib/config_parser.c +++ b/lib/config_parser.c @@ -705,11 +705,22 @@ int cp_parse_pwddb(const char *pwddb) int cp_smbconfig_hash_create(const char *smbconf) { - int ret = init_smbconf_parser(); + int ret; + ret = init_smbconf_parser(); if (ret) return ret; - return __mmap_parse_file(smbconf, process_smbconf_entry); + + ret = __mmap_parse_file(smbconf, process_smbconf_entry); + if (ret == -ENOENT && !strcmp(smbconf, PATH_SMBCONF)) { + ret = __mmap_parse_file(PATH_SMBCONF_FALLBACK, + process_smbconf_entry); + if (!ret) + pr_err("Use of `%s' is deprecated, rename it to `%s' now!\n", + PATH_SMBCONF_FALLBACK, PATH_SMBCONF); + } + + return ret; } int cp_parse_subauth(void)