From 98719797074637cecdff6a0cdb782a1e807a13e9 Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Sun, 20 Aug 2023 00:07:51 +0200 Subject: [PATCH] vnstat2: update to version 2.11 This release breaks the noexit patch, because the code for removing old now returns an error when no interfaces are configured. As it is run on startup, the daemon exits in this case. To avoid this, add an additional check so an error is only returned in an actual error case. Signed-off-by: Jan Hoffmann --- net/vnstat2/Makefile | 4 ++-- net/vnstat2/patches/100-noexit.patch | 34 ++++++++++++++++++++++++---- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/net/vnstat2/Makefile b/net/vnstat2/Makefile index 290cc3273..3968a718b 100644 --- a/net/vnstat2/Makefile +++ b/net/vnstat2/Makefile @@ -6,12 +6,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=vnstat2 -PKG_VERSION:=2.10 +PKG_VERSION:=2.11 PKG_RELEASE:=1 PKG_SOURCE:=vnstat-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://humdi.net/vnstat -PKG_HASH:=a9c61744e5cd8c366e2db4d282badc74021ddb614bd65b41240937997e457d25 +PKG_HASH:=babc3f1583cc40e4e8ffb2f53296d93d308cb5a5043e85054f6eaf7b4ae57856 PKG_LICENSE:=GPL-2.0-only PKG_LICENSE_FILES:=COPYING diff --git a/net/vnstat2/patches/100-noexit.patch b/net/vnstat2/patches/100-noexit.patch index b952818fc..9940e814f 100644 --- a/net/vnstat2/patches/100-noexit.patch +++ b/net/vnstat2/patches/100-noexit.patch @@ -1,6 +1,6 @@ --- a/src/daemon.c +++ b/src/daemon.c -@@ -252,6 +252,7 @@ void initdstate(DSTATE *s) +@@ -277,6 +277,7 @@ void initdstate(DSTATE *s) s->sync = 0; s->forcesave = 0; s->noadd = 0; @@ -8,7 +8,7 @@ s->initdb = 0; s->iflisthash = 0; s->cfgfile[0] = '\0'; -@@ -285,6 +286,9 @@ void preparedatabase(DSTATE *s) +@@ -310,6 +311,9 @@ void preparedatabase(DSTATE *s) } if (s->noadd) { @@ -18,7 +18,7 @@ printf("No interfaces found in database, exiting.\n"); exit(EXIT_FAILURE); } -@@ -303,6 +307,9 @@ void preparedatabase(DSTATE *s) +@@ -328,6 +332,9 @@ void preparedatabase(DSTATE *s) } if (!addinterfaces(s) && s->dbifcount == 0) { @@ -41,7 +41,7 @@ uint64_t dbifcount; --- a/src/vnstatd.c +++ b/src/vnstatd.c -@@ -249,6 +249,7 @@ void showhelp(void) +@@ -259,6 +259,7 @@ void showhelp(void) printf(" --config select used config file\n"); printf(" --noadd prevent startup if database has no interfaces\n"); printf(" --alwaysadd [mode] automatically start monitoring all new interfaces\n"); @@ -49,7 +49,7 @@ printf(" --initdb create empty database and exit\n\n"); printf("See also \"man vnstatd\".\n"); -@@ -322,6 +323,8 @@ void parseargs(DSTATE *s, int argc, char +@@ -332,6 +333,8 @@ void parseargs(DSTATE *s, int argc, char } else { cfg.alwaysadd = 1; } @@ -58,3 +58,27 @@ } else if (strcmp(argv[currentarg], "--initdb") == 0) { s->initdb = 1; s->showhelp = 0; +--- a/src/dbsql.c ++++ b/src/dbsql.c +@@ -976,7 +976,7 @@ int db_insertdata(const char *table, con + + int db_removeoldentries(void) + { +- int rc, i; ++ int rc, i, dbifcount; + char sql[256]; + const char *datatables[] = {"fiveminute", "hour", "day", "month", "year"}; + const int32_t entrylimits[] = {cfg.fiveminutehours * 12, cfg.hourlydays * 24, cfg.dailydays, cfg.monthlymonths, cfg.yearlyyears}; +@@ -987,8 +987,11 @@ int db_removeoldentries(void) + printf("db: removing old entries\n"); + } + +- if (db_getiflist(&dbifl) <= 0) { ++ dbifcount = db_getiflist(&dbifl); ++ if (dbifcount < 0) { + return 0; ++ } else if (dbifcount == 0) { ++ return 1; + } else { + dbifl_i = dbifl; + }