diff options
author | rbalocca <rbalocca@fugazi.vyatta.com> | 2007-12-18 14:18:24 -0800 |
---|---|---|
committer | rbalocca <rbalocca@fugazi.vyatta.com> | 2007-12-18 14:18:24 -0800 |
commit | 64a8cfa9effac219e51498c3b8ef43437ad0396a (patch) | |
tree | fb11fa4d01b3dbe1f0f60e838b4ec450cbf31a64 | |
parent | 65db98116efa3c311c798f05f4f6ec97e9b6d643 (diff) | |
parent | 7966b8cf00e08548447e551a3fcfde40aa06cc59 (diff) | |
download | vyatta-cfg-64a8cfa9effac219e51498c3b8ef43437ad0396a.tar.gz vyatta-cfg-64a8cfa9effac219e51498c3b8ef43437ad0396a.zip |
Merge branch 'master' into glendale
-rw-r--r-- | debian/vyatta-cfg.postinst.in | 3 | ||||
-rw-r--r-- | etc/bash_completion.d/20vyatta-cfg | 12 | ||||
-rw-r--r-- | etc/default/vyatta-cfg | 21 | ||||
-rwxr-xr-x | etc/init.d/vyatta-ofr | 72 | ||||
-rw-r--r-- | scripts/VyattaConfig.pm | 2 | ||||
-rw-r--r-- | scripts/VyattaConfigDOMTree.pm | 2 | ||||
-rwxr-xr-x | scripts/vyatta-cfg-notify | 4 | ||||
-rw-r--r-- | scripts/vyatta-interfaces.pl | 4 | ||||
-rwxr-xr-x | scripts/vyatta-load-config.pl | 6 | ||||
-rwxr-xr-x | scripts/vyatta-save-config.pl | 9 | ||||
-rwxr-xr-x | scripts/xorp_tmpl_tool | 14 | ||||
-rw-r--r-- | src/cli_new.c | 214 | ||||
-rw-r--r-- | src/commit.c | 14 | ||||
-rw-r--r-- | src/delete.c | 4 | ||||
-rw-r--r-- | templates/interfaces/loopback/node.tag/address/node.def | 8 |
15 files changed, 216 insertions, 173 deletions
diff --git a/debian/vyatta-cfg.postinst.in b/debian/vyatta-cfg.postinst.in index 80ddb8c..3fce13b 100644 --- a/debian/vyatta-cfg.postinst.in +++ b/debian/vyatta-cfg.postinst.in @@ -3,6 +3,9 @@ prefix=@prefix@ sysconfdir=@sysconfdir@ +mkdir -m 0775 -p $sysconfdir/config $prefix/config +chgrp quaggavty $sysconfdir/config $prefix/config + update-rc.d vyatta-ofr defaults 90 >/dev/null # do we want to start vyatta-ofr here in postinst? diff --git a/etc/bash_completion.d/20vyatta-cfg b/etc/bash_completion.d/20vyatta-cfg index 78f2e0a..bc9088f 100644 --- a/etc/bash_completion.d/20vyatta-cfg +++ b/etc/bash_completion.d/20vyatta-cfg @@ -941,12 +941,18 @@ make_vyatta_config_dir () sudo chgrp ${DEF_GROUP} $1 } +if grep -q union=aufs /proc/cmdline || grep -q aufs /proc/filesystems ; then + export UNIONFS=aufs +else + export UNIONFS=unionfs +fi + make_vyatta_config_dir $VYATTA_ACTIVE_CONFIGURATION_DIR make_vyatta_config_dir $VYATTA_CHANGES_ONLY_DIR make_vyatta_config_dir $VYATTA_CONFIG_TMP if [ ! -d $VYATTA_TEMP_CONFIG_DIR ]; then make_vyatta_config_dir $VYATTA_TEMP_CONFIG_DIR - sudo mount -t unionfs -o dirs=${VYATTA_CHANGES_ONLY_DIR}=rw:/opt/vyatta/config/active=ro unionfs ${VYATTA_TEMP_CONFIG_DIR} + sudo mount -t $UNIONFS -o dirs=${VYATTA_CHANGES_ONLY_DIR}=rw:/opt/vyatta/config/active=ro $UNIONFS ${VYATTA_TEMP_CONFIG_DIR} fi # disallow 'Ctrl-D' exit, since we need special actions on 'exit' @@ -976,3 +982,7 @@ complete -F vyatta_config_complete edit complete -F vyatta_config_complete exit complete -F vyatta_run_complete run +# Local Variables: +# mode: shell-script +# sh-indentation: 4 +# End: diff --git a/etc/default/vyatta-cfg b/etc/default/vyatta-cfg index d369e0f..e560788 100644 --- a/etc/default/vyatta-cfg +++ b/etc/default/vyatta-cfg @@ -1,15 +1,18 @@ # 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 +{ +declare -x -r VYATTA_ACTIVE_CONFIGURATION_DIR=${vyatta_configdir}/active +declare -x -r VYATTA_CHANGES_ONLY_DIR=${vyatta_configdir}/tmp/changes_only_$$ +declare -x -r VYATTA_TEMP_CONFIG_DIR=${vyatta_configdir}/tmp/new_config_$$ +declare -x -r VYATTA_CONFIG_TMP=${vyatta_configdir}/tmp/tmp_$$ +declare -x -r VYATTA_CONFIG_TEMPLATE=$vyatta_cfg_templates +declare -x -r VYATTA_EDIT_LEVEL=/ +declare -x -r VYATTA_TEMPLATE_LEVEL=/ +declare -x -r VYATTA_TAG_NAME=node.tag +declare -x -r VYATTA_MOD_NAME=.modified +declare -x -r VYATTA_CFG_GROUP_NAME=vyattacfg +} 2>/dev/null || : # don't set level if already set if [ -n "$VYATTA_USER_LEVEL_DIR" ]; then diff --git a/etc/init.d/vyatta-ofr b/etc/init.d/vyatta-ofr index 96770f6..4f8b7dd 100755 --- a/etc/init.d/vyatta-ofr +++ b/etc/init.d/vyatta-ofr @@ -69,53 +69,6 @@ have_rl_system () { test -x $vyatta_sbindir/rl-system.init } -use_floppy () { - _fd_=/media/floppy - - if have_rl_system ; then -## only do this if we have the rl-system package -## if we donot discover an fd device, try loading the floppy module - grep -q fd /proc/devices || modprobe -q floppy 2>/dev/null - if grep -q fd /proc/devices ; then - if awk -- '$1 ~ /\/dev\/fd/ { exit 1 }' /proc/mounts - then - mkdir -p $_fd_ - mount -t ext2 /dev/fd0 $_fd_ -o sync 2>/dev/null - test $? -eq 32 && mount -t vfat /dev/fd0 $_fd_ 2>/dev/null - fi - fi - fi - test -d ${_fd_}/config -} - -setup_configdir() { - [ -f $BOOTFILE ] && return 0 - mkdir -m 0775 -p ${vyatta_sysconfdir}/config - chgrp ${GROUP} ${vyatta_sysconfdir}/config - if [ -d ~root/vyatta/config ] ; then - mount -o bind ~root/vyatta/config $vyatta_sysconfdir/config - elif use_floppy ; then - mount -o bind /media/floppy/config $vyatta_sysconfdir/config - else - mkdir -m 0775 -p ~root/vyatta/config - chgrp ${GROUP} ~root/vyatta ~root/vyatta/config - mount -o bind ~root/vyatta/config $vyatta_sysconfdir/config - fi -} - -setup_rclocal () { - [ -f /etc/rc.local ] || touch /etc/rc.local - if [ -f ~root/vyatta/rc.local ]; then - mount -o bind ~root/vyatta/rc.local /etc/rc.local - elif [ -f /media/floppy/rc.local ]; then - mount -o bind /media/floppy/rc.local /etc/rc.local - fi -} - -restore_rclocal () { - umount /etc/rc.local >& /dev/null -} - # if necessary, provide initial config init_bootfile () { if [ ! -f $BOOTFILE ] ; then @@ -150,28 +103,11 @@ load_bootfile () fi } -# this handles the "config dir" (/opt/vyatta/config), which is different -# from the directory for config files (/opt/vyatta/etc/config). -mount_cfg_dir () -{ - if [ ! -d ${vyatta_configdir} ] ; then - mkdir -m 0775 -p ${vyatta_configdir} - chgrp ${GROUP} ${vyatta_configdir} - fi - mount -o nosuid,nodev -t tmpfs none ${vyatta_configdir} -} - -unmount_cfg_dir () -{ - umount ${vyatta_configdir} -} - start () { log_daemon_msg "Starting Vyatta Router" - setup_configdir - setup_rclocal - mount_cfg_dir + mount -o nosuid,nodev,mode=775 -t tmpfs none ${vyatta_configdir} + chgrp ${GROUP} ${vyatta_configdir} init_bootfile migrate_bootfile for s in ${subinit[@]} ; do @@ -179,7 +115,6 @@ start () ${vyatta_sbindir}/${s}.init start || (log_end_msg $? && return) done load_bootfile - echo -n $BOOTFILE > ${vyatta_sysconfdir}/bootfile_path log_end_msg $? } @@ -193,8 +128,7 @@ stop() ${vyatta_sbindir}/${s}.init stop let status\|=$? done - unmount_cfg_dir - restore_rclocal + umount ${vyatta_configdir} log_end_msg $status } diff --git a/scripts/VyattaConfig.pm b/scripts/VyattaConfig.pm index a783957..9b1b933 100644 --- a/scripts/VyattaConfig.pm +++ b/scripts/VyattaConfig.pm @@ -284,7 +284,7 @@ sub listDeleted { if (! -d "$filepath") { return undef; } else { opendir DIR, "$filepath" or return undef; - @nodes = grep /^\.wh./, readdir DIR; + @nodes = grep !/^\.wh\.\.wh\./, grep /^\.wh./, readdir DIR; closedir DIR; } diff --git a/scripts/VyattaConfigDOMTree.pm b/scripts/VyattaConfigDOMTree.pm index d951202..86aabf8 100644 --- a/scripts/VyattaConfigDOMTree.pm +++ b/scripts/VyattaConfigDOMTree.pm @@ -307,7 +307,7 @@ sub getSubNodesNumber { my @subs = $node->getSubNodes(); - if(defined @subs) { + if(@subs) { $ret = $#subs + 1; } } diff --git a/scripts/vyatta-cfg-notify b/scripts/vyatta-cfg-notify index 82dc6a3..07a385d 100755 --- a/scripts/vyatta-cfg-notify +++ b/scripts/vyatta-cfg-notify @@ -1,11 +1,13 @@ #!/bin/bash +[ -r /etc/default/vyatta ] && source /etc/default/vyatta + 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-) ) + | grep "^newgrp $VYATTA_CFG_GROUP_NAME" | cut -c 29-) ) for (( i = 0; i < ${#ulist[@]}; i += 2 )); do utty=${ulist[i]} diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index d7ba950..36d811f 100644 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -287,6 +287,10 @@ sub is_valid_addr { my ($addr_net, $intf) = @_; if ($addr_net eq "dhcp") { + if ($intf eq "lo") { + print "Error: can't use dhcp client on loopback interface\n"; + exit 1; + } if (is_dhcp_enabled($intf)) { print "Error: dhcp already configured for $intf\n"; exit 1; diff --git a/scripts/vyatta-load-config.pl b/scripts/vyatta-load-config.pl index a6f037a..d011a65 100755 --- a/scripts/vyatta-load-config.pl +++ b/scripts/vyatta-load-config.pl @@ -8,11 +8,7 @@ use VyattaConfigLoad; my $etcdir = $ENV{vyatta_sysconfdir}; my $sbindir = $ENV{vyatta_sbindir}; -my $bootpath = ''; -if (-r "$etcdir/bootfile_path") { - $bootpath = `cat $etcdir/bootfile_path`; -} -$bootpath =~ s/\/[^\/]+$//; +my $bootpath = $etcdir . "/config"; if ($#ARGV != 0) { print "Usage: load <config_file_name>\n"; diff --git a/scripts/vyatta-save-config.pl b/scripts/vyatta-save-config.pl index 26b8eec..bad7c45 100755 --- a/scripts/vyatta-save-config.pl +++ b/scripts/vyatta-save-config.pl @@ -5,19 +5,14 @@ use lib "/opt/vyatta/share/perl5/"; use VyattaConfigOutput; my $etcdir = "/opt/vyatta/etc"; -my $bootfile = ''; -if (-r "$etcdir/bootfile_path") { - $bootfile = `cat $etcdir/bootfile_path`; -} -my $bootpath = $bootfile; -$bootpath =~ s/\/[^\/]+$//; +my $bootpath = $etcdir . "/config"; +my $save_file = $bootpath . "/config.boot"; if ($#ARGV > 0) { print "Usage: save [config_file_name]\n"; exit 1; } -my $save_file = "$bootfile"; if (defined($ARGV[0])) { $save_file = $ARGV[0]; if (!($save_file =~ /^\//)) { diff --git a/scripts/xorp_tmpl_tool b/scripts/xorp_tmpl_tool index 54c87bb..014a53b 100755 --- a/scripts/xorp_tmpl_tool +++ b/scripts/xorp_tmpl_tool @@ -1,5 +1,11 @@ #!/bin/bash +if grep -q union=aufs /proc/cmdline || grep -q aufs /proc/filesystems ; then + export UNIONFS=aufs +else + export UNIONFS=unionfs +fi + UMASK_SAVE_G=`umask` umask 0111 XORPLOGFILE=/tmp/xorp_tmpl_tool.log @@ -36,7 +42,7 @@ export VYATTA_TEMP_CONFIG_DIR=/opt/vyatta/config/tmp/new_config_$VTID; if [ ! -d $VYATTA_TEMP_CONFIG_DIR ] then mkdir -p $VYATTA_TEMP_CONFIG_DIR - sudo mount -t unionfs -o dirs=${VYATTA_CHANGES_ONLY_DIR}=rw:/opt/vyatta/config/active=ro unionfs ${VYATTA_TEMP_CONFIG_DIR} + sudo mount -t $UNIONFS -o dirs=${VYATTA_CHANGES_ONLY_DIR}=rw:/opt/vyatta/config/active=ro $UNIONFS ${VYATTA_TEMP_CONFIG_DIR} fi ## cli ENV_TMP_DIR @@ -110,7 +116,7 @@ case "$1" in sudo umount ${VYATTA_TEMP_CONFIG_DIR} sudo rm -rf $VYATTA_CHANGES_ONLY_DIR/* $VYATTA_CHANGES_ONLY_DIR/.modified - sudo mount -t unionfs -o dirs=${VYATTA_CHANGES_ONLY_DIR}=rw:/opt/vyatta/config/active=ro unionfs ${VYATTA_TEMP_CONFIG_DIR} + sudo mount -t $UNIONFS -o dirs=${VYATTA_CHANGES_ONLY_DIR}=rw:/opt/vyatta/config/active=ro $UNIONFS ${VYATTA_TEMP_CONFIG_DIR} RET_STATUS=0 ;; end_loading) @@ -150,3 +156,7 @@ echo "ret=${RET_STATUS}" >> ${XORPLOGFILE} umask ${UMASK_SAVE_G} exit $RET_STATUS +# Local Variables: +# mode: shell-script +# sh-indentation: 4 +# End: diff --git a/src/cli_new.c b/src/cli_new.c index d4380d5..e3a7955 100644 --- a/src/cli_new.c +++ b/src/cli_new.c @@ -14,6 +14,8 @@ #include "cli_val.h" #include "cli_parse.h" #include <regex.h> +#include <errno.h> +#include <time.h> #include "cli_objects.h" #include "cli_val_engine.h" @@ -56,12 +58,6 @@ static int cond_format_lens[DOMAIN_TYPE] = 6 /* MACADDR_TYPE */ }; -struct __slist_t; - -typedef struct __slist_t { - struct __slist_t *next; -} slist_t; - static int cli_val_len; static char *cli_val_ptr; @@ -229,6 +225,7 @@ void di(vtw_sorted *srtp) } #define LOCK_FILE "/opt/vyatta/config/.lock" +#define COMMIT_CMD "/opt/vyatta/sbin/my_commit" static void release_config_lock() @@ -237,22 +234,133 @@ release_config_lock() /* error ignored */ } -int -get_config_lock() +/* try to clean up orphaned lock file. return -1 if failed */ +static int +try_lock_cleanup() +{ + char buf[128]; + char proc[128]; + FILE *f = NULL; + int ret = -1; + struct stat statb; + + do { + /* get the proc entry */ + if ((f = fopen(LOCK_FILE, "r")) == NULL) { + break; + } + if (fgets(proc, 128, f) == NULL) { + break; + } + /* read the proc entry */ + if (stat(proc, &statb) == -1) { + if (errno == ENOENT) { + /* proc entry doesn't exist. can clean up the lock now */ + ret = 0; + break; + } + } + fclose(f); + if ((f = fopen(proc, "r")) == NULL) { + /* can't open proc entry. assume we can't clean up */ + break; + } + if (fgets(buf, 128, f) == NULL) { + /* can't read proc entry. assume we can't clean up */ + break; + } + /* check if the process is commit */ + if (strcmp(buf, COMMIT_CMD) == 0) { + /* it is commit. can't clean up */ + break; + } + /* can clean up the lock */ + ret = 0; + } while (0); + if (f) { + fclose(f); + } + if (ret == 0) { + unlink(LOCK_FILE); + if (stat(LOCK_FILE, &statb) != -1 || errno != ENOENT) { + /* proc entry still exists. cleanup failed */ + ret = -1; + } + } + return ret; +} + +static int +create_lock_file(int try_cleanup) { - int fd = open(LOCK_FILE, O_WRONLY | O_CREAT | O_EXCL, 0660); + int fd = -1; + int i = 0; + struct timespec req; + +#define LOCK_WAIT_TIME 2 +#define LOCK_NUM_RETRIES 5 + req.tv_sec = LOCK_WAIT_TIME; + req.tv_nsec = 0; + fd = open(LOCK_FILE, O_WRONLY | O_CREAT | O_EXCL, 0660); if (fd == -1) { - return -1; + for (i = 0; i < LOCK_NUM_RETRIES; i++) { + nanosleep(&req, NULL); + fd = open(LOCK_FILE, O_WRONLY | O_CREAT | O_EXCL, 0660); + if (fd >= 0) { + break; + } + } } - if (close(fd) == -1) { - release_config_lock(); - return -1; + if (fd == -1 && try_cleanup) { + if (try_lock_cleanup() != -1) { + /* cleanup succeeded */ + fd = create_lock_file(0); + } } - if (atexit(release_config_lock) != 0) { + return fd; +} + +int +get_config_lock() +{ + int fd = -1; + FILE *lfile = NULL; + int ret = -1; + + do { + /* create lock file */ + fd = create_lock_file(1); + if (fd == -1) { + break; + } + + /* write pid into lock file */ + if ((lfile = fdopen(fd, "w")) == NULL) { + break; + } + if (fprintf(lfile, "/proc/%u/cmdline", getpid()) < 0) { + break; + } + /* fclose also closes fd */ + if (fclose(lfile) != 0) { + break; + } + /* clean up on exit */ + if (atexit(release_config_lock) != 0) { + break; + } + ret = 0; + } while (0); + + if (ret == -1) { + if (lfile) { + fclose(lfile); + } else if (fd != -1) { + close(fd); + } release_config_lock(); - return -1; } - return 0; + return ret; } void internal_error(int line, char *file) @@ -1787,85 +1895,59 @@ boolean validate_value(vtw_def *def, char *cp) return ret; } -typedef struct __value_list { - slist_t link; - const char *value; -} value_list; - -static void delete_list(slist_t *head) -{ - while (head != NULL) { - slist_t *elem = head; - head = head->next; - my_free(elem); - } -} - void subtract_values(char **lhs, const char *rhs) { - size_t length = 0; + size_t length = 0, lhs_cnt = 0, rhs_cnt = 0, i; const char *line = NULL; char *rhs_copy = NULL, *res = NULL; - slist_t *head = NULL, *ptr = NULL; - slist_t *new_head = NULL, *new_ptr = NULL; + const char **head = NULL, **ptr = NULL; + const char **new_head = NULL, **new_ptr = NULL; if (lhs == NULL || *lhs == NULL || **lhs == '\0' || rhs == NULL || *rhs == '\0') return; - rhs_copy = my_malloc(strlen(rhs), "subtract_values rhs_copy"); - strcpy(rhs_copy, rhs); - - head = ptr = my_malloc(sizeof(slist_t), "subtract_values list1"); - memset(head, 0, sizeof(slist_t)); + rhs_copy = strdup(rhs); + length = strlen(rhs) / 2; + head = ptr = my_malloc(length, "subtract_values list1"); + memset(head, 0, length); line = strtok(rhs_copy, "\n\r"); while (line != NULL && *line != '\0') { - value_list *elem = NULL; - - elem = (value_list *) my_malloc(sizeof(value_list), "subtract_values elem1"); - memset(elem, 0, sizeof(value_list)); - elem->value = line; - ptr->next = (slist_t *) elem; - ptr = ptr->next; + *ptr = line; + ptr++; + rhs_cnt++; line = strtok(NULL, "\n\r"); } - new_head = new_ptr = my_malloc(sizeof(slist_t), "subtract_values list2"); - memset(new_head, 0, sizeof(slist_t)); + length = strlen(*lhs) / 2; + new_head = new_ptr = my_malloc(length, "subtract_values list2"); + memset(new_head, 0, length); + length = 0; line = strtok(*lhs, "\n\r"); while (line != NULL && *line != '\0') { - value_list *elem = NULL; - - ptr = head; - while (ptr->next != NULL) { - elem = (value_list *) ptr->next; - if (strncmp(line, elem->value, strlen(line)) == 0) + for (i = 0; i < rhs_cnt; i++) { + if (strncmp(line, head[i], strlen(line)) == 0) break; - ptr = ptr->next; } - if (ptr->next == NULL) { - elem = (value_list *) my_malloc(sizeof(value_list), "subtract_values elem2"); - memset(elem, 0, sizeof(value_list)); - elem->value = line; - new_ptr->next = elem; - new_ptr = new_ptr->next; + if (i >= rhs_cnt) { + *new_ptr = line; length += strlen(line) + 1; + new_ptr++; + lhs_cnt++; } line = strtok(NULL, "\n\r"); } - new_ptr = new_head->next; res = (char *) my_malloc(length + 1, "subtract_values result"); *res = '\0'; - while (new_ptr != NULL) { - strcat(res, ((value_list *) new_ptr)->value); + for (i = 0; i < lhs_cnt; i++) { + strcat(res, new_head[i]); strcat(res, "\n"); - new_ptr = new_ptr->next; } - delete_list(head); - delete_list(new_head); + my_free(head); + my_free(new_head); if (rhs_copy != NULL) my_free(rhs_copy); my_free(*lhs); diff --git a/src/commit.c b/src/commit.c index 400328e..c3219e5 100644 --- a/src/commit.c +++ b/src/commit.c @@ -157,6 +157,7 @@ static boolean validate_dir_for_commit() cp = NULL; status = get_value(&cp, &m_path); if (status == VTWERR_OK) { + size_t value_size = 0; #ifdef DEBUG1 printf("Validating value |%s|\n" "for path %s\n", cp, m_path.path); @@ -167,6 +168,7 @@ static boolean validate_dir_for_commit() // Bug #2509 if (def.multi) { char *old_value = NULL; + value_size = strlen(cp); switch_path(APATH); // temporarily switching to the active config path status = get_value(&old_value, &m_path); if (status == VTWERR_OK) { @@ -176,8 +178,10 @@ static boolean validate_dir_for_commit() if (old_value) my_free(old_value); } - - status = validate_value(&def, cp); + if (strlen(cp) > 0 || value_size == 0) + status = validate_value(&def, cp); + else + status = TRUE; ret = ret && status; } if (cp) @@ -238,7 +242,7 @@ static boolean validate_dir_for_commit() if (!def_present || !def.tag) pop_path(&t_path); /* for PUSH 2b */ - } + } // while status = closedir(dp); if (status) bye("Cannot close dir %s\n", m_path.path); @@ -1334,8 +1338,8 @@ static int fin_commit(boolean ok) static char format4[]="rm -rf %s/{.*,*} >&/dev/null ; /bin/true"; /*cdirp*/ static char format5[]="rm -rf %s/{.*,*} >&/dev/null ; /bin/true"; /*adirp*/ static char format6[]="mv -f %s/* -t %s";/*tmpp, adirp*/ - static char format7[]="sudo mount -t unionfs -o dirs=%s=rw:%s=ro" - " unionfs %s"; /*cdirp, adirp, mdirp*/ + static char format7[]="sudo mount -t $UNIONFS -o dirs=%s=rw:%s=ro" + " $UNIONFS %s"; /*cdirp, adirp, mdirp*/ int m_len = strlen(get_mdirp()); int t_len = strlen(get_tmpp()); int c_len = strlen(get_cdirp()); diff --git a/src/delete.c b/src/delete.c index 1b7b62e..b62a697 100644 --- a/src/delete.c +++ b/src/delete.c @@ -28,8 +28,8 @@ static void remove_rf(boolean do_umount) command = my_malloc(strlen(get_mdirp()) + strlen(get_cdirp()) + strlen(get_mdirp()) + 100, "delete"); - sprintf(command, "sudo mount -t unionfs -o dirs=%s=rw:%s=ro:" - " unionfs %s", get_cdirp(), get_adirp(), get_mdirp()); + sprintf(command, "sudo mount -t $UNIONFS -o dirs=%s=rw:%s=ro:" + " $UNIONFS %s", get_cdirp(), get_adirp(), get_mdirp()); system(command); free(command); } diff --git a/templates/interfaces/loopback/node.tag/address/node.def b/templates/interfaces/loopback/node.tag/address/node.def index e597676..6cef105 100644 --- a/templates/interfaces/loopback/node.tag/address/node.def +++ b/templates/interfaces/loopback/node.tag/address/node.def @@ -1,6 +1,6 @@ multi: -type: ipv4net +type: txt help: "Set IPv4 address and prefix for this interface" -# TODO make sure 127.0.0.0/8 not in here. -update: "sudo ip addr add $(@) dev $(../@)"; "Error setting address $(@) on dev $(../@)" -delete: "sudo ip addr del $(@) dev $(../@)"; "Error deleting address $(@) on dev $(../@)" +syntax: exec "/opt/vyatta/sbin/vyatta-interfaces.pl --valid-addr $(@) --dev $(../@)" +update: "sudo /opt/vyatta/sbin/vyatta-interfaces.pl --eth-addr-update $(@) --dev $(../@)"; "Error setting address $(@) on dev $(../@)" +delete: "sudo /opt/vyatta/sbin/vyatta-interfaces.pl --eth-addr-delete $(@) --dev $(../@)"; "Error deleting address $(@) on dev $(../@)" |