Bug 15501 - when using %I variable substitution, smbclient -L does not list share
Summary: when using %I variable substitution, smbclient -L does not list share
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: 4.19.2
Hardware: All Linux
: P5 normal (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-24 12:57 UTC by jdietrch
Modified: 2023-10-24 12:57 UTC (History)
0 users

See Also:


Attachments
level 10 debug logs, tcpdump packet capture, and config files for both cases (241.43 KB, application/zip)
2023-10-24 12:57 UTC, jdietrch
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description jdietrch 2023-10-24 12:57:13 UTC
Created attachment 18175 [details]
level 10 debug logs, tcpdump packet capture, and config files for both cases

I have Samba 4.19.2 running on Debian unstable with a smb.conf that looks like this:
[global]
   server role = standalone server
   map to guest = bad user

   debug level = 10
   debug pid = true
   max log size = 0

   hosts deny = ALL
   hosts allow = 10.45.12.20

#include = /etc/samba/%I
include = /etc/samba/10.45.12.20

The file 10.45.12.20 looks like this:
[testshare]
   path = /dfg
   read only = No
   guest ok = Yes

Now on my client (running Debian stable version 12.2, with an ip address of 10.45.12.20) I run the following smbclient command (when it asks for a password I just press Enter):
jdietrch@saturn:~$ smbclient -L bbccz
Password for [WORKGROUP\jdietrch]:

        Sharename       Type      Comment
        ---------       ----      -------
        testshare       Disk
        IPC$            IPC       IPC Service (Samba 4.19.2-Debian)
SMB1 disabled -- no workgroup available
jdietrch@saturn:~$

Notice that the share named "testshare" appears. This is just what I would expect.

However, I then change the smb.conf to this:
[global]
   server role = standalone server
   map to guest = bad user

   debug level = 10
   debug pid = true
   max log size = 0

   hosts deny = ALL
   hosts allow = 10.45.12.20

include = /etc/samba/%I
#include = /etc/samba/10.45.12.20

The only change is that I am now using variable substitution: %I instead of explicitly specifying the filename. The end result should be the same, since that is the IP address of the client. However, that is not the case. Notice what happens when I run the same smbclient command:
jdietrch@saturn:~$ smbclient -L bbccz
Password for [WORKGROUP\jdietrch]:

        Sharename       Type      Comment
        ---------       ----      -------
        IPC$            IPC       IPC Service (Samba 4.19.2-Debian)
SMB1 disabled -- no workgroup available
jdietrch@saturn:~$

In particular, notice that the share named "testshare" does not appear anymore. And I do have access to the share. If I connect to it directly by name, that works just fine:
jdietrch@saturn:~/software$ smbclient //bbccz/testshare
Password for [WORKGROUP\jdietrch]:
Try "help" to get a list of possible commands.
smb: \> ls
  .                                   D        0  Mon Oct 23 10:27:21 2023
  ..                                  D        0  Mon Oct 23 10:27:21 2023
  test_file1.txt                      N       14  Mon Oct 23 10:27:21 2023

                19480400 blocks of size 1024. 16250300 blocks available
smb: \>

I do not think that this issue is a matter of configuration or setup, because the only difference between whether or not the share is listed, is whether the include file line uses the %I variable substitution or not.

For both cases I have recorded level 10 debug logs and a tcpdump packet capture, which I will attach to this bug report.

If there is any further information that I can give, or anything else I can do that would be helpful, please don't hesitate to ask.

Thank you,
James Dietrich

Further details:
The server is running Debian unstable with this version of Samba:
Package: samba
Status: install ok installed
Priority: optional
Section: net
Installed-Size: 4039
Maintainer: Debian Samba Maintainers <pkg-samba-maint@lists.alioth.debian.org>
Architecture: amd64
Version: 2:4.19.2+dfsg-1
Depends: passwd, libpam-modules, libpam-runtime (>= 1.0.1-11), procps, python3, python3-dnspython, python3-samba (= 2:4.19.2+dfsg-1), samba-common (= 2:4.19.2+dfsg-1), samba-common-bin (= 2:4.19.2+dfsg-1), tdb-tools, python3:any, libbsd0 (>= 0.6.0), libc6 (>= 2.34), libcups2 (>= 1.7.0), libgnutls30 (>= 3.7.0), libldap-2.5-0 (>= 2.5.4), libldb2 (>= 2:2.6.1), libpopt0 (>= 1.14), libtalloc2 (>= 2.4.1~), libtasn1-6 (>= 4.14), libtdb1 (>= 1.4.9~), libtevent0 (>= 0.15.0), samba-libs (= 2:4.19.2+dfsg-1)
Pre-Depends: init-system-helpers (>= 1.54~)
Recommends: attr, logrotate, python3-markdown, samba-dsdb-modules, samba-vfs-modules, samba-ad-provision
Suggests: bind9 (>= 1:9.5.1), bind9utils, ctdb, ldb-tools, ntp | chrony (>= 3.0-1), ufw, winbind
Breaks: samba-ad-provision (<< 2:4.19.2+dfsg)
Enhances: bind9, ntp
Conffiles:
 /etc/cron.daily/samba f6519535df7964f95cdd7db501bf3ad2
 /etc/init.d/nmbd 30057931c86464cb86fcda7d88cb6783
 /etc/init.d/samba-ad-dc 0d6f8b3ba8294ece9ac3e92935dd9f2f
 /etc/init.d/smbd 0484fd637bf5fbc03055ed9868d40e51
 /etc/logrotate.d/samba 9ffd438b436e01f7a5817205ae983351
 /etc/ufw/applications.d/samba 9d474788f9a1955e16134f2794be473d
Description: SMB/CIFS file, print, and login server for Unix
 Samba is an implementation of the SMB/CIFS protocol for Unix systems,
 providing support for cross-platform file and printer sharing with
 Microsoft Windows, OS X, and other Unix systems.  Samba can also function
 as an Active Directory or NT4-style domain controller, and can integrate
 with Active Directory realms or NT4 domains as a member server.
 .
 This package provides the components necessary to use Samba as a stand-alone
 file and print server or as an NT4 domain controller.  For use in an NT4
 domain or Active Directory realm, you will also need the winbind package.
 To use samba as an Active Directory domain controller (AD DC), please install
 samba-ad-dc package.
 .
 This package is not required for connecting to existing SMB/CIFS servers
 (see smbclient) or for mounting remote filesystems (see cifs-utils).
Homepage: https://www.samba.org