1 --- a/libopkg/conffile.c
2 +++ b/libopkg/conffile.c
3 @@ -36,7 +36,7 @@ void conffile_deinit(conffile_t *conffil
5 int conffile_has_been_modified(conffile_t *conffile)
9 char *filename = conffile->name;
12 @@ -48,16 +48,23 @@ int conffile_has_been_modified(conffile_
14 root_filename = root_filename_alloc(filename);
16 - md5sum = file_md5sum_alloc(root_filename);
18 - if (md5sum && (ret = strcmp(md5sum, conffile->value))) {
19 - opkg_msg(INFO, "Conffile %s:\n\told md5=%s\n\tnew md5=%s\n",
20 - conffile->name, md5sum, conffile->value);
22 + if(conffile->value && strlen(conffile->value) > 33) {
23 + chksum = file_sha256sum_alloc(root_filename);
25 + chksum = file_md5sum_alloc(root_filename);
28 + chksum = file_sha256sum_alloc(root_filename);
30 + if (chksum && (ret = strcmp(chksum, conffile->value))) {
31 + opkg_msg(INFO, "Conffile %s:\n\told chk=%s\n\tnew chk=%s\n",
32 + conffile->name, chksum, conffile->value);
43 --- a/libopkg/file_util.c
44 +++ b/libopkg/file_util.c
47 #include "sprintf_alloc.h"
48 #include "file_util.h"
52 #include "libbb/libbb.h"
54 #if defined HAVE_SHA256
55 @@ -135,6 +137,7 @@ file_mkdir_hier(const char *path, long m
56 return make_directory(path, mode, FILEUTILS_RECUR);
60 char *file_md5sum_alloc(const char *file_name)
62 static const int md5sum_bin_len = 16;
63 @@ -180,6 +183,7 @@ char *file_md5sum_alloc(const char *file
70 char *file_sha256sum_alloc(const char *file_name)
71 --- a/libopkg/opkg_install.c
72 +++ b/libopkg/opkg_install.c
73 @@ -1082,7 +1082,7 @@ resolve_conffiles(pkg_t *pkg)
74 conffile_list_elt_t *iter;
80 if (conf->noaction) return 0;
82 @@ -1093,7 +1093,7 @@ resolve_conffiles(pkg_t *pkg)
84 /* Might need to initialize the md5sum for each conffile */
85 if (cf->value == NULL) {
86 - cf->value = file_md5sum_alloc(root_filename);
87 + cf->value = file_sha256sum_alloc(root_filename);
90 if (!file_exists(root_filename)) {
91 @@ -1105,8 +1105,16 @@ resolve_conffiles(pkg_t *pkg)
93 if (file_exists(cf_backup)) {
94 /* Let's compute md5 to test if files are changed */
95 - md5sum = file_md5sum_alloc(cf_backup);
96 - if (md5sum && cf->value && strcmp(cf->value,md5sum) != 0 ) {
98 + if(cf->value && strlen(cf->value) > 33) {
99 + chksum = file_sha256sum_alloc(cf_backup);
101 + chksum = file_md5sum_alloc(cf_backup);
104 + chksum = file_sha256sum_alloc(cf_backup);
106 + if (chksum && cf->value && strcmp(cf->value,chksum) != 0 ) {
107 if (conf->force_maintainer) {
108 opkg_msg(NOTICE, "Conffile %s using maintainer's setting.\n",
110 @@ -1123,8 +1131,8 @@ resolve_conffiles(pkg_t *pkg)
121 @@ -1323,6 +1331,7 @@ opkg_install_pkg(pkg_t *pkg, int from_up
126 /* Check for md5 values */
129 @@ -1346,6 +1355,7 @@ opkg_install_pkg(pkg_t *pkg, int from_up
136 /* Check for sha256 value */
137 --- a/libopkg/Makefile.am
138 +++ b/libopkg/Makefile.am
139 @@ -25,13 +25,16 @@ opkg_list_sources = conffile.c conffile.
140 pkg_src.c pkg_src.h pkg_src_list.c pkg_src_list.h \
141 str_list.c str_list.h void_list.c void_list.h \
142 active_list.c active_list.h list.h
143 -opkg_util_sources = file_util.c file_util.h opkg_message.h opkg_message.c md5.c md5.h \
144 +opkg_util_sources = file_util.c file_util.h opkg_message.h opkg_message.c \
145 parse_util.c parse_util.h \
146 sprintf_alloc.c sprintf_alloc.h \
147 xregex.c xregex.h xsystem.c xsystem.h
149 opkg_util_sources += opkg_pathfinder.c opkg_pathfinder.h
152 +opkg_util_sources += md5.c md5.h
155 opkg_util_sources += sha256.c sha256.h
159 @@ -68,10 +68,19 @@ AC_ARG_ENABLE(sha256,
160 (sha256.{c,h} are GPLv3 licensed) [[default=no]] ]),
161 [want_sha256="$enableval"], [want_sha256="no"])
164 + AC_HELP_STRING([--enable-md5], [Enable md5sum check
165 + (md5.{c,h} are GPLv3 licensed) [[default=no]] ]),
166 + [want_md5="$enableval"], [want_md5="yes"])
168 if test "x$want_sha256" = "xyes"; then
169 AC_DEFINE(HAVE_SHA256, 1, [Define if you want sha256 support])
171 +if test "x$want_md5" = "xyes"; then
172 + AC_DEFINE(HAVE_MD5, 1, [Define if you want md5 support])
174 AM_CONDITIONAL(HAVE_SHA256, test "x$want_sha256" = "xyes")
175 +AM_CONDITIONAL(HAVE_MD5, test "x$want_md5" = "xyes")
178 AC_ARG_ENABLE(openssl,
179 --- a/libopkg/pkg_parse.c
180 +++ b/libopkg/pkg_parse.c
181 @@ -49,9 +49,9 @@ parse_status(pkg_t *pkg, const char *sst
183 parse_conffiles(pkg_t *pkg, const char *cstr)
185 - char file_name[1024], md5sum[35];
186 + char file_name[1024], md5sum[85];
188 - if (sscanf(cstr, "%1023s %34s", file_name, md5sum) != 2) {
189 + if (sscanf(cstr, "%1023s %84s", file_name, md5sum) != 2) {
190 opkg_msg(ERROR, "Failed to parse Conffiles line for %s\n",