Bug 11024 - Variable substitution broken/not working in "logon script" for %g and %G
Summary: Variable substitution broken/not working in "logon script" for %g and %G
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: 4.1.11
Hardware: x86 Linux
: P5 major (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-26 09:44 UTC by Denis BUCHER
Modified: 2016-04-03 20:07 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Denis BUCHER 2014-12-26 09:44:58 UTC
Dear all, I hope this bug report will be clear enough.

I think I found bug with Samba 4.1.11.

When I define a fixed-name as logon script in smb.conf, it works : 

logon script = employee.bat 

But if I try either %g.bat or %G.bat, or even "%G.bat", it doesn't work
: 

 	* logon script = %g.bat
 	* logon script = %G.bat
 	* logon script = "%G.bat"

In the logs, there was a message showing that Samba was trying to open
the "%G.bat" file and that the file was not found on the disk. (Of
course) 


[2014/11/21 20:53:36.616573, 5]
../source3/smbd/filename.c:258(unix_convert)
 unix_convert called on file "%g.bat"
[2014/11/21 20:53:36.616622, 5]
../source3/smbd/filename.c:421(unix_convert)
 unix_convert begin: name = %g.bat, dirpath = , start = %g.bat
[2014/11/21 20:53:36.616705, 5]
../source3/smbd/filename.c:816(unix_convert)
 New file %g.bat
[2014/11/21 20:53:36.616747, 3]
../source3/smbd/vfs.c:1137(check_reduced_name)
 check_reduced_name [%g.bat] [/data/shares/netlogon]
[2014/11/21 20:53:36.616794, 3]
../source3/smbd/vfs.c:1267(check_reduced_name)
 check_reduced_name: %g.bat reduced to /data/shares/netlogon/%g.bat
[2014/11/21 20:53:36.616838, 5]
../lib/dbwrap/dbwrap.c:187(dbwrap_check_lock_order)
 check lock order 1 for /var/run/samba/smbXsrv_open_global.tdb
[2014/11/21 20:53:36.616906, 5]
../lib/dbwrap/dbwrap.c:146(dbwrap_lock_order_state_destructor)
 release lock order 1 for /var/run/samba/smbXsrv_open_global.tdb
[2014/11/21 20:53:36.616950, 5] ../source3/smbd/files.c:128(file_new)
 allocated file structure fnum 2158460712 (2 used)
[2014/11/21 20:53:36.616995, 3] ../source3/smbd/dosmode.c:163(unix_mode)
 unix_mode(%g.bat) returning 0744
[2014/11/21 20:53:36.617034, 5]
../source3/smbd/open.c:2168(open_file_ntcreate)
 open_file_ntcreate: FILE_OPEN requested for file %g.bat and file doesn't exist.

Denis
Comment 1 Denis BUCHER 2014-12-26 10:05:50 UTC
To give more details, I tried this, which proves that while only %U is working, all others (%G, %g, %u) are broken :

logon script = %G%g%U%u.bat

[2014/12/26 10:58:44.958812,  5] ../source3/smbd/filename.c:258(unix_convert)
  unix_convert called on file "%G%gdbucher%u.bat"
[2014/12/26 10:58:44.958863,  5] ../source3/smbd/filename.c:421(unix_convert)
  unix_convert begin: name = %G%gdbucher%u.bat, dirpath = , start = %G%gdbucher%u.bat
[2014/12/26 10:58:44.958956,  5] ../source3/smbd/filename.c:816(unix_convert)
  New file %G%gdbucher%u.bat
[2014/12/26 10:58:44.959002,  3] ../source3/smbd/vfs.c:1137(check_reduced_name)
  check_reduced_name [%G%gdbucher%u.bat] [/data/shares/netlogon]
[2014/12/26 10:58:44.959052,  3] ../source3/smbd/vfs.c:1267(check_reduced_name)
  check_reduced_name: %G%gdbucher%u.bat reduced to /data/shares/netlogon/%G%gdbucher%u.bat
[2014/12/26 10:58:44.959106,  5] ../lib/dbwrap/dbwrap.c:187(dbwrap_check_lock_order)
  check lock order 1 for /var/run/samba/smbXsrv_open_global.tdb
[2014/12/26 10:58:44.959185,  5] ../lib/dbwrap/dbwrap.c:146(dbwrap_lock_order_state_destructor)
  release lock order 1 for /var/run/samba/smbXsrv_open_global.tdb
[2014/12/26 10:58:44.959230,  5] ../source3/smbd/files.c:128(file_new)
  allocated file structure fnum 491426714 (5 used)
[2014/12/26 10:58:44.959276,  3] ../source3/smbd/dosmode.c:163(unix_mode)
  unix_mode(%G%gdbucher%u.bat) returning 0744
Comment 2 george giagas 2015-01-04 16:46:45 UTC
I have the same problem in samba 4.1.11
logon sript = %U.bat      is working
but
logon sript = %G.bat      is not working

Does the %G parametr has been replaced with another
Can someone help me?
Comment 3 Andreas 2016-04-03 19:52:25 UTC
Same Problem here.

This was the blocker for us to upgrade to Samba4 and bug still not fixed :(
Any fix to get group logon scripts working? It's a must have for us.

Problem since some of the latest 3.6.x versions and all 4.x versions I tested have this bug.
Makes no difference if using Sernet packages, latest Fedora, Redhat/CentOS or Ubuntu.

This bug exists ONLY in the global section of smb.conf!!

If you set %G %g etc. in the comment field of a share they are substituted as expected.

A very simple test to show the bug is:
pdbedit -v <username>

example:

[root@server samba]# pdbedit -v pik1
Unix username:        pik1
NT username:          
Account Flags:        [U          ]
User SID:             S-1-5-21-xxxxxxxxxx-yyyyyyyyy-zzzzzzzzzz-1010
Primary Group SID:    S-1-5-21-xxxxxxxxxx-yyyyyyyyy-zzzzzzzzzz-513
Full Name:            Praktikum IK User 1
Home Directory:       \\praktikums\pik1
HomeDir Drive:        Z:
Logon Script:         scripts\%G.bat
Profile Path:         \\praktikums\Profiles\%G\pik1
Domain:               PRAKTIKUM
Account desc:         
Workstations:         
Munged dial:          
Logon time:           0
Logoff time:          9223372036854775807 seconds since the Epoch
Kickoff time:         9223372036854775807 seconds since the Epoch
Password last set:    Mi, 21 Okt 2015 14:14:59 CEST
Password can change:  Mi, 21 Okt 2015 14:14:59 CEST
Password must change: never
Last bad password   : 0
Bad password count  : 0
Logon hours         : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF


In "Logon Script" and "Profile Path" you see the %G which isn't substituted!
%U is substituted as expected.

Any news? Any fixes?
Comment 4 Andreas 2016-04-03 20:07:27 UTC
One addition:

We are running Samba as PDC.
Samba as ADS is not an option at the moment.