Bug 15826 - '%u' & '%U' in smb.conf do not return correct username
Summary: '%u' & '%U' in smb.conf do not return correct username
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Winbind (show other bugs)
Version: 4.21.4
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-03-14 20:07 UTC by Rowland Penny
Modified: 2025-03-14 20:07 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rowland Penny 2025-03-14 20:07:29 UTC
if '%u' or '%U' is used in a root preexec script, you do not get the correct usename returned.

Previously (i.e. last time I used such a script) it would return the same username as 'getent passwd'.

I created a simple test script:

#!/bin/bash

uSERNAME="$1"
Username="$2"

logger "$0: %u: $uSERNAME"
logger "$0: %U: $Username"

The share was this:

[testshare]
        path = /srv/test
        read only = no
        root preexec = /usr/local/sbin/testparm.sh %u %U

Connecting to the share resulted in this in syslog:

2025-03-14T17:07:28.486254+00:00 rpi5mem root: /usr/local/sbin/testparm.sh: %u: SAMDOMrowland
2025-03-14T17:07:28.488798+00:00 rpi5mem root: /usr/local/sbin/testparm.sh: %U: rowland_samdom.example.com

I expected 'rowland' for both.