Bug 15488 - print command %i/%I/%m/%M substitution broken (with tentative patch)
Summary: print command %i/%I/%m/%M substitution broken (with tentative patch)
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Printing (show other bugs)
Version: 4.19.0
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: printing-maintainers
QA Contact: Samba QA Contact
Depends on:
Reported: 2023-10-06 09:35 UTC by Franz Sirl
Modified: 2023-10-08 12:02 UTC (History)
2 users (show)

See Also:

tentative patch (3.21 KB, patch)
2023-10-06 09:35 UTC, Franz Sirl
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Franz Sirl 2023-10-06 09:35:24 UTC
Created attachment 18152 [details]
tentative patch


in samba 4.17, 4.18 and 4.19 (probably also 4.16 is affected) the print command substitutions for %i/%I/%m/%M are no longer functional.

My analysis shows that for %i/%I/%M the values are simply never initialized in the rpcd_spoolss case. The patch fixes that by setting up missing values and then calling sub_set_socket_ids() in source3/rpc_server/spoolss/srv_spoolss_nt.c:_spoolss_OpenPrinterEx(). There might be better places to do that though.

%m on the other hand is a different beast. It is supposed to be setup in source3/auth/auth_ntlmssp.c:auth3_check_password_send() via set_remote_machine_name(). But the problem is that rpcd_spoolss is now by default a preforked worker process and set_remote_machine_name() is called with True as it's second argument. This means that the remote machine name is always the machine name of the first handled connection during lifetime of the worker.
In the patch I fixed that for rpcd_spoolss simply by calling set_remote_machine_name() with False as it's second argument. But I guess that may be problematic for other code that uses auth3_check_password_send()?

Some notes:

- while debugging this I used a shell script based on smbprngenpdf with an added "sleep 60" and noticed that printing the Win10 testpage on one PC blocked printing the testpage on a second PC until the first print command is finished. Is the blocking still necessary with the worker-based design?

- Bug 15255 sounds like similar problems in a different part of the code
Comment 1 Andreas Schneider 2023-10-07 18:00:52 UTC
I think that sub_set_socket_ids() needs to be called in rpc_worker_new_client(). 

Comment 2 Volker Lendecke 2023-10-08 12:02:58 UTC
(In reply to Andreas Schneider from comment #1)
> I think that sub_set_socket_ids() needs to be called in
> rpc_worker_new_client(). 

This needs to happen on every call, the rpc daemons can now serve many clients in a single process.

It can be done, but this involves bigger work with a very close look at our loadparm subsystem and the way we do includes.