Skip to contentSkip to conversation

opkg_cmd: only look at conffile status if we're going to output it

PATCH New Ross Burton 1 participant 2 messages Jan 10, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 opkg_cmd: only look at conffile status if we're going to output it

The loop to compare the recorded conffile hash with their hash on disk is outputted at level INFO but the loop was executed at level NOTICE and higher.

This means that if a conffile had been deleted the status operation would produce error messages for output it isn't displaying.

---
 libopkg/opkg_cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libopkg/opkg_cmd.c +1 -1
index ba57c6a..37416fd 100644
@@ -638,7 +638,7 @@ static int opkg_info_status_cmd(int argc, char **argv, int installed_only)
 
         pkg_formatted_info(stdout, pkg);
 
-        if (opkg_config->verbosity >= NOTICE) {
+        if (opkg_config->verbosity >= INFO) {
             conffile_list_elt_t *iter;
             for (iter = nv_pair_list_first(&pkg->conffiles); iter;
                  iter = nv_pair_list_next(&pkg->conffiles, iter)) {
Signature · 1 line
2.8.1
#1 lore raw

PATCH 2/2 conffile: gracefully handle deleted conffiles in conffile_has_been_modified

Handle conffiles that don't exist gracefully so that instead of showing an error message from file_md5sum_alloc() a notice that the file has been deleted is shown instead.

---
 libopkg/conffile.c | 5 +++++
 1 file changed, 5 insertions(+)
libopkg/conffile.c +5 -0
index b2f2469..7b4b87b 100644
@@ -51,6 +51,11 @@ int conffile_has_been_modified(conffile_t * conffile)
     }
 
     root_filename = root_filename_alloc(filename);
+    if (!file_exists(root_filename)) {
+        opkg_msg(INFO, "Conffile %s deleted\n", conffile->name);
+        free(root_filename);
+        return 1;
+    }
 
     md5sum = file_md5sum_alloc(root_filename);
 
Signature · 1 line
2.8.1