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
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-18 12:34 UTC by Björn Jacke
Modified: 2022-08-08 14:36 UTC (History)
1 user (show)

See Also:


Attachments

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

[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:
                     try:
-                        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:

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

1c6e59a7dfcc0758606db835082bfe789356e382
5750d7a1d05bccf61b3ae0ea4dcb36e0c103cb26
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):

1c6e59a7dfcc0758606db835082bfe789356e382
5750d7a1d05bccf61b3ae0ea4dcb36e0c103cb26