Destroy security config on shutdown

This commit is contained in:
emersion 2018-11-08 12:01:22 +01:00
parent 50d84b8512
commit 6b200ca7e3
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
3 changed files with 15 additions and 0 deletions

View file

@ -6,6 +6,7 @@
#include "sway/config.h"
bool load_security(struct wl_display *display);
void finish_security(void);
bool check_security_rule(const char *cmd, const char *global);
struct command_policy *alloc_command_policy(const char *command);

View file

@ -422,6 +422,8 @@ int main(int argc, char **argv) {
root_destroy(root);
root = NULL;
finish_security();
if (config) {
free_config(config);
}

View file

@ -123,6 +123,18 @@ bool load_security(struct wl_display *display) {
return true;
}
void finish_security(void) {
struct sway_security_rule *rule, *tmp;
wl_list_for_each_safe(rule, tmp, &rules, link) {
free(rule->command);
free(rule->global);
wl_list_remove(&rule->link);
free(rule);
}
wl_list_remove(&rules);
}
bool check_security_rule(const char *cmd, const char *global) {
struct sway_security_rule *rule;
wl_list_for_each(rule, &rules, link) {