summaryrefslogtreecommitdiff
path: root/source3/librpc
AgeCommit message (Collapse)AuthorFilesLines
2026-03-30s3/librpc/crypto: Don't keep growing in memory keytabNoel Power1-1/+17
When we have long living concurrent connections every rpc bind ends up calling and subsequently adding keytab entries to the memory keytab returned by 'gse_krb5_get_server_keytab(...)'. This is happening because as long as there is a handle open for the keytab named "MEMORY:cifs_srv_keytab" then we keep adding entries to it. Note: There is no leak of gensec_security nor the krb5_keytab it contains. When rpc clients connected to the rpc worker process exit the gensec_security and the krb5_keytab structures are destructed as expected. However because we use a fixed name "MEMORY:cifs_srv_keytab" clients end up with a handle to a reference counted shared keytab. Destruction of the keytab results in the associated reference count being decremented. When the reference count reaches 0 the keytab is destroyed. To avoid the keytab being extended the easiest solution is to ensure a unique memory keytab is created for each client. BUG: https://bugzilla.samba.org/show_bug.cgi?id=16042 Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Noel Power <npower@samba.org> Autobuild-Date(master): Mon Mar 30 09:36:45 UTC 2026 on atb-devel-224
2026-01-22s3:libads: Separate use of ads->config.flags for NBT_* and DS_* valuesPavel Filipenský1-1/+3
Use of ads->config.flags is overloaded. It is used to: - pass DS_* flags down to cldap_netlogon() - store the server_type from NETLOGON_SAM_LOGON_RESPONSE Both cases use different values and cannot be combined. E.g. flags mess up with value 0x00000080 NBT_SERVER_CLOSEST 0x00000080 DS_PDC_REQUIRED 0x00000080 Let's create two separate flags nbt_server_type server_flags; /* NBT_* cldap flags identifying the services. */ uint32 required_flags; /* DS_* - Netlogon flags */ BUG: https://bugzilla.samba.org/show_bug.cgi?id=15972 Signed-off-by: Pavel Filipenský <pfilipensky@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org> Autobuild-Date(master): Thu Jan 22 09:14:25 UTC 2026 on atb-devel-224
2026-01-07librpc: Directly initialize variablesVolker Lendecke1-3/+3
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2025-08-22smbd: Fix a typoVolker Lendecke1-3/+3
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2025-08-05smbd: Add session_global_id and tcon_global_id to smbXsrv_open_global0Ralph Boehme1-0/+2
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2025-08-05smbd: add smbXsrv_tcon to smbXsrv_openRalph Boehme1-0/+1
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2025-08-05smbd: add smbXsrv_session to smbXsrv_openRalph Boehme1-0/+1
From "MS-SMB2 3.3.1.10 Per Open": Open.Session: A reference to the authenticated session, as specified in section 3.3.1.8, over which this open was performed. If the open is not attached to a session at this time, this value MUST be NULL. Needed to implement: 3.3.5.9 Receiving an SMB2 CREATE Request If the server implements the SMB 3.x dialect family and all of the following conditions are TRUE, the server MUST look up an Open in GlobalOpenTable where Open.IsReplayEligible is TRUE and Open.CreateGuid matches the CreateGuid in the SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 create context and Open.ClientGuid matches the ClientGuid of the connection that received this request: ... If an Open is found, the server MUST perform the following: .. If Open.Session.SessionId is not equal to the current Session.SessionId, the server MUST fail the request with STATUS_DUPLICATE_OBJECTID. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2025-08-05smbd: add and use smbXsrv_open_replay_cache_key_bufRalph Boehme1-0/+6
No change in behaviour. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2025-08-05smbd: make the replay cache record an index on the global open tableRalph Boehme1-3/+1
Store only the open_global record key as is in the replay-cache record, making it an index into the global open table. Then in the replay code, use the new function smbXsrv_open_global_lookup() to get at the open records. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2025-08-05smbd: move create_action to smbXsrv_open_global0Ralph Boehme1-1/+1
In preperation for making create replay disk backed. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2025-08-05smbd: simplify create-replayRalph Boehme1-2/+1
Just check state->open_was_deferred and skip calling smb2srv_open_lookup_replay_cache() if it is set. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2025-08-05librpc:gse: Implement storing tickets into an emtpy ccacheAndreas Schneider1-0/+65
smbclient //server/share --krb5-use-ccache=/tmp/foo Will write the ticket to the specified ccache. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
2025-04-18s3:smbd: store transport_type in smbXsrv_channel_global0Stefan Metzmacher1-0/+2
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2025-04-09s3/locking: remove now unused private_options from share_mode_entryRalph Boehme1-1/+0
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2025-04-09s3/locking: store NTCREATEX_FLAG_DENY_[DOS|FCB] as share_entry_flagsRalph Boehme1-1/+3
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2025-04-09s3/locking: store NTCREATEX_FLAG_STREAM_BASEOPEN as share_entry_flagRalph Boehme1-1/+2
No change in behaviour. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2025-04-09s3/librpc: open_files.idl: move flag definition into open_files.idlRalph Boehme1-1/+5
Nice to have everything in one place. No change in behaviour. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2025-03-27smbd: implement modern write time update logicRalph Boehme1-5/+0
The gist of this is: 1. A write or other modifications as per MS-FSA "2.1.4.17 Algorithm for Noting that a File Has Been Modified" immediately update the file times, there's no delayed update. 2. Setting a timestamp on a handle only disables further timestamp updates via that handle. Modifications via other handles must still update the timestamps. This can not be implemented by storing the sticky writetime in the share_mode_data record for performance reasons, as from 2 it follows that the record would have to be checked and updated for every write on all handles. Instead, writes on handles with sticky writetime in effect, record the current timestamp before the modification and reset the filesystem timestamp to the recorded value after doing the modification. For reference, these are the relevant pieces from MS-FSA: 2.1.1.6 Abstract Date Model: Per Open - UserSetModificationTime: A Boolean that is TRUE if a user has explicitly set File.LastModificationTime through this Open. - UserSetChangeTime: A Boolean that is TRUE if a user has explicitly set File.LastChangeTime through this Open. - UserSetAccessTime: A Boolean that is TRUE if a user has explicitly set File.LastAccessTime through this Open. 2.1.4.17 Algorithm for Noting That a File Has Been Modified The inputs for this algorithm are as follows: - Open: The Open through which the file was modified. The pseudocode for the algorithm is as follows: The object store SHOULD<43>: - If Open.UserSetModificationTime is FALSE, set Open.File.LastModificationTime to the current system time. - If Open.UserSetChangeTime is FALSE, set Open.File.LastChangeTime to the current system time. - If Open.UserSetAccessTime is FALSE, set Open.File.LastAccessTime to the current system time. - Set Open.File.FileAttributes.FILE_ATTRIBUTE_ARCHIVE to TRUE. This then gets used for eg writes: 2.1.5.4 Server Requests a Write ... - The object store MUST note that the file has been modified as specified in section 2.1.4.17 with Open equal to Open. ... Note the following differences between Windows behaviour and current MS-FSA, these are documentation bugs that will be fixed in later releases as discussed here: https://lists.samba.org/archive/cifs-protocol/2025-March/004453.html * When processing FileEndOfFileInformation timestamps must be updated if new size equals current size * When processing FileAllocationInformation timestamps must be updated if new size equals current size * When processing FileAllocationInformation, If (the new allocation size is less than the existing allocation) Set the modification time (which will also updates the change time) Else Update the LastChangeTime BUG: https://bugzilla.samba.org/show_bug.cgi?id=13594 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Thu Mar 27 06:37:31 UTC 2025 on atb-devel-224
2024-12-05gensec: add GENSEC_FEATURE_NO_DELEGATION flag to avoid GSS_C_DELEG[_POLICY]_FLAGStefan Metzmacher1-1/+4
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2024-11-05s3/locking: remember parent_lease_key that set delete-on-closeRalph Boehme1-0/+1
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2024-09-26s3:librpc/rpc: split out dcerpc_internal.h for struct pipe_auth_dataStefan Metzmacher3-12/+37
This should be anonymous for callers. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2024-09-26s3:rpc_client: header signing is negotiated per transport connectionStefan Metzmacher1-1/+0
All gensec backends support GENSEC_FEATURE_SIGN_PKT_HEADER, so there's no point in negotiating header signing based on the auth context used during the DCERPC Bind. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2024-09-26s3:rpc_client: the transport_session_key is per connection!Stefan Metzmacher1-3/+0
It's not per auth_context_id, currently there's no difference but that will change in future... Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2024-07-17s3:librpc: Fix a typo in DEBUG textPavel Filipenský1-2/+2
Signed-off-by: Pavel Filipenský <pfilipensky@samba.org> Reviewed-by: Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-06-24gse: Simplify gse_errstr() with talloc_asprintf_addbuf()Volker Lendecke1-13/+5
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2024-06-24gse: Avoid explicit ZERO_STRUCT in gse_errstr()Volker Lendecke1-5/+2
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2024-05-22s3:librpc: Use lp_dns_hostname() for creating the fqdnAndreas Schneider1-3/+7
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-05-14s3:libads: finally remove unused ads_connect[_user_creds]() and related codeStefan Metzmacher1-7/+0
That was a long way, but now we're cli_credentials/gensec only :-) Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2024-05-14s3:libnet_join: pass down cli_credentials *admin_credentials to ↵Stefan Metzmacher1-11/+5
libnet_{Join,Unjoin}Ctx() Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2024-05-14s3:libads: add ads_set_reconnect_fn() and only reconnect if we can get credsStefan Metzmacher1-0/+1
This reconnect is only useful for long running connections (e.g. in winbindd) and there we'll make use of it... Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2024-05-14s3:libads: move ads->auth.time_offset to ads->config.time_offsetStefan Metzmacher1-1/+1
There's no reason to pass the LDAP servers time to the kerberos libraries, as we may talk to a KDC different than the LDAP server! Also Heimdal handles AS-REQ with KRB5KRB_AP_ERR_SKEW fine and retries with the time from the krb-error. MIT records the time from the KDC_ERR_PREAUTH_REQUIRED response in order to use the KDCs time. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2024-05-14s3:libads: we only need to gensec_expire_time()...Stefan Metzmacher1-2/+1
The lifetime of a service ticket is never longer than the lifetime of the TGT... Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2024-05-14s3:libads: remove unused ads->auth.renewableStefan Metzmacher1-1/+0
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2024-05-14s3:libads: add ADS_AUTH_GENERATE_KRB5_CONFIG to generate a custom krb5.confStefan Metzmacher1-1/+2
That's better then using !ADS_AUTH_NO_BIND. And it allows callers to be more flexible in future. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2024-05-14s3:gse: get an explicit ccache_name from creds and kinit if requiredStefan Metzmacher1-1/+242
This means we may call kinit multiple times for now, but we'll remove the kinit from the callers soon. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2024-05-14s3:gse: Pass down the mech to gse_context_init()Andreas Schneider1-7/+27
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2024-05-14s3:gse: Implement gensec_gse_security_by_oid()Andreas Schneider2-2/+15
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2024-05-14s3:gse: Use smb_gss_mech_import_cred() in gse_init_server()Andreas Schneider1-1/+2
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2024-05-07s3:gse: don't call krb5_cc_resolve() as serverStefan Metzmacher1-15/+16
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2024-05-07s3:gse: avoid prompting for a password that we don't use in the endStefan Metzmacher1-7/+0
Currently we rely on a valid default credential cache being available and don't make use of the password. In future we'll do a kinit on demand, but that's for another day. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2024-05-07s3:gse: make use of gensec_kerberos_possible()Stefan Metzmacher1-22/+18
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2024-04-23smbdotconf: add client ldap sasl wrapping = {starttls,ldaps}Stefan Metzmacher1-1/+3
In order to use SASL authentitation within a TLS connection we now provide "client ldap sasl wrapping = starttls" or "client ldap sasl wrapping = ldaps". Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-04-23s3:libads: add tls_wrapping into openldapStefan Metzmacher1-0/+11
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-04-23s3:libads: always require ber_sockbuf_add_io() and LDAP_OPT_SOCKBUFStefan Metzmacher1-4/+4
There's no point in trying to support --with-ads, but only use plaintext ldap without sign/seal. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-04-23s3:libads: use the correct struct sockbuf_io_desc type for 'sbiod' pointerStefan Metzmacher1-1/+1
Using 'Sockbuf_IO_Desc' in idl implicitly means pidl will use 'struct Sockbuf_IO_Desc', which doesn't exist! Using 'struct sockbuf_io_desc' which is used in OpenLDAP to typedef Sockbuf_IO_Desc, we won't need to cast the assign the 'sbiod' pointer. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-04-23s3:libads: remove unused ADS_AUTH_SIMPLE_BIND codeStefan Metzmacher1-1/+0
We have other code to test simple binds. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-04-23s3:crypto/gse: implement channel binding supportStefan Metzmacher1-7/+88
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15621 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-04-05s3:libads: avoid changing ADS->server.workgroupStefan Metzmacher1-0/+1
ads_find_dc() uses c_domain = ads->server.workgroup and don't expect it to get out of scope deep in resolve_and_ping_dns(). The result are corrupted domain values in the debug output. Valgrind shows this: Invalid read of size 1 at 0x483EF46: strlen (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x608BE94: __vfprintf_internal (vfprintf-internal.c:1688) by 0x609ED49: __vasprintf_internal (vasprintf.c:57) by 0x5D2EC0F: __dbgtext_va (debug.c:1860) by 0x5D2ED3F: dbgtext (debug.c:1881) by 0x4BFFB50: ads_find_dc (ldap.c:570) by 0x4C001F4: ads_connect (ldap.c:704) by 0x4C1DC12: ads_dc_name (namequery_dc.c:84) Address 0xb69f6f0 is 0 bytes inside a block of size 11 free'd at 0x483CA3F: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x4BFF0AF: ads_try_connect (ldap.c:299) by 0x4BFF40E: cldap_ping_list (ldap.c:367) by 0x4BFF75F: resolve_and_ping_dns (ldap.c:468) by 0x4BFFA91: ads_find_dc (ldap.c:556) by 0x4C001F4: ads_connect (ldap.c:704) by 0x4C1DC12: ads_dc_name (namequery_dc.c:84) Block was alloc'd at at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x60B250E: strdup (strdup.c:42) by 0x4FF1492: smb_xstrdup (util.c:743) by 0x4C10E62: ads_init (ads_struct.c:148) by 0x4C1DB68: ads_dc_name (namequery_dc.c:73) BUG: https://bugzilla.samba.org/show_bug.cgi?id=14981 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-03-20s3-librpc: merge two PIDL listsGünther Deschner1-8/+1
Guenther Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-03-12smbd: Fix a typoVolker Lendecke1-1/+1
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>