summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am1
-rwxr-xr-xscripts/vyatta-cfg-notify22
-rw-r--r--src/cli_new.c2
-rw-r--r--src/commit.c3
4 files changed, 27 insertions, 1 deletions
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 <<EOF
+Active configuration has been changed by user '$cur_user' on '$cur_tty'.
+Please make sure you do not have conflicting changes. You can also discard
+the current changes by issuing 'exit discard'.
+EOF
+done
+
diff --git a/src/cli_new.c b/src/cli_new.c
index 52a03d3..07f0697 100644
--- a/src/cli_new.c
+++ b/src/cli_new.c
@@ -215,7 +215,7 @@ void di(vtw_sorted *srtp)
printf("%u %u\n", i, *(unsigned int *)(srtp->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;
}