From d823a59cd64acad4afcf2d5e21a2e8c95546cc95 Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Tue, 30 Oct 2007 14:58:03 -0700 Subject: add configuration change notification. --- Makefile.am | 1 + scripts/vyatta-cfg-notify | 22 ++++++++++++++++++++++ src/cli_new.c | 2 +- src/commit.c | 3 +++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100755 scripts/vyatta-cfg-notify diff --git a/Makefile.am b/Makefile.am index 3129eb7..5d43423 100644 --- a/Makefile.am +++ b/Makefile.am @@ -33,6 +33,7 @@ sbin_SCRIPTS += scripts/vyatta-cli-expand-var.pl sbin_SCRIPTS += scripts/vyatta-output-config.pl sbin_SCRIPTS += scripts/vyatta-save-config.pl sbin_SCRIPTS += scripts/vyatta-load-config.pl +sbin_SCRIPTS += scripts/vyatta-cfg-notify share_perl5_DATA = scripts/VyattaConfig.pm share_perl5_DATA += scripts/VyattaConfigDOMTree.pm diff --git a/scripts/vyatta-cfg-notify b/scripts/vyatta-cfg-notify new file mode 100755 index 0000000..82dc6a3 --- /dev/null +++ b/scripts/vyatta-cfg-notify @@ -0,0 +1,22 @@ +#!/bin/bash + +declare cur_tty=$(ps -o tty= |head -n1) +declare cur_uid=($(ps -o ruser= n |head -n1)) +declare cur_user=$(grep "[^:]\+:[^:]*:${cur_uid[0]}:" /etc/passwd \ + | cut -d ':' -f 1) +declare -a ulist=( $(ps -a -o args,tty,ruser n \ + | grep '^newgrp quaggavty' | cut -c 29-) ) + +for (( i = 0; i < ${#ulist[@]}; i += 2 )); do + utty=${ulist[i]} + if [ "$utty" == "$cur_tty" ]; then + continue + fi + user=$(grep "[^:]\+:[^:]*:${ulist[i+1]}:" /etc/passwd | cut -d ':' -f 1) + sudo write $user $utty <ptrs[i])); } -#define LOCK_FILE "/var/lock/vyatta_cfg_lock" +#define LOCK_FILE "/opt/vyatta/config/.lock" static void release_config_lock() diff --git a/src/commit.c b/src/commit.c index 9aafedd..0d029f0 100644 --- a/src/commit.c +++ b/src/commit.c @@ -1360,6 +1360,9 @@ static int fin_commit(boolean ok) system(command); my_free(command); + /* notify other users in config mode */ + system("/opt/vyatta/sbin/vyatta-cfg-notify"); + return 0; } -- cgit v1.2.3