Bug 15070 - samba-tool testparm -s /other/smb.conf is broken with --section-name parameter
Summary: samba-tool testparm -s /other/smb.conf is broken with --section-name parameter
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Tools (show other bugs)
Version: 4.16.1
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
Depends on:
Reported: 2022-05-18 12:34 UTC by Björn Jacke
Modified: 2022-08-08 14:36 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Björn Jacke 2022-05-18 12:34:40 UTC
running this command:

# samba-tool testparm --supress-prompt -s /root/some_other_smb.conf --section-name=global

will output:

ERROR: Unknown section global

Even though there is an ordinary global section present there. With out the "-s some_other_smb.conf" option this is working correctly.
Comment 1 Douglas Bagnall 2022-08-04 01:08:14 UTC
I can reproduce in a testenv with 

$ bin/samba-tool testparm --suppress-prompt -s st/ad_dc/etc/smb.conf --section-name=global

but I think only "global" is broken?

$ bin/samba-tool testparm --suppress-prompt -s st/ad_dc/etc/smb.conf --section-name=xattr

        path = /home/douglasb/src/samba/st/ad_dc/share
        vfs objects = streams_xattr acl_xattr

Fixes for https://bugzilla.samba.org/show_bug.cgi?id=14143 changed things here. 

If I go 

--- a/python/samba/netcmd/testparm.py
+++ b/python/samba/netcmd/testparm.py
@@ -104,8 +104,12 @@ class cmd_testparm(Command):
             if section_name is not None or parameter_name is not None:
                 if parameter_name is None:
-                        section = lp[section_name]
+                        if section_name == 'global':
+                            section = lp.default_service
+                        else:
+                            section = lp[section_name]
                     except KeyError:

which *seems* plausible, I get a segfault.
Comment 2 Samba QA Contact 2022-08-06 01:43:20 UTC
This bug was referenced in samba master:

Comment 3 Samba QA Contact 2022-08-08 14:32:14 UTC
This bug was referenced in samba v4-17-test:

Comment 4 Samba QA Contact 2022-08-08 14:36:27 UTC
This bug was referenced in samba v4-17-stable (Release samba-4.17.0rc1):