230-drop_md5_support.patch 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. --- a/libopkg/conffile.c
  2. +++ b/libopkg/conffile.c
  3. @@ -36,7 +36,7 @@
  4. int conffile_has_been_modified(conffile_t *conffile)
  5. {
  6. - char *md5sum;
  7. + char *chksum;
  8. char *filename = conffile->name;
  9. char *root_filename;
  10. int ret = 1;
  11. @@ -48,16 +48,19 @@
  12. root_filename = root_filename_alloc(filename);
  13. - md5sum = file_md5sum_alloc(root_filename);
  14. -
  15. - if (md5sum && (ret = strcmp(md5sum, conffile->value))) {
  16. - opkg_msg(INFO, "Conffile %s:\n\told md5=%s\n\tnew md5=%s\n",
  17. - conffile->name, md5sum, conffile->value);
  18. +#ifdef HAVE_MD5
  19. + chksum = file_md5sum_alloc(root_filename);
  20. +#else
  21. + chksum = file_sha256sum_alloc(root_filename);
  22. +#endif
  23. + if (chksum && (ret = strcmp(chksum, conffile->value))) {
  24. + opkg_msg(INFO, "Conffile %s:\n\told chk=%s\n\tnew chk=%s\n",
  25. + conffile->name, chksum, conffile->value);
  26. }
  27. free(root_filename);
  28. - if (md5sum)
  29. - free(md5sum);
  30. + if (chksum)
  31. + free(chksum);
  32. return ret;
  33. }
  34. --- a/libopkg/file_util.c
  35. +++ b/libopkg/file_util.c
  36. @@ -26,7 +26,9 @@
  37. #include "sprintf_alloc.h"
  38. #include "file_util.h"
  39. +#ifdef HAVE_MD5
  40. #include "md5.h"
  41. +#endif
  42. #include "libbb/libbb.h"
  43. #if defined HAVE_SHA256
  44. @@ -135,6 +137,7 @@
  45. return make_directory(path, mode, FILEUTILS_RECUR);
  46. }
  47. +#ifdef HAVE_MD5
  48. char *file_md5sum_alloc(const char *file_name)
  49. {
  50. static const int md5sum_bin_len = 16;
  51. @@ -180,6 +183,7 @@
  52. return md5sum_hex;
  53. }
  54. +#endif
  55. #ifdef HAVE_SHA256
  56. char *file_sha256sum_alloc(const char *file_name)
  57. --- a/libopkg/opkg_install.c
  58. +++ b/libopkg/opkg_install.c
  59. @@ -1082,7 +1082,7 @@
  60. conffile_list_elt_t *iter;
  61. conffile_t *cf;
  62. char *cf_backup;
  63. - char *md5sum;
  64. + char *chksum;
  65. if (conf->noaction) return 0;
  66. @@ -1093,7 +1093,11 @@
  67. /* Might need to initialize the md5sum for each conffile */
  68. if (cf->value == NULL) {
  69. +#ifdef HAVE_MD5
  70. cf->value = file_md5sum_alloc(root_filename);
  71. +#else
  72. + cf->value = file_sha256sum_alloc(root_filename);
  73. +#endif
  74. }
  75. if (!file_exists(root_filename)) {
  76. @@ -1105,8 +1109,12 @@
  77. if (file_exists(cf_backup)) {
  78. /* Let's compute md5 to test if files are changed */
  79. - md5sum = file_md5sum_alloc(cf_backup);
  80. - if (md5sum && cf->value && strcmp(cf->value,md5sum) != 0 ) {
  81. +#ifdef HAVE_MD5
  82. + chksum = file_md5sum_alloc(cf_backup);
  83. +#else
  84. + chksum = file_sha256sum_alloc(cf_backup);
  85. +#endif
  86. + if (chksum && cf->value && strcmp(cf->value,chksum) != 0 ) {
  87. if (conf->force_maintainer) {
  88. opkg_msg(NOTICE, "Conffile %s using maintainer's setting.\n",
  89. cf_backup);
  90. @@ -1123,8 +1131,8 @@
  91. }
  92. }
  93. unlink(cf_backup);
  94. - if (md5sum)
  95. - free(md5sum);
  96. + if (chksum)
  97. + free(chksum);
  98. }
  99. free(cf_backup);
  100. @@ -1323,6 +1331,7 @@
  101. }
  102. #endif
  103. +#ifdef HAVE_MD5
  104. /* Check for md5 values */
  105. if (pkg->md5sum)
  106. {
  107. @@ -1346,6 +1355,7 @@
  108. if (file_md5)
  109. free(file_md5);
  110. }
  111. +#endif
  112. #ifdef HAVE_SHA256
  113. /* Check for sha256 value */
  114. --- a/libopkg/Makefile.am
  115. +++ b/libopkg/Makefile.am
  116. @@ -25,13 +25,16 @@
  117. pkg_src.c pkg_src.h pkg_src_list.c pkg_src_list.h \
  118. str_list.c str_list.h void_list.c void_list.h \
  119. active_list.c active_list.h list.h
  120. -opkg_util_sources = file_util.c file_util.h opkg_message.h opkg_message.c md5.c md5.h \
  121. +opkg_util_sources = file_util.c file_util.h opkg_message.h opkg_message.c \
  122. parse_util.c parse_util.h \
  123. sprintf_alloc.c sprintf_alloc.h \
  124. xregex.c xregex.h xsystem.c xsystem.h
  125. if HAVE_PATHFINDER
  126. opkg_util_sources += opkg_pathfinder.c opkg_pathfinder.h
  127. endif
  128. +if HAVE_MD5
  129. +opkg_util_sources += md5.c md5.h
  130. +endif
  131. if HAVE_SHA256
  132. opkg_util_sources += sha256.c sha256.h
  133. endif
  134. --- a/configure.ac
  135. +++ b/configure.ac
  136. @@ -72,6 +72,7 @@
  137. AC_DEFINE(HAVE_SHA256, 1, [Define if you want sha256 support])
  138. fi
  139. AM_CONDITIONAL(HAVE_SHA256, test "x$want_sha256" = "xyes")
  140. +AM_CONDITIONAL(HAVE_MD5, test "x$want_sha256" = "xno")
  141. # check for openssl
  142. AC_ARG_ENABLE(openssl,