aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorHayato Kiwata <dev@haytok.jp>2026-11-25 22:38:07 +0900
committerStefano Brivio <sbrivio@redhat.com>2026-11-27 02:12:46 +0100
commit6af105391cea3c6501ede02ffe937af26b544ba8 (patch)
treee585db178bce54ba7853fc9ae29850bd6c7c35c2
parent0b9abe75043cfed0d92b14e4f34e42ade9ee4221 (diff)
downloadpasst-6af105391cea3c6501ede02ffe937af26b544ba8.tar
passt-6af105391cea3c6501ede02ffe937af26b544ba8.tar.gz
passt-6af105391cea3c6501ede02ffe937af26b544ba8.tar.bz2
passt-6af105391cea3c6501ede02ffe937af26b544ba8.tar.lz
passt-6af105391cea3c6501ede02ffe937af26b544ba8.tar.xz
passt-6af105391cea3c6501ede02ffe937af26b544ba8.tar.zst
passt-6af105391cea3c6501ede02ffe937af26b544ba8.zip
pesto: Drop exit_status, use status to select the exit code
Commit 885c39e8b999 ("conf, pesto: Notify client of the result of rule updates") added an exit_status variable to exit with a non-zero status if the server reports a failure. However, the status read from the server already tells us whether the update failed. Drop exit_status, broaden the scope of status, and select the exit code from it when we call exit(). Initialize status to PESTO_STATUS_OK, since it is not read from the server when pesto only shows the current rules or the server uses a protocol version older than 3. Link: https://archives.passt.top/passt-dev/20261120235844.75da1afa@elisabeth/ Suggested-by: Stefano Brivio <sbrivio@redhat.com> Signed-off-by: Hayato Kiwata <dev@haytok.jp> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--pesto.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/pesto.c b/pesto.c
index 03edc29..fe5a536 100644
--- a/pesto.c
+++ b/pesto.c
@@ -318,7 +318,7 @@ int main(int argc, char **argv)
struct sockaddr_un a = { AF_UNIX, "" };
struct configuration conf = { 0 };
bool update = false, show = false;
- int exit_status = EXIT_SUCCESS;
+ uint8_t status = PESTO_STATUS_OK;
struct pesto_hello hello;
struct sock_fprog prog;
int optname, ret, s;
@@ -515,8 +515,6 @@ int main(int argc, char **argv)
send_conf(s, &conf);
if (s_version >= PESTO_VERSION_STATUS) {
- uint8_t status;
-
if (read_u8(s, &status) < 0)
die_perror("Couldn't read configuration status");
@@ -524,16 +522,13 @@ int main(int argc, char **argv)
case PESTO_STATUS_OK:
break;
case PESTO_STATUS_ROLLBACK:
- exit_status = EXIT_FAILURE;
warn("Failed to apply new rules, old rules restored");
break;
case PESTO_STATUS_FAILED:
- exit_status = EXIT_FAILURE;
warn(
"Failed to apply new rules, couldn't restore old ones");
break;
default:
- exit_status = EXIT_FAILURE;
warn("Unknown configuration status %"PRIu8, status);
}
}
@@ -542,5 +537,5 @@ noupdate:
if (shutdown(s, SHUT_RDWR) < 0 || close(s) < 0)
die_perror("Error shutting down control socket");
- exit(exit_status);
+ exit(status == PESTO_STATUS_OK ? EXIT_SUCCESS : EXIT_FAILURE);
}