OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
3.6 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../libdkim/extra-options.patch
  5. # Copyright (C) 2009 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. This patch was taken from
  17. http://patchlog.com/security/qmail-and-dkim/
  18. It adds usage text and a few extra options to the libdkimtest program that
  19. comes with Alt-N's libdkim library.
  20. Installation instructions:
  21. % wget http://downloads.sourceforge.net/libdkim/libdkim-1.0.19.zip
  22. % wget http://www.bltweb.net/qmail/libdkim-1.0.19-extra-options.patch
  23. % unzip libdkim-1.0.19
  24. % cd libdkim/src
  25. % patch -p2 < ../../libdkim-1.0.19-extra-options.patch
  26. diff -Naur libdkim.orig/src/libdkimtest.cpp libdkim/src/libdkimtest.cpp
  27. --- ./libdkimtest.cpp 2009-03-13 16:17:45.000000000 -0500
  28. +++ ./libdkimtest.cpp 2009-03-13 16:26:02.000000000 -0500
  29. @@ -55,8 +55,23 @@
  30. return 0;
  31. }
  32. +void usage()
  33. +{
  34. -
  35. + 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");
  36. + printf( "-b<standard> allman , ietf or both\n");
  37. + printf( "-c<canonicalization> r for relaxed [DEFAULT], s - simple, t relaxed/simple, u - simple/relaxed\n");
  38. + printf( "-d<domain> the domain tag, if not provided it will be determined from the sender/from header\n");
  39. + printf( "-l include body length tag\n");
  40. + printf( "-h this help\n");
  41. + printf( "-i<identity> the identity, if not provided it will not be included\n");
  42. + printf( "-s sign the message\n");
  43. + printf( "-t include a timestamp tag\n");
  44. + printf( "-v verify the message\n");
  45. + 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");
  46. + printf( "-z<hash> 1 for sha1, 2 for sha256, 3 for both\n");
  47. + printf( "-y<selector> the selector tag DEFAULT=MDaemon\n");
  48. +}
  49. int main(int argc, char* argv[])
  50. {
  51. int n;
  52. @@ -77,7 +92,7 @@
  53. time(&t);
  54. opts.nCanon = DKIM_SIGN_RELAXED;
  55. - opts.nIncludeBodyLengthTag = 1;
  56. + opts.nIncludeBodyLengthTag = 0;
  57. opts.nIncludeQueryMethod = 0;
  58. opts.nIncludeTimeStamp = 0;
  59. opts.expireTime = t + 604800; // expires in 1 week
  60. @@ -92,6 +107,11 @@
  61. int nArgParseState = 0;
  62. bool bSign = true;
  63. + if(argc<2){
  64. + usage();
  65. + exit(1);
  66. + }
  67. +
  68. for( n = 1; n < argc; n++ )
  69. {
  70. if( argv[n][0] == '-' && strlen(argv[n]) > 1 )
  71. @@ -121,14 +141,16 @@
  72. }
  73. break;
  74. -
  75. + case 'd':
  76. + strncpy(opts.szDomain,(const char*)(argv[n]+2),sizeof(opts.szDomain)-1);
  77. + break;
  78. case 'l': // body length tag
  79. opts.nIncludeBodyLengthTag = 1;
  80. break;
  81. case 'h':
  82. - printf( "usage: \n" );
  83. + usage();
  84. return 0;
  85. case 'i': // identity
  86. @@ -138,7 +160,7 @@
  87. }
  88. else
  89. {
  90. - strcpy( opts.szIdentity, argv[n] + 2 );
  91. + strncpy( opts.szIdentity, argv[n] + 2,sizeof(opts.szIdentity)-1 );
  92. }
  93. break;
  94. @@ -169,6 +191,9 @@
  95. }
  96. break;
  97. + case 'y':
  98. + strncpy( opts.szSelector, argv[n]+2, sizeof(opts.szSelector)-1);
  99. + break;
  100. case 'z': // sign w/ sha1, sha256 or both
  101. opts.nHash = atoi( &argv[n][2] );