Skip to content
Browse files

lib/param: handle (ignore) substitution variable in smb.conf


The function handle_include returns false when trying to include
files that have a substitution variable in filename (like %U),
this patch makes handle_include to ignore this case, to make
samba-tool work when there is such include in samba's configuration.

Error was :
	root@ubuntu:/usr/local/samba# grep 'include.*%U' etc/smb.conf
	include = %U.conf
	root@ubuntu:/usr/local/samba# ./bin/samba-tool user list
	Can't find include file %U.conf
	ERROR(runtime): uncaught exception - Unable to load default file

Signed-off-by: Quentin Gibeaux <>
Reviewed-by: Michael Adam <>
Reviewed-by: Jeremy Allison <>

Autobuild-User(master): Jeremy Allison <>
Autobuild-Date(master): Wed Dec  9 02:05:30 CET 2015 on sn-devel-104
  • Loading branch information...
QGuLL authored and jrasamba committed Oct 29, 2015
1 parent ea6de66 commit 3c6ea3293c6aac67bc442f47185fd494714e4806
Showing with 18 additions and 0 deletions.
  1. +18 −0 lib/param/loadparm.c
@@ -1113,6 +1113,8 @@ bool handle_include(struct loadparm_context *lp_ctx, struct loadparm_service *se
const char *pszParmValue, char **ptr)
char *fname;
const char *substitution_variable_substring;
char next_char;

if (lp_ctx->s3_fns) {
return lp_ctx->s3_fns->lp_include(lp_ctx, service, pszParmValue, ptr);
@@ -1127,6 +1129,22 @@ bool handle_include(struct loadparm_context *lp_ctx, struct loadparm_service *se
if (file_exist(fname))
return pm_process(fname, do_section, lpcfg_do_parameter, lp_ctx);

* If the file doesn't exist, we check that it isn't due to variable
* substitution
substitution_variable_substring = strchr(fname, '%');

if (substitution_variable_substring != NULL) {
next_char = substitution_variable_substring[1];
if ((next_char >= 'a' && next_char <= 'z')
|| (next_char >= 'A' && next_char <= 'Z')) {
DEBUG(2, ("Tried to load %s but variable substitution in "
"filename, ignoring file.\n", fname));
return true;

DEBUG(2, ("Can't find include file %s\n", fname));

return false;

0 comments on commit 3c6ea32

Please sign in to comment.
You can’t perform that action at this time.