smb: fix Kerberos credentials being reloaded for every connection - fixes #9674

A new KerberosFactory was constructed for every dial, so the client,
error and ccache modification time caches it holds were discarded
after a single use. Every new SMB connection re-read the Kerberos
config, re-parsed the ccache and did a fresh KDC exchange.

Share a single factory so clients are cached across connections as
intended, and refreshed when the ccache file changes.
This commit is contained in:
Nick Craig-Wood
2026-07-30 17:47:21 +01:00
parent 862ed2b7ac
commit 76d1adb7a6
2 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ func (f *Fs) dial(ctx context.Context, network, addr string) (*conn, error) {
d := &smb2.Dialer{}
if f.opt.UseKerberos {
cl, err := NewKerberosFactory().GetClient(f.opt.KerberosCCache)
cl, err := kerberosFactory.GetClient(f.opt.KerberosCCache)
if err != nil {
return nil, err
}
+3
View File
@@ -33,6 +33,9 @@ type KerberosFactory struct {
loadConfig func() (*config.Config, error)
}
// kerberosFactory is the shared KerberosFactory used to cache all connections
var kerberosFactory = NewKerberosFactory()
// NewKerberosFactory creates a new instance of KerberosFactory with default dependencies.
func NewKerberosFactory() *KerberosFactory {
return &KerberosFactory{