Skip to content

Commit

Permalink
ksmbd-tools: add smb.conf fallback functionality
Browse files Browse the repository at this point in the history
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 <atteh.mailbox@gmail.com>
  • Loading branch information
atheik committed Sep 3, 2022
1 parent db5d672 commit 07051e6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
7 changes: 4 additions & 3 deletions include/ksmbdtools.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 13 additions & 2 deletions lib/config_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 07051e6

Please sign in to comment.