summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralex <alex@builder.localdomain>2007-12-11 15:12:41 -0800
committeralex <alex@builder.localdomain>2007-12-11 15:12:41 -0800
commit42aff76b3686beb463a77f3dabd4c5beed961120 (patch)
treee61062b2c0b55d3841083c38110603f1c398bd06
parentfb9450551d5757a45806a062d7457a761e6dd295 (diff)
parent832dbf144bc019ec524e4163b716dd823ee26900 (diff)
downloadvyatta-cfg-42aff76b3686beb463a77f3dabd4c5beed961120.tar.gz
vyatta-cfg-42aff76b3686beb463a77f3dabd4c5beed961120.zip
Merge branch 'master' of http://phuket.vyatta.com/vyatta-cfg
-rw-r--r--Makefile.am6
-rw-r--r--debian/control1
-rw-r--r--debian/vyatta-cfg.postinst.in4
-rw-r--r--etc/bash_completion.d/20vyatta-cfg19
-rw-r--r--etc/default/vyatta-cfg40
-rw-r--r--etc/shell/level/admin/restricted-mode1
-rw-r--r--etc/shell/level/users/allowed-cfg0
-rw-r--r--etc/shell/level/users/allowed-op3
-rw-r--r--etc/shell/level/users/allowed-pipe10
-rw-r--r--etc/shell/level/users/restricted-mode1
-rwxr-xr-xscripts/vyatta-output-config.pl7
-rw-r--r--src/cli_new.c5
-rw-r--r--src/commit.c2
13 files changed, 91 insertions, 8 deletions
diff --git a/Makefile.am b/Makefile.am
index c757ac1..733526f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,6 +2,8 @@ cfgdir = $(datadir)/vyatta-cfg/templates
share_perl5dir = /opt/vyatta/share/perl5
completiondir = /etc/bash_completion.d
initddir = /etc/init.d
+defaultdir = /etc/default
+etc_shell_leveldir = $(sysconfdir)/shell/level
AM_CFLAGS = -I src -Wall
AM_YFLAGS = -d --name-prefix=yy_`basename $* .y`_
@@ -43,9 +45,13 @@ share_perl5_DATA += scripts/VyattaConfigLoad.pm
share_perl5_DATA += scripts/VyattaMisc.pm
share_perl5_DATA += scripts/VyattaTypeChecker.pm
+default_DATA = etc/default/vyatta-cfg
+
cpiop = find . ! -regex '\(.*~\|.*\.bak\|.*\.swp\|.*\#.*\#\)' -print0 | \
cpio -0pd
install-exec-hook:
mkdir -p $(DESTDIR)$(cfgdir)
cd templates; $(cpiop) $(DESTDIR)$(cfgdir)
+ mkdir -p $(DESTDIR)$(etc_shell_leveldir)
+ cd etc/shell/level; $(cpiop) $(DESTDIR)$(etc_shell_leveldir)
diff --git a/debian/control b/debian/control
index 10e1156..0ebf92d 100644
--- a/debian/control
+++ b/debian/control
@@ -13,6 +13,7 @@ Depends: bash (>= 3.1),
procps (>= 1:3.2.7-3),
quagga,
coreutils (>= 5.97-5.3),
+ vyatta-op,
vyatta-config-migrate,
dhcp3-client
Suggests: util-linux (>= 2.13-5),
diff --git a/debian/vyatta-cfg.postinst.in b/debian/vyatta-cfg.postinst.in
index 4690c18..80ddb8c 100644
--- a/debian/vyatta-cfg.postinst.in
+++ b/debian/vyatta-cfg.postinst.in
@@ -14,3 +14,7 @@ if [ "$sysconfdir" != "/etc" ]; then
touch /etc/$conf
done
fi
+
+# add group for configure
+addgroup --system vyattacfg
+
diff --git a/etc/bash_completion.d/20vyatta-cfg b/etc/bash_completion.d/20vyatta-cfg
index fe64f40..dc05cf1 100644
--- a/etc/bash_completion.d/20vyatta-cfg
+++ b/etc/bash_completion.d/20vyatta-cfg
@@ -54,8 +54,9 @@ show ()
args[${#args[@]}]="$arg"
fi
done
- eval "${vyatta_sbindir}/vyatta-output-config.pl ${show_all}\
- \${VYATTA_EDIT_LEVEL//\// } ${args[@]}"
+ ${vyatta_sbindir}/vyatta-output-config.pl ${show_all} \
+ ${VYATTA_EDIT_LEVEL//\// } ${args[@]} \
+ | eval "${VYATTA_PAGER:-cat}"
}
save ()
@@ -705,6 +706,20 @@ vyatta_config_complete ()
end_space=1
(( num_comp -= 1 ))
fi
+
+ # handle pipe
+ if [ "${COMP_WORDS[$num_comp]}" == "|" ]; then
+ declare -a hitems=( "more" \
+ )
+ declare -a hstrs=( \
+ "Paginate the output" \
+ )
+ generate_help_text hitems hstrs
+ vyatta_completions=( "${hitems[@]}" )
+ vyatta_do_complete
+ return
+ fi
+
(( last_idx = num_comp - 1 ))
comp_words=( ${COMP_WORDS[@]:1:$num_comp} )
diff --git a/etc/default/vyatta-cfg b/etc/default/vyatta-cfg
new file mode 100644
index 0000000..d369e0f
--- /dev/null
+++ b/etc/default/vyatta-cfg
@@ -0,0 +1,40 @@
+# Vyatta shell environment variables for config mode
+# should be sourced from /etc/default/vyatta
+
+export VYATTA_ACTIVE_CONFIGURATION_DIR=${vyatta_configdir}/active
+export VYATTA_CHANGES_ONLY_DIR=${vyatta_configdir}/tmp/changes_only_$$
+export VYATTA_TEMP_CONFIG_DIR=${vyatta_configdir}/tmp/new_config_$$
+export VYATTA_CONFIG_TMP=${vyatta_configdir}/tmp/tmp_$$
+export VYATTA_CONFIG_TEMPLATE=$vyatta_cfg_templates
+export VYATTA_EDIT_LEVEL=/
+export VYATTA_TEMPLATE_LEVEL=/
+export VYATTA_TAG_NAME=node.tag
+export VYATTA_MOD_NAME=.modified
+
+# don't set level if already set
+if [ -n "$VYATTA_USER_LEVEL_DIR" ]; then
+ return
+fi
+{
+is_admin=0
+is_users=0
+VYATTA_LEVEL_GROUP_ADMIN=vyattacfg
+VYATTA_LEVEL_GROUP_USERS=quaggavty
+local -a groups=( $(id -Gn) )
+for g in "${groups[@]}"; do
+ if [ "$g" == "$VYATTA_LEVEL_GROUP_ADMIN" ]; then
+ is_admin=1
+ fi
+ if [ "$g" == "$VYATTA_LEVEL_GROUP_USERS" ]; then
+ is_users=1
+ fi
+done
+# check level from high to low
+if [ $is_admin == 1 ]; then
+ declare -x -r VYATTA_USER_LEVEL_DIR=${vyatta_sysconfdir}/shell/level/admin
+else
+ # no need to check is_users since there are only 2 levels for now
+ declare -x -r VYATTA_USER_LEVEL_DIR=${vyatta_sysconfdir}/shell/level/users
+fi
+} 2>/dev/null || :
+
diff --git a/etc/shell/level/admin/restricted-mode b/etc/shell/level/admin/restricted-mode
new file mode 100644
index 0000000..53752db
--- /dev/null
+++ b/etc/shell/level/admin/restricted-mode
@@ -0,0 +1 @@
+output
diff --git a/etc/shell/level/users/allowed-cfg b/etc/shell/level/users/allowed-cfg
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/etc/shell/level/users/allowed-cfg
diff --git a/etc/shell/level/users/allowed-op b/etc/shell/level/users/allowed-op
new file mode 100644
index 0000000..a2ad52d
--- /dev/null
+++ b/etc/shell/level/users/allowed-op
@@ -0,0 +1,3 @@
+show
+terminal
+exit
diff --git a/etc/shell/level/users/allowed-pipe b/etc/shell/level/users/allowed-pipe
new file mode 100644
index 0000000..3204ef3
--- /dev/null
+++ b/etc/shell/level/users/allowed-pipe
@@ -0,0 +1,10 @@
+more
+1
+no-more
+1
+count
+1
+match
+2
+no-match
+2
diff --git a/etc/shell/level/users/restricted-mode b/etc/shell/level/users/restricted-mode
new file mode 100644
index 0000000..2877147
--- /dev/null
+++ b/etc/shell/level/users/restricted-mode
@@ -0,0 +1 @@
+full
diff --git a/scripts/vyatta-output-config.pl b/scripts/vyatta-output-config.pl
index 8b25ec2..8eb0be8 100755
--- a/scripts/vyatta-output-config.pl
+++ b/scripts/vyatta-output-config.pl
@@ -8,6 +8,11 @@ if ($ARGV[0] eq '-all') {
shift;
VyattaConfigOutput::set_show_all(1);
}
-VyattaConfigOutput::outputNewConfig(@ARGV);
+if ($ARGV[0] eq '-active') {
+ shift;
+ VyattaConfigOutput::outputActiveConfig(@ARGV);
+} else {
+ VyattaConfigOutput::outputNewConfig(@ARGV);
+}
exit 0;
diff --git a/src/cli_new.c b/src/cli_new.c
index c51be7f..d4380d5 100644
--- a/src/cli_new.c
+++ b/src/cli_new.c
@@ -268,14 +268,11 @@ void internal_error(int line, char *file)
*/
void vtw_sort(valstruct *valp, vtw_sorted *sortp)
{
- int i, unsorted, left, child, right;
- void *leftp, *rightp, *childp;
+ int i;
const char * format;
unsigned int *parts;
vtw_type_e type = valp->val_type;
char *cp;
- int cur=0, par=0, partnum=0, res=0;
- void *curp, *parp;
sortp->num = valp->cnt?valp->cnt : 1;
#ifdef CLI_DEBUG
diff --git a/src/commit.c b/src/commit.c
index 2eedf6f..400328e 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -290,7 +290,7 @@ int main(int argc, char **argv)
my_free(mod);
if (st < 0 ) {
fprintf(out_stream, "No configuration changes to commit\n");
- bye("No configuration changes to commit\n");
+ return 0;
}
if (get_config_lock() == -1) {