Skip to content

Commit 8a97afd

Browse files
committed
s3-net: fix "net ads kerberos" krb5ccname handling
We can only rely on KRB5CCNAME being set, --use-krb5-ccname content is not available. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15840 Guenther Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Günther Deschner <gd@samba.org> Autobuild-Date(master): Thu Jul 24 17:31:14 UTC 2025 on atb-devel-224
1 parent 18d0574 commit 8a97afd

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

selftest/knownfail

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,3 @@
338338

339339
# We currently don't send referrals for LDAP modify of non-replicated attrs
340340
^samba4.ldap.rodc.python\(rodc\).__main__.RodcTests.test_modify_nonreplicated.*
341-
342-
# net ads kerberos
343-
samba3.blackbox.net_ads_kerberos.*net_ads_kerberos_kinit.*
344-
samba3.blackbox.net_ads_kerberos.*net_ads_kerberos_renew.*

source3/utils/net.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,7 @@ static struct functable net_func[] = {
13941394
cli_credentials_get_principal_obtained(c->creds);
13951395
enum credentials_obtained password_obtained =
13961396
cli_credentials_get_password_obtained(c->creds);
1397+
char *krb5ccname = NULL;
13971398

13981399
if (principal_obtained == CRED_SPECIFIED) {
13991400
c->explicit_credentials = true;
@@ -1410,6 +1411,20 @@ static struct functable net_func[] = {
14101411
GENSEC_FEATURE_NTLM_CCACHE,
14111412
CRED_SPECIFIED);
14121413
}
1414+
1415+
/* cli_credentials_get_ccache_name_obtained() would not work
1416+
* here, we also cannot get the content of --use-krb5-ccache= so
1417+
* for now at least honour the KRB5CCNAME environment variable
1418+
* to get 'net ads kerberos' functions to work at all - gd */
1419+
1420+
krb5ccname = getenv("KRB5CCNAME");
1421+
if (krb5ccname == NULL) {
1422+
krb5ccname = talloc_strdup(c, "MEMORY:net");
1423+
}
1424+
if (krb5ccname == NULL) {
1425+
exit(1);
1426+
}
1427+
c->opt_krb5_ccache = krb5ccname;
14131428
}
14141429

14151430
c->msg_ctx = cmdline_messaging_context(get_dyn_CONFIGFILE());

source3/utils/net.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ struct net_context {
9797
const char *opt_witness_new_ip;
9898
int opt_witness_new_node;
9999
const char *opt_witness_forced_response;
100+
const char *opt_krb5_ccache;
100101

101102
int opt_have_ip;
102103
struct sockaddr_storage opt_dest_ip;

source3/utils/net_ads.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2998,7 +2998,7 @@ static int net_ads_kerberos_renew(struct net_context *c, int argc, const char **
29982998
return -1;
29992999
}
30003000

3001-
ret = smb_krb5_renew_ticket(NULL, NULL, NULL, NULL);
3001+
ret = smb_krb5_renew_ticket(c->opt_krb5_ccache, NULL, NULL, NULL);
30023002
if (ret) {
30033003
d_printf(_("failed to renew kerberos ticket: %s\n"),
30043004
error_message(ret));
@@ -3053,7 +3053,7 @@ static int net_ads_kerberos_pac_common(struct net_context *c, int argc, const ch
30533053
0,
30543054
NULL,
30553055
NULL,
3056-
NULL,
3056+
c->opt_krb5_ccache,
30573057
true,
30583058
true,
30593059
2592000, /* one month */
@@ -3234,7 +3234,7 @@ static int net_ads_kerberos_kinit(struct net_context *c, int argc, const char **
32343234
0,
32353235
NULL,
32363236
NULL,
3237-
NULL,
3237+
c->opt_krb5_ccache,
32383238
true,
32393239
true,
32403240
2592000, /* one month */

0 commit comments

Comments
 (0)