diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c37aa27..0718eb21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -111,7 +111,6 @@ * Many hand-crafted validation messages have been removed and replaced with generic validations, which may lead to changed rpc-error messages. * CLICON_XML_SORT option (in clixon-config.yang) has been removed and set to true permanently. Unsorted XML lists leads to slower performance and old obsolete code can be removed. * Strict namespace setting can be a problem when upgrading existing database files, such as startup-db or persistent running-db, or any other saved XML file. -* Removed obsolete `-x` command-line option to clixon_cli. * Removed `delete-config` support for candidate db since it is not supported in RFC6241. * Switched the order of `error-type` and `error-tag` in all netconf and restconf error messages to comply to RFC order. * XML namespace handling is corrected (see major changes) @@ -130,15 +129,14 @@ * `=" command-line option to all programs: backend, cli, netconf, restconf. diff --git a/apps/backend/backend_main.c b/apps/backend/backend_main.c index 31f7eafe..0bf2a7f8 100644 --- a/apps/backend/backend_main.c +++ b/apps/backend/backend_main.c @@ -77,10 +77,7 @@ #define BACKEND_LOGFILE "/usr/local/var/clixon_backend.log" -/*! Clean and close all state of backend (but dont exit). - * Cannot use h after this - * @param[in] h Clixon handle - */ +/*! Terminate. Cannot use h after this */ static int backend_terminate(clicon_handle h) { @@ -90,11 +87,8 @@ backend_terminate(clicon_handle h) char *sockpath = clicon_sock(h); cxobj *x; struct stat st; - int ss; clicon_debug(1, "%s", __FUNCTION__); - if ((ss = clicon_socket_get(h)) != -1) - close(ss); if ((yspec = clicon_dbspec_yang(h)) != NULL) yspec_free(yspec); if ((yspec = clicon_config_yang(h)) != NULL) @@ -937,11 +931,10 @@ main(int argc, goto done; } - /* Initialize server socket and save it to handle */ + /* Initialize server socket */ if ((ss = backend_server_socket(h)) < 0) goto done; - if (clicon_socket_set(h, ss) < 0) - goto done; + if (debug) clicon_option_dump(h, debug); @@ -952,6 +945,8 @@ main(int argc, retval = 0; done: clicon_log(LOG_NOTICE, "%s: %u Terminated retval:%d", __PROGRAM__, getpid(), retval); + if (ss != -1) + close(ss); backend_terminate(h); /* Cannot use h after this */ return retval; diff --git a/apps/cli/cli_handle.c b/apps/cli/cli_handle.c index e2f25121..34a92c4d 100644 --- a/apps/cli/cli_handle.c +++ b/apps/cli/cli_handle.c @@ -83,7 +83,7 @@ struct cli_handle { /* ------ end of common handle ------ */ cligen_handle cl_cligen; /* cligen handle */ - cli_syntax_t *cl_stx; /* CLI syntax structure */ + cli_syntax_t *cl_stx; /* syntax structure */ }; /*! Return a clicon handle for other CLICON API calls diff --git a/apps/cli/cli_main.c b/apps/cli/cli_main.c index 905fb5b8..fba80de1 100644 --- a/apps/cli/cli_main.c +++ b/apps/cli/cli_main.c @@ -71,12 +71,11 @@ #include "cli_handle.h" /* Command line options to be passed to getopt(3) */ -#define CLI_OPTS "hD:f:l:F:1a:u:d:m:qp:GLy:c:U:o:" +#define CLI_OPTS "hD:f:xl:F:1a:u:d:m:qp:GLy:c:U:o:" -/*! Clean and close all state of cli process (but dont exit). - * Cannot use h after this - * @param[in] h Clixon handle - */ +#define CLI_LOGFILE "/tmp/clixon_cli.log" + +/*! terminate cli application */ static int cli_terminate(clicon_handle h) { @@ -145,6 +144,63 @@ cli_interactive(clicon_handle h) return retval; } +/*! Read file as configuration file and print xml file for migrating to new fmt + * @see clicon_option_readfile_xml + */ +static int +dump_configfile_xml_fn(FILE *fout, + const char *filename) +{ + struct stat st; + char opt[1024]; + char val[1024]; + char line[1024]; + char *cp; + FILE *f = NULL; + int retval = -1; + char *suffix; + + if (filename == NULL || !strlen(filename)){ + clicon_err(OE_UNIX, 0, "Not specified"); + goto done; + } + if ((suffix = rindex(filename, '.')) != NULL && + strcmp((suffix+1), "xml") == 0){ + clicon_err(OE_CFG, 0, "Configfile %s should not be XML", filename); + goto done; + } + if (stat(filename, &st) < 0){ + clicon_err(OE_UNIX, errno, "%s", filename); + goto done; + } + if (!S_ISREG(st.st_mode)){ + clicon_err(OE_UNIX, 0, "%s is not a regular file", filename); + goto done; + } + if ((f = fopen(filename, "r")) == NULL) { + clicon_err(OE_UNIX, errno, "configure file: %s", filename); + return -1; + } + clicon_debug(2, "%s: Reading config file %s", __FUNCTION__, filename); + fprintf(fout, "\n"); + while (fgets(line, sizeof(line), f)) { + if ((cp = strchr(line, '\n')) != NULL) /* strip last \n */ + *cp = '\0'; + /* Trim out comments, strip whitespace, and remove CR */ + if ((cp = strchr(line, '#')) != NULL) + memcpy(cp, "\n", 2); + if (sscanf(line, "%s %s", opt, val) < 2) + continue; + fprintf(fout, "\t<%s>%s\n", opt, val, opt); + } + fprintf(fout, "\n"); + retval = 0; + done: + if (f) + fclose(f); + return retval; +} + static void usage(clicon_handle h, char *argv0) @@ -157,6 +213,7 @@ usage(clicon_handle h, "\t-h \t\tHelp\n" "\t-D \tDebug level\n" "\t-f \tConfig-file (mandatory)\n" + "\t-x\t\tDump configuration file as XML on stdout (migration utility)\n" "\t-F \tRead commands from file (default stdin)\n" "\t-1\t\tDo not enter interactive mode\n" "\t-a UNIX|IPv4|IPv6\tInternal backend socket family\n" @@ -194,6 +251,7 @@ main(int argc, char **argv) int help = 0; int logdst = CLICON_LOG_STDERR; char *restarg = NULL; /* what remains after options */ + int dump_configfile_xml = 0; yang_spec *yspec; yang_spec *yspecfg = NULL; /* For config XXX clixon bug */ struct passwd *pw; @@ -207,7 +265,6 @@ main(int argc, char **argv) /* Initiate CLICON handle */ if ((h = cli_handle_init()) == NULL) goto done; - /* Set username to clicon handle. Use in all communication to backend * Note, can be overridden by -U */ @@ -244,6 +301,9 @@ main(int argc, char **argv) usage(h, argv[0]); clicon_option_str_set(h, "CLICON_CONFIGFILE", optarg); break; + case 'x': /* dump config file as xml (migration from .conf file)*/ + dump_configfile_xml++; + break; case 'l': /* Log destination: s|e|o|f */ if ((logdst = clicon_log_opt(optarg[0])) < 0) usage(h, argv[0]); @@ -260,6 +320,14 @@ main(int argc, char **argv) clicon_debug_init(debug, NULL); + /* Use cli as util tool to dump config file as xml for migration */ + if (dump_configfile_xml) { + clicon_hash_t *copt = clicon_options(h); + char *configfile = hash_value(copt, "CLICON_CONFIGFILE", NULL); + if (dump_configfile_xml_fn(stdout, configfile) < 0) + goto done; + } + /* Create top-level yang spec and store as option */ if ((yspecfg = yspec_new()) == NULL) goto done; @@ -277,6 +345,7 @@ main(int argc, char **argv) switch (c) { case 'D' : /* debug */ case 'f': /* config file */ + case 'x': /* dump config file as xml */ case 'l': /* Log destination */ break; /* see above */ case 'F': /* read commands from file */ diff --git a/apps/netconf/netconf_main.c b/apps/netconf/netconf_main.c index 27794d65..b6c1e930 100644 --- a/apps/netconf/netconf_main.c +++ b/apps/netconf/netconf_main.c @@ -283,10 +283,6 @@ send_hello(clicon_handle h, return retval; } -/*! Clean and close all state of netconf process (but dont exit). - * Cannot use h after this - * @param[in] h Clixon handle - */ static int netconf_terminate(clicon_handle h) { diff --git a/apps/restconf/restconf_lib.c b/apps/restconf/restconf_lib.c index 161d80bc..ec6689c4 100644 --- a/apps/restconf/restconf_lib.c +++ b/apps/restconf/restconf_lib.c @@ -471,20 +471,12 @@ api_return_err(clicon_handle h, return retval; } -/*! Clean and close all state of restconf process (but dont exit). - * Cannot use h after this - * @param[in] h Clixon handle - */ int restconf_terminate(clicon_handle h) { yang_spec *yspec; cxobj *x; - int fs; /* fgcx socket */ - clicon_debug(1, "%s", __FUNCTION__); - if ((fs = clicon_socket_get(h)) != -1) - close(fs); clixon_plugin_exit(h); rpc_callback_delete_all(); clicon_rpc_close_session(h); @@ -498,4 +490,3 @@ restconf_terminate(clicon_handle h) clicon_log_exit(); return 0; } - diff --git a/apps/restconf/restconf_main.c b/apps/restconf/restconf_main.c index dc21b5aa..f4de845a 100644 --- a/apps/restconf/restconf_main.c +++ b/apps/restconf/restconf_main.c @@ -694,8 +694,6 @@ main(int argc, clicon_err(OE_CFG, errno, "FCGX_OpenSocket"); goto done; } - if (clicon_socket_set(h, sock) < 0) - goto done; /* umask settings may interfer: we want group to write: this is 774 */ if (chmod(sockpath, S_IRWXU|S_IRWXG|S_IROTH) < 0){ clicon_err(OE_UNIX, errno, "chmod"); diff --git a/docker/Makefile.in b/docker/Makefile.in index 51443a4e..b7711d98 100644 --- a/docker/Makefile.in +++ b/docker/Makefile.in @@ -44,38 +44,23 @@ SUBDIRS = base SUBDIRS += system #SUBDIRS += cluster -.PHONY: all clean distclean depend install-include install uninstall test $(SUBDIRS) +.PHONY: all clean distclean depend install-include install uninstall test all: $(SUBDIRS) -$(SUBDIRS): - (cd $@; $(MAKE) $(MFLAGS) all) - clean: - for i in $(SUBDIRS); \ - do (cd $$i; $(MAKE) $(MFLAGS) $@); done distclean: clean rm -f Makefile *~ .depend - for i in $(SUBDIRS); \ - do (cd $$i; $(MAKE) $(MFLAGS) $@); done test: - for i in $(SUBDIRS); \ - do (cd $$i; $(MAKE) $(MFLAGS) $@); done + (cd system && $(MAKE) $(MFLAGS) test) depend: - for i in $(SUBDIRS); \ - do (cd $$i; $(MAKE) $(MFLAGS) $@); done install-include: - for i in $(SUBDIRS); \ - do (cd $$i && $(MAKE) $(MFLAGS) $@||exit 1); done; install: - for i in $(SUBDIRS); \ - do (cd $$i && $(MAKE) $(MFLAGS) $@)||exit 1; done uninstall: - for i in $(SUBDIRS); \ - do (cd $$i; $(MAKE) $(MFLAGS) $@)||exit 1; done + diff --git a/lib/clixon/clixon_options.h b/lib/clixon/clixon_options.h index cefc0f6b..4168b9ed 100644 --- a/lib/clixon/clixon_options.h +++ b/lib/clixon/clixon_options.h @@ -198,8 +198,4 @@ int clicon_xmldb_handle_set(clicon_handle h, void *xh); char *clicon_username_get(clicon_handle h); int clicon_username_set(clicon_handle h, void *username); -/* Set and get socket fd (ie backend server socket / restconf fcgx socket */ -int clicon_socket_get(clicon_handle h); -int clicon_socket_set(clicon_handle h, int s); - #endif /* _CLIXON_OPTIONS_H_ */ diff --git a/lib/src/clixon_handle.c b/lib/src/clixon_handle.c index 2951de31..45a53ebe 100644 --- a/lib/src/clixon_handle.c +++ b/lib/src/clixon_handle.c @@ -66,17 +66,6 @@ * @note If you change here, you must also change the structs below: * @see struct cli_handle * @see struct backend_handle - * This is the internal definition of a "Clixon handle" which in its external - * form is "clicon_handle" and is used in most Clixon API calls. - * Some details: - * 1) the internal structure contains a header (defined here) whereas higher - * order libs (eg cli and backend) introduce more fields appended to this - * struct. - * 2) ch_options accessed via clicon_data() are clixon config options are - * string values appearing in the XML configfile accessed with -f. - * Alternatively, these could be accessed via clicon_conf_xml() - * 3) ch_data accessed via clicon_data() is more general purpose for any data. - * that is, not only strings. And has separate namespace from options. */ struct clicon_handle { int ch_magic; /* magic (HDR) */ diff --git a/lib/src/clixon_hash.c b/lib/src/clixon_hash.c index 69f5fce2..4769abfa 100644 --- a/lib/src/clixon_hash.c +++ b/lib/src/clixon_hash.c @@ -202,7 +202,7 @@ hash_value(clicon_hash_t *hash, * * @param[in] hash Hash table * @param[in] key Variable name - * @param[in] val Variable value (pointer to) + * @param[in] val Variable value * @param[in] vlen Length of variable value * @retval variable New hash structure on success * @retval NULL Failure diff --git a/lib/src/clixon_json.c b/lib/src/clixon_json.c index 88b2d8ae..4b412e20 100644 --- a/lib/src/clixon_json.c +++ b/lib/src/clixon_json.c @@ -224,6 +224,7 @@ json_str_escape_cdata(cbuf *cb, char *str) { int retval = -1; + char *snew = NULL; int i; int esc = 0; /* cdata escape */ @@ -260,8 +261,12 @@ json_str_escape_cdata(cbuf *cb, cprintf(cb, "%c", str[i]); break; } + if ((snew = strdup(cbuf_get(cb))) ==NULL){ + clicon_err(OE_XML, errno, "strdup"); + goto done; + } retval = 0; - // done: + done: return retval; } diff --git a/lib/src/clixon_options.c b/lib/src/clixon_options.c index 24b5c309..2ef5b7e6 100644 --- a/lib/src/clixon_options.c +++ b/lib/src/clixon_options.c @@ -32,12 +32,7 @@ ***** END LICENSE BLOCK ***** * - * This file contains access functions for two types of clixon vars: - * - options, ie string based variables from Clixon configuration files. - * Accessed with clicon_options(h). - * - data. Free-typed values for runtime getting and setting. - * Accessed with clicon_data(h). - * Consider splitting? + * CLICON options */ #ifdef HAVE_CONFIG_H #include "clixon_config.h" /* generated by config & autoconf */ @@ -364,8 +359,6 @@ clicon_option_str(clicon_handle h, * @param[in] h clicon_handle * @param[in] name option name * @param[in] val option value, must be null-terminated string - * @retval 0 OK - * @retval -1 Error */ int clicon_option_str_set(clicon_handle h, @@ -751,7 +744,7 @@ clicon_conf_xml(clicon_handle h) return NULL; } -/*! Set YANG specification for Clixon system options and features + /*! Set YANG specification for Clixon system options and features * ys must be a malloced pointer */ int @@ -890,35 +883,3 @@ clicon_username_set(clicon_handle h, } -/*! Get socket fd (ie backend server socket / restconf fcgx socket) - * @param[in] h Clicon handle - * @retval -1 No open socket - * @retval s Socket - */ -int -clicon_socket_get(clicon_handle h) -{ - clicon_hash_t *cdat = clicon_data(h); - void *p; - - if ((p = hash_value(cdat, "socket", NULL)) == NULL) - return -1; - return *(int*)p; -} - -/*! Set socket fd (ie backend server socket / restconf fcgx socket) - * @param[in] h Clicon handle - * @param[in] s Open socket (or -1 to close) - * @retval 0 OK - * @retval -1 Error - */ -int -clicon_socket_set(clicon_handle h, - int s) -{ - clicon_hash_t *cdat = clicon_data(h); - - if (s == -1) - return hash_del(cdat, "socket"); - return hash_add(cdat, "socket", &s, sizeof(int))==NULL?-1:0; -} diff --git a/test/README.md b/test/README.md index cb41e85f..1d147dd2 100644 --- a/test/README.md +++ b/test/README.md @@ -57,7 +57,7 @@ These tests use valgrind to check for memory leaks: mem.sh cli mem.sh netconf mem.sh backend - mem.sh restconf +# mem.sh restconf # NYI ``` ## Site.sh diff --git a/test/valgrind-clixon.supp b/test/clixon.supp similarity index 65% rename from test/valgrind-clixon.supp rename to test/clixon.supp index 80d26160..c2201ab3 100644 --- a/test/valgrind-clixon.supp +++ b/test/clixon.supp @@ -1,12 +1,12 @@ { - supp1 + supp2 Memcheck:Leak match-leak-kinds: reachable fun:* fun:_dl_new_object } { - supp2 + supp3 Memcheck:Leak match-leak-kinds: reachable fun:* @@ -14,31 +14,16 @@ fun:expand_dynamic_string_token } { - supp3 + supp44 Memcheck:Leak match-leak-kinds: reachable fun:* fun:_dlerror_run } { - supp4 + supp5 Memcheck:Leak match-leak-kinds: reachable fun:* fun:_dl_check_map_versions } -{ - supp5 - Memcheck:Leak - match-leak-kinds: reachable - fun:* - fun:* - fun:_dl_map_object -} -{ - supp6-fcgi - Memcheck:Leak - match-leak-kinds: reachable - fun:* - fun:OS_LibInit -} diff --git a/test/lib.sh b/test/lib.sh index d17f5891..8e3cd52f 100755 --- a/test/lib.sh +++ b/test/lib.sh @@ -52,9 +52,8 @@ testname= # : ${valgrindtest=0} -# Valgrind log file. This should be removed automatically. Note that mktemp -# actually creates a file so do not call it by default -#: ${valgrindfile=$(mktemp)} +# Valgrind log file. This is usually removed automatically +: ${valgrindfile=$(mktemp)} # If set to 0, override starting of clixon_backend in test (you bring your own) : ${BE:=1} @@ -136,9 +135,9 @@ start_backend(){ if [ $valgrindtest -eq 2 ]; then # Start in background since daemon version creates two traces: parent, # child. If background then only the single relevant. - sudo $clixon_backend -F -D $DBG $* & + sudo $clixon_backend -F $* -D $DBG & else - sudo $clixon_backend -D $DBG $* + sudo $clixon_backend $* -D $DBG fi if [ $? -ne 0 ]; then err @@ -156,22 +155,6 @@ stop_backend(){ fi } -start_restconf(){ - # Start in background - sudo su -c "$clixon_restconf $RCLOG -D $DBG $*" -s /bin/sh www-data & - if [ $? -ne 0 ]; then - err - fi -} - -stop_restconf(){ - sudo pkill -u www-data -f "/www-data/clixon_restconf" - if [ $valgrindtest -eq 3 ]; then - sleep 1 - checkvalgrind - fi -} - # Increment test number and print a nice string new(){ if [ $valgrindtest -eq 1 ]; then diff --git a/test/mem.sh b/test/mem.sh index e570d96d..4c2e45f8 100755 --- a/test/mem.sh +++ b/test/mem.sh @@ -15,12 +15,12 @@ case "$PROGRAM" in 'cli') valgrindtest=1 RCWAIT=1 - clixon_cli="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_cli" + clixon_cli="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./clixon.supp --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_cli" ;; 'netconf') valgrindtest=1 RCWAIT=1 - clixon_netconf="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_netconf" + clixon_netconf="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./clixon.supp --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_netconf" ;; 'backend') valgrindtest=2 # This means backend valgrind test @@ -28,19 +28,10 @@ case "$PROGRAM" in perfnr=100 # test_perf.sh restconf put more or less stops perfreq=10 - clixon_backend="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=yes --log-file=$valgrindfile clixon_backend" -;; - 'restconf') - valgrindtest=3 # This means backend valgrind test - sudo chmod 660 $valgrindfile - sudo chown www-data $valgrindfile - RCWAIT=5 # valgrind restconf needs some time to get up - clixon_restconf="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile /www-data/clixon_restconf" - + clixon_backend="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./clixon.supp --track-fds=yes --trace-children=yes --log-file=$valgrindfile clixon_backend" ;; *) echo "usage: $0 cli|netconf|restconf|backend" # valgrind memleak checks - rm -f $valgrindfile exit -1 ;; esac diff --git a/test/test_choice.sh b/test/test_choice.sh index 53d2a4ea..37d05cc3 100755 --- a/test/test_choice.sh +++ b/test/test_choice.sh @@ -106,7 +106,7 @@ new "kill old restconf daemon" sudo pkill -u www-data clixon_restconf new "start restconf daemon" -start_restconf -f $cfg -y $fyang +sudo su -c "$clixon_restconf -f $RCLOG $cfg -y $fyang -D $DBG" -s /bin/sh www-data & new "waiting" sleep $RCWAIT @@ -194,7 +194,7 @@ new "netconf validate mandatory" expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" new "Kill restconf daemon" -stop_restconf +sudo pkill -u www-data -f "/www-data/clixon_restconf" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_nacm.sh b/test/test_nacm.sh index caba05e3..37a971cf 100755 --- a/test/test_nacm.sh +++ b/test/test_nacm.sh @@ -127,7 +127,7 @@ sudo pkill -u www-data -f "/www-data/clixon_restconf" sleep 1 new "start restconf daemon (-a is enable basic authentication)" -start_restconf -f $cfg -- -a +sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG -- -a" -s /bin/sh www-data & new "waiting" sleep $RCWAIT @@ -178,7 +178,7 @@ new "guest edit nacm" expecteq "$(curl -u guest:bar -sS -X PUT -d '{"nacm-example:x": 3}' http://localhost/restconf/data/nacm-example:x)" 0 '{"ietf-restconf:errors" : {"error": {"error-type": "application","error-tag": "access-denied","error-severity": "error","error-message": "access denied"}}} ' new "Kill restconf daemon" -stop_restconf +sudo pkill -u www-data -f "/www-data/clixon_restconf" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_nacm_ext.sh b/test/test_nacm_ext.sh index 072d0049..ef3742f0 100755 --- a/test/test_nacm_ext.sh +++ b/test/test_nacm_ext.sh @@ -146,7 +146,7 @@ new "kill old restconf daemon" sudo pkill -u www-data -f "/www-data/clixon_restconf" new "start restconf daemon (-a is enable http basic auth)" -start_restconf -f $cfg -- -a +sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG -- -a" -s /bin/sh www-data & new "waiting" sleep $RCWAIT @@ -207,7 +207,7 @@ new "cli rpc as guest" expectfn "$clixon_cli -1 -U guest -l o -f $cfg rpc ipv4" 255 "protocol access-denied access denied" new "Kill restconf daemon" -stop_restconf +sudo pkill -u www-data -f "/www-data/clixon_restconf" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_nacm_module_read.sh b/test/test_nacm_module_read.sh index b18e3540..5624cb44 100755 --- a/test/test_nacm_module_read.sh +++ b/test/test_nacm_module_read.sh @@ -142,7 +142,7 @@ sudo pkill -u www-data -f "/www-data/clixon_restconf" sleep 1 new "start restconf daemon (-a is enable basic authentication)" -start_restconf -f $cfg -- -a +sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG -- -a" -s /bin/sh www-data & new "waiting" sleep $RCWAIT @@ -272,8 +272,7 @@ expecteq "$(curl -u guest:bar -sS -X GET http://localhost/restconf/data/clixon-e new "Kill restconf daemon" -stop_restconf - +sudo pkill -u www-data -f "/www-data/clixon_restconf" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_nacm_module_write.sh b/test/test_nacm_module_write.sh index 53bf1da3..3462fd3f 100755 --- a/test/test_nacm_module_write.sh +++ b/test/test_nacm_module_write.sh @@ -150,7 +150,7 @@ sudo pkill -u www-data -f "/www-data/clixon_restconf" sleep 1 new "start restconf daemon (-a is enable basic authentication)" -start_restconf -f $cfg -- -a +sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG -- -a" -s /bin/sh www-data & new "waiting" sleep $RCWAIT @@ -254,7 +254,7 @@ new "default delete list deny" expecteq "$(curl -u wilma:bar -sS -X DELETE http://localhost/restconf/data/clixon-example:translate=key42)" 0 '{"ietf-restconf:errors" : {"error": {"error-type": "application","error-tag": "access-denied","error-severity": "error","error-message": "default deny"}}} ' new "Kill restconf daemon" -stop_restconf +sudo pkill -u www-data -f "/www-data/clixon_restconf" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_nacm_protocol.sh b/test/test_nacm_protocol.sh index 2a4487f0..a918511b 100755 --- a/test/test_nacm_protocol.sh +++ b/test/test_nacm_protocol.sh @@ -150,7 +150,7 @@ sudo pkill -u www-data -f "/www-data/clixon_restconf" sleep 1 new "start restconf daemon (-a is enable basic authentication)" -start_restconf -f $cfg -- -a +sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG -- -a" -s /bin/sh www-data & new "waiting" sleep $RCWAIT @@ -216,7 +216,7 @@ new "permit-edit-config: guest fail restconf" expecteq "$(curl -u guest:bar -sS -X PUT -d '{"nacm-example:x": 2}' http://localhost/restconf/data/nacm-example:x)" 0 '{"ietf-restconf:errors" : {"error": {"error-type": "application","error-tag": "access-denied","error-severity": "error","error-message": "default deny"}}} ' new "Kill restconf daemon" -stop_restconf +sudo pkill -u www-data -f "/www-data/clixon_restconf" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_perf.sh b/test/test_perf.sh index 89985e0b..1bb88806 100755 --- a/test/test_perf.sh +++ b/test/test_perf.sh @@ -70,7 +70,7 @@ new "kill old restconf daemon" sudo pkill -u www-data -f "/www-data/clixon_restconf" new "start restconf daemon" -start_restconf -f $cfg -y $fyang +sudo su -c "$clixon_restconf -f $cfg -y $fyang $RCLOG -D $DBG" -s /bin/sh www-data & new "waiting" sleep $RCWAIT @@ -169,7 +169,7 @@ new "netconf get large leaf-list config" expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^01' new "Kill restconf daemon" -stop_restconf +sudo pkill -u www-data -f "/www-data/clixon_restconf" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_restconf.sh b/test/test_restconf.sh index 84ed9212..43c5c96b 100755 --- a/test/test_restconf.sh +++ b/test/test_restconf.sh @@ -51,7 +51,7 @@ new "kill old restconf daemon" sudo pkill -u www-data clixon_restconf new "start restconf daemon" -start_restconf -f $cfg +sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG" -s /bin/sh www-data & new "waiting" sleep $RCWAIT @@ -265,7 +265,7 @@ if [ -z "$match" ]; then fi new "Kill restconf daemon" -stop_restconf +sudo pkill -u www-data -f "/www-data/clixon_restconf" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_restconf2.sh b/test/test_restconf2.sh index e4e8de20..54d1ae3a 100755 --- a/test/test_restconf2.sh +++ b/test/test_restconf2.sh @@ -83,7 +83,7 @@ new "kill old restconf daemon" sudo pkill -u www-data -f "/www-data/clixon_restconf" new "start restconf daemon" -start_restconf -f $cfg -y $fyang +sudo su -c "$clixon_restconf -f $cfg -y $fyang $RCLOG -D $DBG" -s /bin/sh www-data & new "waiting" sleep $RCWAIT @@ -182,7 +182,7 @@ new "restconf POST type x3" expectfn 'curl -s -X GET http://localhost/restconf/data/example:types' 0 '{"example:types": {"tint": 42,"tdec64": 42.123,"tbool": false,"tstr": "str"}}' new "Kill restconf daemon" -stop_restconf +sudo pkill -u www-data -f "/www-data/clixon_restconf" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_rpc.sh b/test/test_rpc.sh index 084c136e..af543edc 100755 --- a/test/test_rpc.sh +++ b/test/test_rpc.sh @@ -48,7 +48,7 @@ new "kill old restconf daemon" sudo pkill -u www-data clixon_restconf new "start restconf daemon" -start_restconf -f $cfg +sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG" -s /bin/sh www-data & new "waiting" sleep $RCWAIT @@ -149,7 +149,7 @@ new "netconf edit-config missing config should fail" expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^applicationdata-missingmissing-choiceedit-contenterror]]>]]>$' new "Kill restconf daemon" -stop_restconf +sudo pkill -u www-data -f "/www-data/clixon_restconf" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_stream.sh b/test/test_stream.sh index e04a2041..e9613887 100755 --- a/test/test_stream.sh +++ b/test/test_stream.sh @@ -118,7 +118,7 @@ new "kill old restconf daemon" sudo pkill -u www-data -f "/www-data/clixon_restconf" new "start restconf daemon" -start_restconf -f $cfg -y $fyang +sudo su -c "$clixon_restconf -f $cfg -y $fyang $RCLOG -D $DBG" -s /bin/sh www-data & new "waiting" sleep $RCWAIT @@ -274,7 +274,7 @@ echo "Eg: curl -H \"Accept: text/event-stream\" -s -X GET http://localhost/sub/E #----------------- sleep 5 new "Kill restconf daemon" -stop_restconf +sudo pkill -u www-data -f "/www-data/clixon_restconf" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_yang_namespace.sh b/test/test_yang_namespace.sh index 7e73b145..d0f78a05 100755 --- a/test/test_yang_namespace.sh +++ b/test/test_yang_namespace.sh @@ -82,10 +82,7 @@ new "kill old restconf daemon" sudo pkill -u www-data clixon_restconf new "start restconf daemon" -start_restconf -f $cfg - -new "waiting" -sleep $RCWAIT +sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG" -s /bin/sh www-data & new "netconf set x in example1" expecteof "$clixon_netconf -qf $cfg" 0 '42]]>]]>' '^]]>]]>$' @@ -131,7 +128,7 @@ if [ -z "$match" ]; then fi new "Kill restconf daemon" -stop_restconf +sudo pkill -u www-data -f "/www-data/clixon_restconf" if [ $BE -eq 0 ]; then exit # BE