Created attachment 18152 [details]
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()?
- 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
I think that sub_set_socket_ids() needs to be called in rpc_worker_new_client().
(In reply to Andreas Schneider from comment #1)
> I think that sub_set_socket_ids() needs to be called in
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.