Skip to content

Commit

Permalink
Auth notifications for unknown peers
Browse files Browse the repository at this point in the history
  • Loading branch information
leninalive committed Sep 6, 2024
1 parent be6a26e commit 1472cc8
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions contrib/peer-approver/notification-listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
static struct nl_sock *sk = NULL;
static char **cb_argv;
static int cb_argc;
static bool running_cb = false;
//static bool running_cb = false;

static int cleanup_and_exit(int ret)
{
Expand All @@ -33,7 +33,7 @@ static int cleanup_and_exit(int ret)

static void signal_handler(int sig)
{
if (!running_cb)
//if (!running_cb)
cleanup_and_exit(EXIT_SUCCESS);
}

Expand Down Expand Up @@ -130,9 +130,20 @@ static int run_callback(char *ifname, char *pubkey, char *endpoint_ip, bool adva
new_argv[cb_argc - 1] = (advanced_security ? "on\0" : "off\0");
new_argv[cb_argc] = NULL;

running_cb = true;
int ret = execv(cb_argv[1], new_argv);
running_cb = false;
//running_cb = true;

int child_pid = fork(), ret;
if (child_pid < 0) {
prerr("failed to spawn child process: %d\n", child_pid);
return child_pid;
} else if (child_pid == 0) {
execv(cb_argv[1], new_argv);
exit(0);
} else {
waitpid(child_pid, &ret, 0);
}

//running_cb = false;

free(new_argv);
return ret;
Expand Down

0 comments on commit 1472cc8

Please sign in to comment.