@@ -495,7 +495,13 @@ def __init__(self, command, target, creds):
495495 self .env = os .environ .copy ()
496496 self .env ['KRB5CCNAME' ] = self .creds .ticket_file
497497 # User and domain are taken from the ticket
498- self .exec += ['-k' ]
498+ # Kerberos options differ between samba versions
499+ samba_version = re .match (r".*(\d+\.\d+\.\d+).*" , check_output (["smbclient" , "--version" ]).decode ()).group (1 )
500+ samba_version = tuple (int (x ) for x in samba_version .split ('.' ))
501+ if samba_version < (4 , 15 , 0 ):
502+ self .exec += ['-k' ]
503+ else :
504+ self .exec += ['--use-krb5-ccache' , self .creds .ticket_file ]
499505 elif creds .nthash :
500506 self .exec += ['-W' , f'{ self .creds .domain } ' ]
501507 self .exec += ['-U' , f'{ self .creds .user } %{ self .creds .nthash } ' , '--pw-nt-hash' ]
@@ -539,6 +545,9 @@ def run(self, log, error_filter=True):
539545 output = output .replace (line , "" )
540546 output = output .rstrip ('\n ' )
541547
548+ if "Cannot find KDC for realm" in output :
549+ return Result (False , "Cannot find KDC for realm, check DNS settings or setup /etc/krb5.conf" )
550+
542551 if retval == 1 and not output :
543552 return Result (False , "empty response" )
544553
0 commit comments