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