File libdkim-verifyopts.patch of Package dkim

diff -rU3 libdkim/src/libdkimtest.cpp libdkim.nosub/src/libdkimtest.cpp
--- libdkim/src/libdkimtest.cpp	2011-06-14 16:53:50.000000000 +0200
+++ libdkim.nosub/src/libdkimtest.cpp	2011-06-14 16:51:28.000000000 +0200
@@ -58,7 +58,7 @@
 void usage()
 {
 
-	printf( "usage: libdkimtest [-b<allman|ietf|both>] [-c<r|s|t|u>] [-d<domain>] [-l] [-h] [-i<you@yourdomain.com>] [-q] [-s] [-t] [-v] [-x<expire time>] [-z<hash>] <msgfile> <privkeyfile> <outfile>\n");
+	printf( "usage: libdkimtest [-b<allman|ietf|both>] [-c<r|s|t|u>] [-d<domain>] [-l] [-h] [-i<you@yourdomain.com>] [-q] [-s] [-t] [-v [-V:<length|adsp|subject|from> ...]] [-x<expire time>] [-z<hash>] <msgfile> <privkeyfile> <outfile>\n");
 	printf( "-b<standard> allman , ietf or both\n");
 	printf( "-c<canonicalization> r for relaxed [DEFAULT], s - simple, t relaxed/simple, u - simple/relaxed\n");
 	printf( "-d<domain> the domain tag, if not provided it will be determined from the sender/from header\n");
@@ -68,6 +68,10 @@
 	printf( "-s sign the message\n");
 	printf( "-t include a timestamp tag\n");
 	printf( "-v verify the message\n");
+	printf( "-V:length  verify with body length (default: ignore body length)\n");
+	printf( "-V:adsp    verify using sender signing practices (default: use unknown practices))\n");
+	printf( "-V:subject require signed subject header (default: don't require it))\n");
+	printf( "-V:from    forbid unsigned from headers (default: allow them))\n");
 	printf( "-x<expire_time> the expire time in seconds since epoch ( DEFAULT = current time + 604800)\n\t if set to - then it will not be included");
 	printf( "-z<hash>  1 for sha1, 2 for sha256, 3 for both\n");
 	printf( "-y<selector> the selector tag DEFAULT=MDaemon\n");
@@ -86,6 +90,7 @@
 	time_t t;
 	DKIMContext ctxt;
 	DKIMSignOptions opts = {0};
+	DKIMVerifyOptions vopts = {0};
 
 	opts.nHash = DKIM_HASH_SHA1_AND_256;
 
@@ -176,6 +181,25 @@
 
 			case 'v':		// verify
 				bSign = false;
+				vopts.nSubjectRequired = 1;
+				vopts.nAllowUnsignedFromHeaders = 1;
+				break;
+
+			case 'V':		// verify options
+				if (argv[n][2] == ':') { switch (argv[n][3]) {
+				case 'l':
+					vopts.nHonorBodyLengthTag = 1;
+					break;
+				case 'a':
+					vopts.nCheckPractices = 1;
+					break;
+				case 's':
+					vopts.nSubjectRequired = 0;
+					break;
+				case 'f':
+					vopts.nAllowUnsignedFromHeaders = 0;
+					break;
+				}}
 				break;
 
 			case 'x':		// expire time 
@@ -297,7 +321,12 @@
 	{
 		FILE* in = fopen( MsgFile, "rb" );
 
-		DKIMVerifyOptions vopts = {0};
+		if ( in == NULL ) 
+		{ 
+			printf( "%s: can't open msg file %s\n", argv[0], MsgFile );
+			exit(1);
+		}
+
 		vopts.pfnSelectorCallback = NULL; //SelectorCallback;
 
 		n = DKIMVerifyInit( &ctxt, &vopts );
openSUSE Build Service is sponsored by