aboutgitcodebugslistschat
path: root/pesto.c
diff options
context:
space:
mode:
Diffstat (limited to 'pesto.c')
-rw-r--r--pesto.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/pesto.c b/pesto.c
index eeaf274..03edc29 100644
--- a/pesto.c
+++ b/pesto.c
@@ -318,6 +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;
struct pesto_hello hello;
struct sock_fprog prog;
int optname, ret, s;
@@ -513,9 +514,33 @@ 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");
+
+ switch (status) {
+ 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);
+ }
+ }
+
noupdate:
if (shutdown(s, SHUT_RDWR) < 0 || close(s) < 0)
die_perror("Error shutting down control socket");
- exit(0);
+ exit(exit_status);
}