Skip to content

Fix to build with Heimdal Kerberos5 #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ if test "$ss" != no; then
fi
AC_CHECK_LIB(ss, ss_perror,
[SS_LIBS="-lss"
SS_OBJS='${SS_OBJS}'
AC_DEFINE(HAVE_SS, 1, [Define if we are building with the ss library])],
AS_IF([test "x$ss" != "xmaybe"], AC_MSG_ERROR(ss library not found)),
-lcom_err)
SS_OBJS='${SS_OBJS}'
fi
AC_SUBST(SS_LIBS)
AC_SUBST(SS_OBJS)
Expand Down
30 changes: 24 additions & 6 deletions lib/ZDumpSession.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ZDumpSession(char **buffer,
for (key = Z_keys_head; key != NULL; key = key->next) {
num_keys++;
len += 4 + 4; /* enctype, length */
len += key->keyblock->length; /* contents */
len += Z_keylen(key->keyblock); /* contents */
}
#endif

Expand All @@ -56,10 +56,10 @@ ZDumpSession(char **buffer,
#ifdef HAVE_KRB5
*((uint32_t *)ptr) = htonl(num_keys); ptr += 4;
for (key = Z_keys_tail; key != NULL; key = key->prev) {
*((uint32_t*) ptr) = htonl(key->keyblock->enctype); ptr += 4;
*((uint32_t*) ptr) = htonl(key->keyblock->length); ptr += 4;
memcpy(ptr, key->keyblock->contents, key->keyblock->length);
ptr += key->keyblock->length;
*((uint32_t*) ptr) = htonl(Z_enctype(key->keyblock)); ptr += 4;
*((uint32_t*) ptr) = htonl(Z_keylen(key->keyblock)); ptr += 4;
memcpy(ptr, Z_keydata(key->keyblock), Z_keylen(key->keyblock));
ptr += Z_keylen(key->keyblock);
}
#endif

Expand Down Expand Up @@ -110,12 +110,30 @@ ZLoadSession(char *buffer, int len)
free(key);
return (EINVAL);
}
#ifdef HAVE_KRB5_CREDS_KEYBLOCK_ENCTYPE
ret = krb5_init_keyblock(Z_krb5_ctx, enctype, keylength, &key->keyblock);
#else
{
krb5_keyblock *tmp, tmp_ss;
tmp = &tmp_ss;

key->keyblock = NULL;
Z_enctype(tmp) = enctype;
Z_keylen(tmp) = keylength;
Z_keydata(tmp) = malloc(keylength);
if (!Z_keydata(tmp)) {
ret = ENOMEM;
} else {
ret = krb5_copy_keyblock(Z_krb5_ctx, tmp, &key->keyblock);
free(Z_keydata(tmp));
}
}
#endif
if (ret) {
free(key);
return ret;
}
memcpy((char *)key->keyblock->contents, buffer, keylength);
memcpy((char *)Z_keydata(key->keyblock), buffer, keylength);
buffer += keylength; len -= keylength;
/* Just set recent times. It means we might not be able to
retire the keys, but that's fine. */
Expand Down
4 changes: 4 additions & 0 deletions lib/ZGetSender.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ ZGetSender(void)
if (!result) {
krb5_unparse_name(Z_krb5_ctx, principal, &prname);
sender = strdup(prname);
#ifdef HAVE_KRB5_UNPARSE_NAME
krb5_free_unparsed_name(Z_krb5_ctx, prname);
#else
free(prname);
#endif
krb5_free_principal(Z_krb5_ctx, principal);
return sender;
}
Expand Down
8 changes: 4 additions & 4 deletions lib/ZMkAuth.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ Z_MakeAuthenticationSaveKey(register ZNotice_t *notice,
keyblock = Z_credskey(creds);

if (Z_keys_head &&
Z_keys_head->keyblock->enctype == keyblock->enctype &&
Z_keys_head->keyblock->length == keyblock->length &&
memcmp(Z_keys_head->keyblock->contents, keyblock->contents,
keyblock->length) == 0) {
Z_enctype(Z_keys_head->keyblock) == Z_enctype(keyblock) &&
Z_keylen(Z_keys_head->keyblock) == Z_keylen(keyblock) &&
memcmp(Z_keydata(Z_keys_head->keyblock), Z_keydata(keyblock),
Z_keylen(keyblock)) == 0) {
/*
* Optimization: if the key hasn't changed, replace the current entry,
* rather than make a new one.
Expand Down