Jra bug 13992 fix
Fix bug https://bugzilla.samba.org/show_bug.cgi?id=13992.
The problem is that net rpc share allowedusers
opens a SVRSVC pipes on a cli tcon, and then switches to a new tcon to open a handle on the root directory of each share and query the security descriptors. It uses logic like:
cli_state_save_tcon()/cli_tree_connect()/...do stuff.../cli_tdis(new connection)/cli_state_restore_tcon()
Unfortunately the existing cli_state_save_tcon() does a deep copy of the cli->smb[1|2].tcon struct to save it. This misses any pipe handles that have been allocated as talloc children of cli->smb[1|2].tcon and so they don't get copied. When the existing cli->smb[1|2].tcon is talloc freed to prepare for the new connection the pipes are disconnected, so the existing net rpc share allowedusers
will only successfully query the first share.
We didn't notice this as the existing samba3.blackbox.net_rpc_share_allowedusers
test only checks for one share (a comedy of errors).
Fix this by:
(1). Extending the test to check that all shares are correctly checked. (2) changing cli_state_save_tcon()/cli_state_restore_tcon() to do do a pointer swap, leaving the existing allocated tcon struct around to be returned.
Slightly more complex to fix as I needed to ensure all error code paths correctly call cli_state_restore_tcon() on error, and fix one horrible SMB1 test (UID-REGRESSION-TEST, I wrote it so I'm to blame :-) which still needed the deep copy (it doesn't actually do new connections, just wants to mangle the existing one multiple times).
Passes ci.