Demon->Daemon, FreeBSD grep changes

This commit is contained in:
Olof Hagsand 2019-10-14 07:47:08 -10:00
parent 734f65e25a
commit 77b491c568
15 changed files with 54 additions and 51 deletions

View file

@ -10,6 +10,7 @@
* If dropped temporary, you can restore privileges with `restore_priv()` * If dropped temporary, you can restore privileges with `restore_priv()`
### API changes on existing features (you may need to change your code) ### API changes on existing features (you may need to change your code)
* In logs and debug changed "Demon error" to "Daemon error".
* Stricter handling of multi-namespace handling * Stricter handling of multi-namespace handling
* This occurs in cases where there are more than one XML namespaces in a config tree, such as `augment`:ed trees. * This occurs in cases where there are more than one XML namespaces in a config tree, such as `augment`:ed trees.
* Affects all parts of the system, including datastore, backend, restconf and cli. * Affects all parts of the system, including datastore, backend, restconf and cli.

View file

@ -273,19 +273,19 @@ check_drop_priv(clicon_handle h,
/* From here, drop privileges */ /* From here, drop privileges */
/* Check backend user exists */ /* Check backend user exists */
if ((backend_user = clicon_backend_user(h)) == NULL){ if ((backend_user = clicon_backend_user(h)) == NULL){
clicon_err(OE_DEMON, EPERM, "Privileges cannot be dropped without specifying CLICON_BACKEND_USER\n"); clicon_err(OE_DAEMON, EPERM, "Privileges cannot be dropped without specifying CLICON_BACKEND_USER\n");
goto done; goto done;
} }
/* Get (wanted) new backend user id */ /* Get (wanted) new backend user id */
if (name2uid(backend_user, &newuid) < 0){ if (name2uid(backend_user, &newuid) < 0){
clicon_err(OE_DEMON, errno, "'%s' is not a valid user .\n", backend_user); clicon_err(OE_DAEMON, errno, "'%s' is not a valid user .\n", backend_user);
goto done; goto done;
} }
/* get current backend userid, if already at this level OK */ /* get current backend userid, if already at this level OK */
if ((uid = getuid()) == newuid) if ((uid = getuid()) == newuid)
goto ok; goto ok;
if (uid != 0){ if (uid != 0){
clicon_err(OE_DEMON, EPERM, "Privileges can only be dropped from root user (uid is %u)\n", uid); clicon_err(OE_DAEMON, EPERM, "Privileges can only be dropped from root user (uid is %u)\n", uid);
goto done; goto done;
} }
/* When dropping priveleges, datastores are created if they do not exist. /* When dropping priveleges, datastores are created if they do not exist.
@ -309,7 +309,7 @@ check_drop_priv(clicon_handle h,
goto done; goto done;
if (setgid(gid) == -1) { if (setgid(gid) == -1) {
clicon_err(OE_DEMON, errno, "setgid %d", gid); clicon_err(OE_DAEMON, errno, "setgid %d", gid);
goto done; goto done;
} }
switch (priv_mode){ switch (priv_mode){
@ -318,7 +318,7 @@ check_drop_priv(clicon_handle h,
goto done; goto done;
/* Verify you cannot regain root privileges */ /* Verify you cannot regain root privileges */
if (setuid(0) != -1){ if (setuid(0) != -1){
clicon_err(OE_DEMON, EPERM, "Could regain root privilieges"); clicon_err(OE_DAEMON, EPERM, "Could regain root privilieges");
goto done; goto done;
} }
break; break;
@ -652,7 +652,7 @@ main(int argc,
} }
else else
if (pid){ if (pid){
clicon_err(OE_DEMON, 0, "Daemon already running with pid %d\n(Try killing it with %s -z)", clicon_err(OE_DAEMON, 0, "Daemon already running with pid %d\n(Try killing it with %s -z)",
pid, argv0); pid, argv0);
return -1; /* goto done deletes pidfile */ return -1; /* goto done deletes pidfile */
} }
@ -866,11 +866,11 @@ main(int argc,
clicon_log(LOG_NOTICE, "%s: %u Started", __PROGRAM__, getpid()); clicon_log(LOG_NOTICE, "%s: %u Started", __PROGRAM__, getpid());
if (set_signal(SIGTERM, backend_sig_term, NULL) < 0){ if (set_signal(SIGTERM, backend_sig_term, NULL) < 0){
clicon_err(OE_DEMON, errno, "Setting signal"); clicon_err(OE_DAEMON, errno, "Setting signal");
goto done; goto done;
} }
if (set_signal(SIGINT, backend_sig_term, NULL) < 0){ if (set_signal(SIGINT, backend_sig_term, NULL) < 0){
clicon_err(OE_DEMON, errno, "Setting signal"); clicon_err(OE_DAEMON, errno, "Setting signal");
goto done; goto done;
} }

View file

@ -626,15 +626,15 @@ main(int argc,
clicon_debug_init(debug, NULL); clicon_debug_init(debug, NULL);
clicon_log(LOG_NOTICE, "%s: %u Started", __PROGRAM__, getpid()); clicon_log(LOG_NOTICE, "%s: %u Started", __PROGRAM__, getpid());
if (set_signal(SIGTERM, restconf_sig_term, NULL) < 0){ if (set_signal(SIGTERM, restconf_sig_term, NULL) < 0){
clicon_err(OE_DEMON, errno, "Setting signal"); clicon_err(OE_DAEMON, errno, "Setting signal");
goto done; goto done;
} }
if (set_signal(SIGINT, restconf_sig_term, NULL) < 0){ if (set_signal(SIGINT, restconf_sig_term, NULL) < 0){
clicon_err(OE_DEMON, errno, "Setting signal"); clicon_err(OE_DAEMON, errno, "Setting signal");
goto done; goto done;
} }
if (set_signal(SIGCHLD, restconf_sig_child, NULL) < 0){ if (set_signal(SIGCHLD, restconf_sig_child, NULL) < 0){
clicon_err(OE_DEMON, errno, "Setting signal"); clicon_err(OE_DAEMON, errno, "Setting signal");
goto done; goto done;
} }

View file

@ -56,7 +56,7 @@ $(SUBDIRS):
install: install:
for i in $(SUBDIRS); \ for i in $(SUBDIRS); \
do (cd $$i && $(MAKE) $(MFLAGS) $@); done do (cd $$i && $(MAKE) $(MFLAGS) $@)||exit 1; done
install-include: install-include:
for i in $(SUBDIRS); \ for i in $(SUBDIRS); \
@ -72,12 +72,12 @@ config.status: configure
clean: clean:
for i in $(SUBDIRS); \ for i in $(SUBDIRS); \
do (cd $$i; $(MAKE) $(MFLAGS) clean); done do (cd $$i; $(MAKE) $(MFLAGS) $@)||exit 1; done
distclean: clean distclean: clean
rm -f Makefile *~ .depend rm -f Makefile *~ .depend
for i in $(SUBDIRS); \ for i in $(SUBDIRS); \
do (cd $$i; $(MAKE) $(MFLAGS) distclean); done; \ do (cd $$i; $(MAKE) $(MFLAGS) $@)||exit 1; done; \
(cd clixon; $(MAKE) $(MFLAGS) $@) (cd clixon; $(MAKE) $(MFLAGS) $@)
TAGS: TAGS:

View file

@ -58,7 +58,7 @@
enum clicon_err{ enum clicon_err{
/* 0 means error not set) */ /* 0 means error not set) */
OE_DB = 1, /* database registries */ OE_DB = 1, /* database registries */
OE_DEMON, /* demons: pidfiles, etc */ OE_DAEMON, /* demons: pidfiles, etc */
OE_EVENTS, /* events, filedescriptors, timeouts */ OE_EVENTS, /* events, filedescriptors, timeouts */
OE_CFG, /* configuration */ OE_CFG, /* configuration */
OE_PROTO, /* config/client communication */ OE_PROTO, /* config/client communication */

View file

@ -85,7 +85,7 @@ char clicon_err_reason[ERR_STRLEN] = {0, };
*/ */
static struct errvec EV[] = { static struct errvec EV[] = {
{"Database error", OE_DB}, {"Database error", OE_DB},
{"Demon error", OE_DEMON}, {"Daemon error", OE_DAEMON},
{"Event error", OE_EVENTS}, {"Event error", OE_EVENTS},
{"Config error", OE_CFG}, {"Config error", OE_CFG},
{"Protocol error", OE_PROTO}, {"Protocol error", OE_PROTO},

View file

@ -165,7 +165,7 @@ pidfile_zapold(pid_t pid)
if ((kill (pid, 0)) != 0 && errno == ESRCH) /* Nothing there */ if ((kill (pid, 0)) != 0 && errno == ESRCH) /* Nothing there */
; ;
else{ /* problem: couldnt kill it */ else{ /* problem: couldnt kill it */
clicon_err(OE_DEMON, errno, "Killing old demon"); clicon_err(OE_DAEMON, errno, "Killing old demon");
return -1; return -1;
} }
return 0; return 0;
@ -184,13 +184,13 @@ pidfile_write(char *pidfile)
/* Here, there should be no old agent and no pidfile */ /* Here, there should be no old agent and no pidfile */
if ((f = fopen(pidfile, "w")) == NULL){ if ((f = fopen(pidfile, "w")) == NULL){
if (errno == EACCES) if (errno == EACCES)
clicon_err(OE_DEMON, errno, "Creating pid-file %s (Try run as root?)", pidfile); clicon_err(OE_DAEMON, errno, "Creating pid-file %s (Try run as root?)", pidfile);
else else
clicon_err(OE_DEMON, errno, "Creating pid-file %s", pidfile); clicon_err(OE_DAEMON, errno, "Creating pid-file %s", pidfile);
goto done; goto done;
} }
if ((retval = fprintf(f, "%ld\n", (long) getpid())) < 1){ if ((retval = fprintf(f, "%ld\n", (long) getpid())) < 1){
clicon_err(OE_DEMON, errno, "Could not write pid to %s", pidfile); clicon_err(OE_DAEMON, errno, "Could not write pid to %s", pidfile);
goto done; goto done;
} }
clicon_debug(1, "Opened pidfile %s with pid %d", pidfile, getpid()); clicon_debug(1, "Opened pidfile %s with pid %d", pidfile, getpid());

View file

@ -78,9 +78,8 @@ You may add your site-specific modifications in a `site.sh` file. Example:
IETFRFC=$YANGMODELS/standard/ietf/RFC IETFRFC=$YANGMODELS/standard/ietf/RFC
``` ```
## FreeBSD For example, in FreeBSD, add:
```
To run on freebsd: wwwuser=www
make=gmake
``` ```
wwwuser=www clixon_restconf=/usr/local/sbin/clixon_restconf ./all.sh
```

View file

@ -123,14 +123,14 @@ EOF
new "netconf modules-state header" new "netconf modules-state header"
expect='^<rpc-reply><data><modules-state xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library"><module><name>' expect='^<rpc-reply><data><modules-state xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library"><module><name>'
match=`echo "$ret" | grep -GZo "$expect"` match=`echo "$ret" | grep --null -Go "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi
new "netconf module A" new "netconf module A"
expect="<module><name>example</name><revision/><namespace>urn:example:clixon</namespace><feature>A</feature><conformance-type>implement</conformance-type></module>" expect="<module><name>example</name><revision/><namespace>urn:example:clixon</namespace><feature>A</feature><conformance-type>implement</conformance-type></module>"
match=`echo "$ret" | grep -GZo "$expect"` match=`echo "$ret" | grep --null -Go "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi
@ -138,7 +138,7 @@ fi
if false ; then # clixon "config" bug if false ; then # clixon "config" bug
new "netconf module clixon-config" new "netconf module clixon-config"
expect="<module><name>clixon-config</name><revision>2018-09-30</revision><namespace/></module>" expect="<module><name>clixon-config</name><revision>2018-09-30</revision><namespace/></module>"
match=`echo "$ret" | grep -GZo "$expect"` match=`echo "$ret" | grep --null -Go "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi
@ -146,14 +146,14 @@ fi # false
new "netconf module ietf-inet-types" new "netconf module ietf-inet-types"
expect="<module><name>ietf-inet-types</name><revision>2013-07-15</revision><namespace>urn:ietf:params:xml:ns:yang:ietf-inet-types</namespace><conformance-type>implement</conformance-type></module>" expect="<module><name>ietf-inet-types</name><revision>2013-07-15</revision><namespace>urn:ietf:params:xml:ns:yang:ietf-inet-types</namespace><conformance-type>implement</conformance-type></module>"
match=`echo "$ret" | grep -GZo "$expect"` match=`echo "$ret" | grep --null -Go "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi
new "netconf module ietf-interfaces" new "netconf module ietf-interfaces"
expect="<module><name>ietf-interfaces</name><revision>2018-02-20</revision><namespace>urn:ietf:params:xml:ns:yang:ietf-interfaces</namespace><conformance-type>implement</conformance-type></module>" expect="<module><name>ietf-interfaces</name><revision>2018-02-20</revision><namespace>urn:ietf:params:xml:ns:yang:ietf-interfaces</namespace><conformance-type>implement</conformance-type></module>"
match=`echo "$ret" | grep -GZo "$expect"` match=`echo "$ret" | grep --null -Go "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi
@ -161,26 +161,26 @@ fi
# Note order of features in ietf-netconf yang is alphabetically: candidate, startup, validate, xpath # Note order of features in ietf-netconf yang is alphabetically: candidate, startup, validate, xpath
new "netconf module ietf-netconf" new "netconf module ietf-netconf"
expect="<module><name>ietf-netconf</name><revision>2011-06-01</revision><namespace>urn:ietf:params:xml:ns:netconf:base:1.0</namespace><feature>candidate</feature><feature>validate</feature><feature>xpath</feature><conformance-type>implement</conformance-type></module>" expect="<module><name>ietf-netconf</name><revision>2011-06-01</revision><namespace>urn:ietf:params:xml:ns:netconf:base:1.0</namespace><feature>candidate</feature><feature>validate</feature><feature>xpath</feature><conformance-type>implement</conformance-type></module>"
match=`echo "$ret" | grep -GZo "$expect"` match=`echo "$ret" | grep --null -Go "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi
new "netconf module ietf-routing" new "netconf module ietf-routing"
expect="<module><name>ietf-routing</name><revision>2018-03-13</revision><namespace>urn:ietf:params:xml:ns:yang:ietf-routing</namespace><feature>router-id</feature><conformance-type>implement</conformance-type></module>" expect="<module><name>ietf-routing</name><revision>2018-03-13</revision><namespace>urn:ietf:params:xml:ns:yang:ietf-routing</namespace><feature>router-id</feature><conformance-type>implement</conformance-type></module>"
match=`echo "$ret" | grep -GZo "$expect"` match=`echo "$ret" | grep --null -Go "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi
expect="<module><name>ietf-yang-library</name><revision>2016-06-21</revision><namespace>urn:ietf:params:xml:ns:yang:ietf-yang-library</namespace><conformance-type>implement</conformance-type></module>" expect="<module><name>ietf-yang-library</name><revision>2016-06-21</revision><namespace>urn:ietf:params:xml:ns:yang:ietf-yang-library</namespace><conformance-type>implement</conformance-type></module>"
match=`echo "$ret" | grep -GZo "$expect"` match=`echo "$ret" | grep --null -Go "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi
new "netconf module ietf-yang_types" new "netconf module ietf-yang_types"
expect="<module><name>ietf-yang-types</name><revision>2013-07-15</revision><namespace>urn:ietf:params:xml:ns:yang:ietf-yang-types</namespace><conformance-type>implement</conformance-type></module>" expect="<module><name>ietf-yang-types</name><revision>2013-07-15</revision><namespace>urn:ietf:params:xml:ns:yang:ietf-yang-types</namespace><conformance-type>implement</conformance-type></module>"
match=`echo "$ret" | grep -GZo "$expect"` match=`echo "$ret" | grep --null -Go "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi

View file

@ -4,10 +4,13 @@
# Magic line must be first in script (see README.md) # Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# Eg on FreeBSD use gmake
: ${make:=make}
new "Set up installdir $dir" new "Set up installdir $dir"
new "Make DESTDIR install" new "Make DESTDIR install ($dir)"
(cd ..; make DESTDIR=$dir install) (cd ..; $make DESTDIR=$dir install)
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
err err
fi fi
@ -33,7 +36,7 @@ if [ ! -h $dir/usr/local/lib/libclixon_backend.so ]; then
fi fi
new "Make DESTDIR install include" new "Make DESTDIR install include"
(cd ..; make DESTDIR=$dir install-include) (cd ..; $make DESTDIR=$dir install-include)
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
err err
fi fi
@ -42,7 +45,7 @@ if [ ! -f $dir/usr/local/include/clixon/clixon.h ]; then
err $dir/usr/local/include/clixon/clixon.h err $dir/usr/local/include/clixon/clixon.h
fi fi
new "Make DESTDIR uninstall" new "Make DESTDIR uninstall"
(cd ..; make DESTDIR=$dir uninstall) (cd ..; $make DESTDIR=$dir uninstall)
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
err err
fi fi

View file

@ -181,7 +181,7 @@ expecteq "$(curl -u andy:bar -sS -X GET http://localhost/restconf/data/clixon-ex
new "admin read top ok (all)" new "admin read top ok (all)"
ret=$(curl -u andy:bar -sS -X GET http://localhost/restconf/data) ret=$(curl -u andy:bar -sS -X GET http://localhost/restconf/data)
expect='{"data":{"nacm-example:x":42,"clixon-example:translate":' expect='{"data":{"nacm-example:x":42,"clixon-example:translate":'
match=`echo $ret | grep -EZo "$expect"` match=`echo $ret | grep --null -Eo "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi

View file

@ -80,7 +80,7 @@ expecteq "$(curl -sG http://localhost/restconf/operations)" 0 '{"operations":{"c
new "restconf get restconf/operations. RFC8040 3.3.2 (xml)" new "restconf get restconf/operations. RFC8040 3.3.2 (xml)"
ret=$(curl -s -H "Accept: application/yang-data+xml" -G http://localhost/restconf/operations) ret=$(curl -s -H "Accept: application/yang-data+xml" -G http://localhost/restconf/operations)
expect='<operations><client-rpc xmlns="urn:example:clixon"/><empty xmlns="urn:example:clixon"/><optional xmlns="urn:example:clixon"/><example xmlns="urn:example:clixon"/><debug xmlns="http://clicon.org/lib"/><ping xmlns="http://clicon.org/lib"/><get-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><edit-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><copy-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><delete-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><lock xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><unlock xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><get xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><close-session xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><kill-session xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><commit xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><discard-changes xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><validate xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><create-subscription xmlns="urn:ietf:params:xml:ns:netmod:notification"/></operations>' expect='<operations><client-rpc xmlns="urn:example:clixon"/><empty xmlns="urn:example:clixon"/><optional xmlns="urn:example:clixon"/><example xmlns="urn:example:clixon"/><debug xmlns="http://clicon.org/lib"/><ping xmlns="http://clicon.org/lib"/><get-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><edit-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><copy-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><delete-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><lock xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><unlock xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><get xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><close-session xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><kill-session xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><commit xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><discard-changes xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><validate xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><create-subscription xmlns="urn:ietf:params:xml:ns:netmod:notification"/></operations>'
match=`echo $ret | grep -EZo "$expect"` match=`echo $ret | grep --null -Eo "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi
@ -91,7 +91,7 @@ expecteq "$(curl -sG http://localhost/restconf/yang-library-version)" 0 '{"yang-
new "restconf get restconf/yang-library-version. RFC8040 3.3.3 (xml)" new "restconf get restconf/yang-library-version. RFC8040 3.3.3 (xml)"
ret=$(curl -s -H "Accept: application/yang-data+xml" -G http://localhost/restconf/yang-library-version) ret=$(curl -s -H "Accept: application/yang-data+xml" -G http://localhost/restconf/yang-library-version)
expect="<yang-library-version>2016-06-21</yang-library-version>" expect="<yang-library-version>2016-06-21</yang-library-version>"
match=`echo $ret | grep -EZo "$expect"` match=`echo $ret | grep --null -Eo "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi
@ -132,7 +132,7 @@ expectpart "$(curl -siSG http://localhost/restconf/data/badmodule:state)" 0 'HTT
new "restconf get empty config + state xml" new "restconf get empty config + state xml"
ret=$(curl -s -H "Accept: application/yang-data+xml" -G http://localhost/restconf/data/clixon-example:state) ret=$(curl -s -H "Accept: application/yang-data+xml" -G http://localhost/restconf/data/clixon-example:state)
expect='<state xmlns="urn:example:clixon"><op>42</op><op>41</op><op>43</op></state>' expect='<state xmlns="urn:example:clixon"><op>42</op><op>41</op><op>43</op></state>'
match=`echo $ret | grep -EZo "$expect"` match=`echo $ret | grep --null -Eo "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi
@ -145,7 +145,7 @@ new "restconf get state operation"
# Cant get shell macros to work, inline matching from lib.sh # Cant get shell macros to work, inline matching from lib.sh
ret=$(curl -s -H "Accept: application/yang-data+xml" -G http://localhost/restconf/data/clixon-example:state/op=42) ret=$(curl -s -H "Accept: application/yang-data+xml" -G http://localhost/restconf/data/clixon-example:state/op=42)
expect='<op xmlns="urn:example:clixon">42</op>' expect='<op xmlns="urn:example:clixon">42</op>'
match=`echo $ret | grep -EZo "$expect"` match=`echo $ret | grep --null -Eo "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi
@ -158,7 +158,7 @@ new "restconf get state operation type xml"
# Cant get shell macros to work, inline matching from lib.sh # Cant get shell macros to work, inline matching from lib.sh
ret=$(curl -s -H "Accept: application/yang-data+xml" -G http://localhost/restconf/data/clixon-example:state/op=42) ret=$(curl -s -H "Accept: application/yang-data+xml" -G http://localhost/restconf/data/clixon-example:state/op=42)
expect='<op xmlns="urn:example:clixon">42</op>' expect='<op xmlns="urn:example:clixon">42</op>'
match=`echo $ret | grep -EZo "$expect"` match=`echo $ret | grep --null -Eo "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi
@ -250,7 +250,7 @@ expecteq "$(curl -s -X POST -H "Content-Type: application/yang-data+json" -d '{}
new "restconf rpc using POST xml" new "restconf rpc using POST xml"
ret=$(curl -s -X POST -H "Content-Type: application/yang-data+json" -H "Accept: application/yang-data+xml" -d '{"clixon-example:input":{"x":42}}' http://localhost/restconf/operations/clixon-example:example) ret=$(curl -s -X POST -H "Content-Type: application/yang-data+json" -H "Accept: application/yang-data+xml" -d '{"clixon-example:input":{"x":42}}' http://localhost/restconf/operations/clixon-example:example)
expect='<output xmlns="urn:example:clixon"><x>42</x><y>42</y></output>' expect='<output xmlns="urn:example:clixon"><x>42</x><y>42</y></output>'
match=`echo $ret | grep -EZo "$expect"` match=`echo $ret | grep --null -Eo "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi
@ -261,7 +261,7 @@ expecteq "$(curl -s -X POST -H "Content-Type: application/yang-data+json" -d '{"
new "restconf local client rpc using POST xml" new "restconf local client rpc using POST xml"
ret=$(curl -s -i -X POST -H "Content-Type: application/yang-data+json" -H "Accept: application/yang-data+xml" -d '{"clixon-example:input":{"x":"example"}}' http://localhost/restconf/operations/clixon-example:client-rpc) ret=$(curl -s -i -X POST -H "Content-Type: application/yang-data+json" -H "Accept: application/yang-data+xml" -d '{"clixon-example:input":{"x":"example"}}' http://localhost/restconf/operations/clixon-example:client-rpc)
expect='<output xmlns="urn:example:clixon"><x>example</x></output>' expect='<output xmlns="urn:example:clixon"><x>example</x></output>'
match=`echo $ret | grep -EZo "$expect"` match=`echo $ret | grep --null -Eo "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi

View file

@ -107,7 +107,7 @@ expectfn "curl -s -X GET http://localhost/restconf/data/example:cont1/interface=
new "restconf GET interface subtree xml" new "restconf GET interface subtree xml"
ret=$(curl -s -H "Accept: application/yang-data+xml" -G http://localhost/restconf/data/example:cont1/interface=local0) ret=$(curl -s -H "Accept: application/yang-data+xml" -G http://localhost/restconf/data/example:cont1/interface=local0)
expect='<interface xmlns="urn:example:clixon"><name>local0</name><type>regular</type></interface>' expect='<interface xmlns="urn:example:clixon"><name>local0</name><type>regular</type></interface>'
match=`echo $ret | grep -EZo "$expect"` match=`echo $ret | grep --null -Eo "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi

View file

@ -61,7 +61,7 @@ new "rpc tests"
new "restconf empty rpc" new "restconf empty rpc"
ret=$(curl -is -X POST http://localhost/restconf/operations/clixon-example:empty) ret=$(curl -is -X POST http://localhost/restconf/operations/clixon-example:empty)
expect="204 No Content" expect="204 No Content"
match=`echo $ret | grep -EZo "$expect"` match=`echo $ret | grep --null -Eo "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi
@ -108,7 +108,7 @@ expecteof "$clixon_netconf -qf $cfg" 0 '<rpc xmlns="urn:ietf:params:xml:ns:netco
new "restconf empty rpc with null input" new "restconf empty rpc with null input"
ret=$(curl -is -X POST -H "Content-Type: application/yang-data+json" -d '{"clixon-example:input":null}' http://localhost/restconf/operations/clixon-example:empty) ret=$(curl -is -X POST -H "Content-Type: application/yang-data+json" -d '{"clixon-example:input":null}' http://localhost/restconf/operations/clixon-example:empty)
expect="204 No Content" expect="204 No Content"
match=`echo $ret | grep -EZo "$expect"` match=`echo $ret | grep --null -Eo "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi
@ -120,7 +120,7 @@ expectpart "$(curl -iss -X POST -H "Content-Type: application/yang-data+json" -d
new "restconf optional rpc with null input and output" new "restconf optional rpc with null input and output"
ret=$(curl -is -X POST -H "Content-Type: application/yang-data+json" -d '{"clixon-example:input":null}' http://localhost/restconf/operations/clixon-example:optional) ret=$(curl -is -X POST -H "Content-Type: application/yang-data+json" -d '{"clixon-example:input":null}' http://localhost/restconf/operations/clixon-example:optional)
expect="204 No Content" expect="204 No Content"
match=`echo $ret | grep -EZo "$expect"` match=`echo $ret | grep --null -Eo "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi

View file

@ -124,7 +124,7 @@ expecteq "$(curl -s -X POST -H "Content-Type: application/yang-data+json" -d '{"
new "restconf get config example1 and example2" new "restconf get config example1 and example2"
ret=$(curl -s -X GET http://localhost/restconf/data) ret=$(curl -s -X GET http://localhost/restconf/data)
expect='"example1:x":42,"example2:x":{"y":99}' expect='"example1:x":42,"example2:x":{"y":99}'
match=`echo $ret | grep -EZo "$expect"` match=`echo $ret | grep --null -Eo "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi