-/* $Cambridge: exim/src/src/dk.c,v 1.3 2005/06/20 11:20:41 ph10 Exp $ */
+/* $Cambridge: exim/src/src/dk.c,v 1.9 2006/02/07 11:19:00 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2005 */
+/* Copyright (c) University of Cambridge 1995 - 2006 */
/* See the file NOTICE for conditions of use and distribution. */
/* Code for DomainKeys support. Other DK relevant code is in
dk_internal_status = dk_message(dk_context, CUS &dkbuff[i], 1);
/* Flag end-of-message. */
- dk_internal_status = dk_end(dk_context, NULL);
+ dk_internal_status = dk_end(dk_context, &dk_flags);
+
+ /* dk_flags now has the selector flags (if there was one).
+ It seems that currently only the "t=" flag is supported
+ in selectors. */
+ if (dk_flags & DK_FLAG_SET)
+ if (dk_flags & DK_FLAG_TESTING)
+ dk_verify_block->testing = TRUE;
/* Grab address/domain information. */
p = dk_address(dk_context);
dk_verify_block->domain = string_copy((uschar *)(q+1));
*q = '\0';
dk_verify_block->local_part = string_copy((uschar *)p);
+ *q = '@';
}
}
}
+ /* Now grab the domain-wide DK policy */
dk_flags = dk_policy(dk_context);
- /* Grab domain policy */
if (dk_flags & DK_FLAG_SET) {
- if (dk_flags & DK_FLAG_TESTING)
+ /* Selector "t=" flag has precedence, don't overwrite it if
+ the selector has set it above. */
+ if ((dk_flags & DK_FLAG_TESTING) && !dk_verify_block->testing)
dk_verify_block->testing = TRUE;
if (dk_flags & DK_FLAG_SIGNSALL)
dk_verify_block->signsall = TRUE;
dk_verify_block->result_string = string_copy((uschar *)DK_STAT_to_string(dk_internal_status));
/* All done, reset dk_context. */
- dk_free(dk_context);
+ dk_free(dk_context,1);
dk_context = NULL;
store_pool = old_pool;
/* Looks like a filename, load the private key. */
memset(big_buffer,0,big_buffer_size);
privkey_fd = open(CS dk_private_key,O_RDONLY);
- read(privkey_fd,big_buffer,16383);
- close(privkey_fd);
+ (void)read(privkey_fd,big_buffer,16383);
+ (void)close(privkey_fd);
dk_private_key = big_buffer;
}
rc = store_get(1024);
/* Build DomainKey-Signature header to return. */
- snprintf(CS rc, 1024, "DomainKey-Signature: a=rsa-sha1; q=dns; c=%s;\r\n"
+ (void)string_format(rc, 1024, "DomainKey-Signature: a=rsa-sha1; q=dns; c=%s;\r\n"
"\ts=%s; d=%s;\r\n"
"\tb=%s;\r\n", dk_canon, dk_selector, dk_domain, sig);
CLEANUP:
if (dk_context != NULL) {
- dk_free(dk_context);
+ dk_free(dk_context,1);
dk_context = NULL;
}
store_pool = old_pool;