Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor formatting goofs in ksmbd.conf.example #300

Open
BMJ-pdx opened this issue Apr 8, 2023 · 6 comments
Open

Minor formatting goofs in ksmbd.conf.example #300

BMJ-pdx opened this issue Apr 8, 2023 · 6 comments

Comments

@BMJ-pdx
Copy link

BMJ-pdx commented Apr 8, 2023

There are two related formatting goofs in ksmbd.conf.example (3.4.8 ksmbd-tools).
They're very minor; I mention them only because both that file and the ksmdb.conf man page meet a very high standard.

  1. The "max connections' parameter in [global] "global section parameters" is out of order (at the end of that subsection).
  2. There is a duplicate of it in [global] "share parameters for all sections". (It doesn't belong there; it's tagged 'G' in the man page.) That causes a warning (?; possibly just info) message.
@namjaejeon
Copy link
Member

Please send the patch to us.

@BMJ-pdx
Copy link
Author

BMJ-pdx commented Apr 12, 2023

Patch has been sent via email. (I couldn't find a way to enter it here without it getting bogusly formatted -- indentation altered, and the leading '-' of the unified diff getting turned into bullets. Is there a way?)

@atheik
Copy link
Member

atheik commented May 14, 2023

@namjaejeon, @BMJ-pdx,

This confusion is related to problems caused by commit 785a9d2.

Before commit 785a9d2, max connections was a share parameter, meaning that giving it in the global section set the default value for the max connections share parameter for each share. After 785a9d2, it is both a global parameter and a share parameter, and as a global parameter it limits simultaneous connections to the ksmbd server and not each share individually. This means that it is no longer possible to set the default value for max connections share parameter by giving it in the global section.

Similarly, guest account is unfortunately both a global parameter and a share parameter. See #281 (comment) and commit a09f767 for the related discussion. Note that the ksmbd.conf(5) man page reflects this situation with guest account:

\fBguest account\fR (G)
User that does not require a password when connecting to any share with \fBguest ok = yes\fR specified.
When connecting to such a share with the user left empty, the parameter determines what system user to map to.
Default: \fBguest account = nobody\fR \" KSMBD_CONF_DEFAULT_GUEST_ACCOUNT
.TP
\fBguest account\fR (S)
User that does not require a password when connecting to the share with \fBguest ok = yes\fR specified.
Default: \fBguest account = \fR

As a result of commit 785a9d2, the description for max connections is wrong in ksmbd.conf(5). The global parameter concerns the maximum number of simultaneous connections to the server and not any share. The descriptions for the share parameter and the global parameter should be kept separate just like they are for guest account. Also, note that the share parameter does not support the memparse() suffixes.

@namjaejeon
Copy link
Member

@atheik Okay, Please fix it. I will apply it if you provide the patch to me.

@atheik
Copy link
Member

atheik commented May 14, 2023

@namjaejeon,

[PATCH] ksmbd-tools: fix handling of max connections on config reload (click the arrow to expand)
From e68f7110ea5ee6e27968daf9fec81d13c89d2407 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Atte=20Heikkil=C3=A4?= <[email protected]>
Date: Sun, 14 May 2023 21:37:17 +0300
Subject: [PATCH] ksmbd-tools: fix handling of max connections on config reload
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

As of commit 785a9d2, `max connections' is both a global parameter and
a share parameter. This introduces a bug where the global parameter
is confused for the share parameter on config reload if a share has not
specified the latter. This bug is identical to the one fixed in commit
a09f767 for the `guest account' global and share parameters. As such,
fix it the same way. Additionally, since the `max connections' *share*
parameter can no longer be given in the global section, remove it from
the ksmbd.conf.example file. Also, fix the `smb3 encryption' default.
Finally, describe both the global parameter and the share parameter in
ksmbd.conf(5) since they are distinct. Omit the use of number suffixes
since they are not supported by the share parameter code path.

Signed-off-by: Atte Heikkilä <[email protected]>
---
 ksmbd.conf.5.in       | 10 ++++++++--
 ksmbd.conf.example    |  5 ++---
 tools/config_parser.c |  1 +
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/ksmbd.conf.5.in b/ksmbd.conf.5.in
index efb9c3f..6fd2bf7 100644
--- a/ksmbd.conf.5.in
+++ b/ksmbd.conf.5.in
@@ -173,10 +173,16 @@ Maximum number of simultaneous sessions to all shares.
 Default: \fBmax active sessions = 1024\fR \" KSMBD_CONF_DEFAULT_SESS_CAP
 .TP
 \fBmax connections\fR (G)
+Maximum number of simultaneous connections to the server.
+With \fBmax connections = 0\fR, the value will be set to the maximum allowed number of 65536. \" KSMBD_CONF_MAX_CONNECTIONS
+
+Default: \fBmax connections = 128\fR \" KSMBD_CONF_DEFAULT_CONNECTIONS
+.TP
+\fBmax connections\fR (S)
 Maximum number of simultaneous connections to the share.
-The maximum value is 64k. Values greater than 64k or 0 will be silently set to 64k.
+With \fBmax connections = 0\fR, the value will be set to the maximum allowed number of 65536. \" KSMBD_CONF_MAX_CONNECTIONS
 
-Default: \fBmax connections = 128\fR
+Default: \fBmax connections = 128\fR \" KSMBD_CONF_DEFAULT_CONNECTIONS
 .TP
 \fBmax open files\fR (G)
 Maximum number of simultaneous open files for a client.
diff --git a/ksmbd.conf.example b/ksmbd.conf.example
index 2e1eda8..c7e70af 100644
--- a/ksmbd.conf.example
+++ b/ksmbd.conf.example
@@ -11,6 +11,7 @@
 	kerberos service name = 
 	map to guest = never
 	max active sessions = 1024
+	max connections = 128
 	max open files = 10000
 	netbios name = KSMBD SERVER
 	restrict anonymous = 0
@@ -26,11 +27,10 @@
 	smb2 max read = 4MB
 	smb2 max trans = 1MB
 	smb2 max write = 4MB
-	smb3 encryption = no
+	smb3 encryption = auto
 	smbd max io size = 8MB
 	tcp port = 445
 	workgroup = WORKGROUP
-	max connections = 128
 
 	; share parameters for all sections
 	browseable = yes
@@ -45,7 +45,6 @@
 	hide dot files = yes
 	inherit owner = no
 	invalid users = 
-	max connections = 128
 	oplocks = yes
 	path = 
 	read list = 
diff --git a/tools/config_parser.c b/tools/config_parser.c
index a675b51..ae19db8 100644
--- a/tools/config_parser.c
+++ b/tools/config_parser.c
@@ -598,6 +598,7 @@ static void global_conf_update(struct smbconf_group *group)
 		return;
 
 	g_hash_table_remove(global_group->kv, "guest account");
+	g_hash_table_remove(global_group->kv, "max connections");
 	g_hash_table_foreach(global_group->kv, append_key_value, group->kv);
 }
 
-- 
2.40.1

@namjaejeon
Copy link
Member

@atheik Applied. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants