diff --git a/CHANGELOG.md b/CHANGELOG.md index d7576fd3..300e6af3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * If dropped temporary, you can restore privileges with `restore_priv()` ### 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 * 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. diff --git a/apps/backend/backend_main.c b/apps/backend/backend_main.c index 40db2848..d4261145 100644 --- a/apps/backend/backend_main.c +++ b/apps/backend/backend_main.c @@ -273,19 +273,19 @@ check_drop_priv(clicon_handle h, /* From here, drop privileges */ /* Check backend user exists */ 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; } /* Get (wanted) new backend user id */ 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; } /* get current backend userid, if already at this level OK */ if ((uid = getuid()) == newuid) goto ok; 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; } /* When dropping priveleges, datastores are created if they do not exist. @@ -309,7 +309,7 @@ check_drop_priv(clicon_handle h, goto done; if (setgid(gid) == -1) { - clicon_err(OE_DEMON, errno, "setgid %d", gid); + clicon_err(OE_DAEMON, errno, "setgid %d", gid); goto done; } switch (priv_mode){ @@ -318,7 +318,7 @@ check_drop_priv(clicon_handle h, goto done; /* Verify you cannot regain root privileges */ if (setuid(0) != -1){ - clicon_err(OE_DEMON, EPERM, "Could regain root privilieges"); + clicon_err(OE_DAEMON, EPERM, "Could regain root privilieges"); goto done; } break; @@ -652,7 +652,7 @@ main(int argc, } else 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); return -1; /* goto done deletes pidfile */ } @@ -866,11 +866,11 @@ main(int argc, clicon_log(LOG_NOTICE, "%s: %u Started", __PROGRAM__, getpid()); 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; } 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; } diff --git a/apps/restconf/restconf_main.c b/apps/restconf/restconf_main.c index a5c4a41d..1ce97013 100644 --- a/apps/restconf/restconf_main.c +++ b/apps/restconf/restconf_main.c @@ -626,15 +626,15 @@ main(int argc, clicon_debug_init(debug, NULL); clicon_log(LOG_NOTICE, "%s: %u Started", __PROGRAM__, getpid()); 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; } 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; } 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; } diff --git a/lib/Makefile.in b/lib/Makefile.in index a0f09147..1ca5b49d 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -56,7 +56,7 @@ $(SUBDIRS): install: for i in $(SUBDIRS); \ - do (cd $$i && $(MAKE) $(MFLAGS) $@); done + do (cd $$i && $(MAKE) $(MFLAGS) $@)||exit 1; done install-include: for i in $(SUBDIRS); \ @@ -72,12 +72,12 @@ config.status: configure clean: for i in $(SUBDIRS); \ - do (cd $$i; $(MAKE) $(MFLAGS) clean); done + do (cd $$i; $(MAKE) $(MFLAGS) $@)||exit 1; done distclean: clean rm -f Makefile *~ .depend for i in $(SUBDIRS); \ - do (cd $$i; $(MAKE) $(MFLAGS) distclean); done; \ + do (cd $$i; $(MAKE) $(MFLAGS) $@)||exit 1; done; \ (cd clixon; $(MAKE) $(MFLAGS) $@) TAGS: diff --git a/lib/clixon/clixon_err.h b/lib/clixon/clixon_err.h index 28be3def..b9daf309 100644 --- a/lib/clixon/clixon_err.h +++ b/lib/clixon/clixon_err.h @@ -58,7 +58,7 @@ enum clicon_err{ /* 0 means error not set) */ OE_DB = 1, /* database registries */ - OE_DEMON, /* demons: pidfiles, etc */ + OE_DAEMON, /* demons: pidfiles, etc */ OE_EVENTS, /* events, filedescriptors, timeouts */ OE_CFG, /* configuration */ OE_PROTO, /* config/client communication */ diff --git a/lib/src/clixon_err.c b/lib/src/clixon_err.c index 3166259e..89a133f1 100644 --- a/lib/src/clixon_err.c +++ b/lib/src/clixon_err.c @@ -85,7 +85,7 @@ char clicon_err_reason[ERR_STRLEN] = {0, }; */ static struct errvec EV[] = { {"Database error", OE_DB}, - {"Demon error", OE_DEMON}, + {"Daemon error", OE_DAEMON}, {"Event error", OE_EVENTS}, {"Config error", OE_CFG}, {"Protocol error", OE_PROTO}, diff --git a/lib/src/clixon_sig.c b/lib/src/clixon_sig.c index d7c27335..d7bf3f1c 100644 --- a/lib/src/clixon_sig.c +++ b/lib/src/clixon_sig.c @@ -165,7 +165,7 @@ pidfile_zapold(pid_t pid) if ((kill (pid, 0)) != 0 && errno == ESRCH) /* Nothing there */ ; else{ /* problem: couldnt kill it */ - clicon_err(OE_DEMON, errno, "Killing old demon"); + clicon_err(OE_DAEMON, errno, "Killing old demon"); return -1; } return 0; @@ -184,13 +184,13 @@ pidfile_write(char *pidfile) /* Here, there should be no old agent and no pidfile */ if ((f = fopen(pidfile, "w")) == NULL){ 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 - clicon_err(OE_DEMON, errno, "Creating pid-file %s", pidfile); + clicon_err(OE_DAEMON, errno, "Creating pid-file %s", pidfile); goto done; } 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; } clicon_debug(1, "Opened pidfile %s with pid %d", pidfile, getpid()); diff --git a/test/README.md b/test/README.md index 5cc925c5..fd34175f 100644 --- a/test/README.md +++ b/test/README.md @@ -78,9 +78,8 @@ You may add your site-specific modifications in a `site.sh` file. Example: IETFRFC=$YANGMODELS/standard/ietf/RFC ``` -## FreeBSD - -To run on freebsd: +For example, in FreeBSD, add: +``` +wwwuser=www +make=gmake ``` -wwwuser=www clixon_restconf=/usr/local/sbin/clixon_restconf ./all.sh -``` \ No newline at end of file diff --git a/test/test_feature.sh b/test/test_feature.sh index 5a9253c9..eda6b56e 100755 --- a/test/test_feature.sh +++ b/test/test_feature.sh @@ -123,14 +123,14 @@ EOF new "netconf modules-state header" expect='^' -match=`echo "$ret" | grep -GZo "$expect"` +match=`echo "$ret" | grep --null -Go "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" fi new "netconf module A" expect="exampleurn:example:clixonAimplement" -match=`echo "$ret" | grep -GZo "$expect"` +match=`echo "$ret" | grep --null -Go "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" fi @@ -138,7 +138,7 @@ fi if false ; then # clixon "config" bug new "netconf module clixon-config" expect="clixon-config2018-09-30" -match=`echo "$ret" | grep -GZo "$expect"` +match=`echo "$ret" | grep --null -Go "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" fi @@ -146,14 +146,14 @@ fi # false new "netconf module ietf-inet-types" expect="ietf-inet-types2013-07-15urn:ietf:params:xml:ns:yang:ietf-inet-typesimplement" -match=`echo "$ret" | grep -GZo "$expect"` +match=`echo "$ret" | grep --null -Go "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" fi new "netconf module ietf-interfaces" expect="ietf-interfaces2018-02-20urn:ietf:params:xml:ns:yang:ietf-interfacesimplement" -match=`echo "$ret" | grep -GZo "$expect"` +match=`echo "$ret" | grep --null -Go "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" fi @@ -161,26 +161,26 @@ fi # Note order of features in ietf-netconf yang is alphabetically: candidate, startup, validate, xpath new "netconf module ietf-netconf" expect="ietf-netconf2011-06-01urn:ietf:params:xml:ns:netconf:base:1.0candidatevalidatexpathimplement" -match=`echo "$ret" | grep -GZo "$expect"` +match=`echo "$ret" | grep --null -Go "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" fi new "netconf module ietf-routing" expect="ietf-routing2018-03-13urn:ietf:params:xml:ns:yang:ietf-routingrouter-idimplement" -match=`echo "$ret" | grep -GZo "$expect"` +match=`echo "$ret" | grep --null -Go "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" fi expect="ietf-yang-library2016-06-21urn:ietf:params:xml:ns:yang:ietf-yang-libraryimplement" -match=`echo "$ret" | grep -GZo "$expect"` +match=`echo "$ret" | grep --null -Go "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" fi new "netconf module ietf-yang_types" expect="ietf-yang-types2013-07-15urn:ietf:params:xml:ns:yang:ietf-yang-typesimplement" -match=`echo "$ret" | grep -GZo "$expect"` +match=`echo "$ret" | grep --null -Go "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" fi diff --git a/test/test_install.sh b/test/test_install.sh index 5322ebed..78b85ecb 100755 --- a/test/test_install.sh +++ b/test/test_install.sh @@ -4,10 +4,13 @@ # Magic line must be first in script (see README.md) 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 "Make DESTDIR install" -(cd ..; make DESTDIR=$dir install) +new "Make DESTDIR install ($dir)" +(cd ..; $make DESTDIR=$dir install) if [ $? -ne 0 ]; then err fi @@ -33,7 +36,7 @@ if [ ! -h $dir/usr/local/lib/libclixon_backend.so ]; then fi new "Make DESTDIR install include" -(cd ..; make DESTDIR=$dir install-include) +(cd ..; $make DESTDIR=$dir install-include) if [ $? -ne 0 ]; then err fi @@ -42,7 +45,7 @@ if [ ! -f $dir/usr/local/include/clixon/clixon.h ]; then err $dir/usr/local/include/clixon/clixon.h fi new "Make DESTDIR uninstall" -(cd ..; make DESTDIR=$dir uninstall) +(cd ..; $make DESTDIR=$dir uninstall) if [ $? -ne 0 ]; then err fi diff --git a/test/test_nacm_module_read.sh b/test/test_nacm_module_read.sh index 416095e0..2665f805 100755 --- a/test/test_nacm_module_read.sh +++ b/test/test_nacm_module_read.sh @@ -181,7 +181,7 @@ expecteq "$(curl -u andy:bar -sS -X GET http://localhost/restconf/data/clixon-ex new "admin read top ok (all)" ret=$(curl -u andy:bar -sS -X GET http://localhost/restconf/data) 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 err "$expect" "$ret" fi diff --git a/test/test_restconf.sh b/test/test_restconf.sh index 7c7dfbc7..909b3eac 100755 --- a/test/test_restconf.sh +++ b/test/test_restconf.sh @@ -80,7 +80,7 @@ expecteq "$(curl -sG http://localhost/restconf/operations)" 0 '{"operations":{"c new "restconf get restconf/operations. RFC8040 3.3.2 (xml)" ret=$(curl -s -H "Accept: application/yang-data+xml" -G http://localhost/restconf/operations) expect='' -match=`echo $ret | grep -EZo "$expect"` +match=`echo $ret | grep --null -Eo "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" 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)" ret=$(curl -s -H "Accept: application/yang-data+xml" -G http://localhost/restconf/yang-library-version) expect="2016-06-21" -match=`echo $ret | grep -EZo "$expect"` +match=`echo $ret | grep --null -Eo "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" fi @@ -132,7 +132,7 @@ expectpart "$(curl -siSG http://localhost/restconf/data/badmodule:state)" 0 'HTT new "restconf get empty config + state xml" ret=$(curl -s -H "Accept: application/yang-data+xml" -G http://localhost/restconf/data/clixon-example:state) expect='424143' -match=`echo $ret | grep -EZo "$expect"` +match=`echo $ret | grep --null -Eo "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" fi @@ -145,7 +145,7 @@ new "restconf get state operation" # 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) expect='42' -match=`echo $ret | grep -EZo "$expect"` +match=`echo $ret | grep --null -Eo "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" fi @@ -158,7 +158,7 @@ new "restconf get state operation type xml" # 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) expect='42' -match=`echo $ret | grep -EZo "$expect"` +match=`echo $ret | grep --null -Eo "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" fi @@ -250,7 +250,7 @@ expecteq "$(curl -s -X POST -H "Content-Type: application/yang-data+json" -d '{} 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) expect='4242' -match=`echo $ret | grep -EZo "$expect"` +match=`echo $ret | grep --null -Eo "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" 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" 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='example' -match=`echo $ret | grep -EZo "$expect"` +match=`echo $ret | grep --null -Eo "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" fi diff --git a/test/test_restconf2.sh b/test/test_restconf2.sh index 18afb0db..651d9098 100755 --- a/test/test_restconf2.sh +++ b/test/test_restconf2.sh @@ -107,7 +107,7 @@ expectfn "curl -s -X GET http://localhost/restconf/data/example:cont1/interface= new "restconf GET interface subtree xml" ret=$(curl -s -H "Accept: application/yang-data+xml" -G http://localhost/restconf/data/example:cont1/interface=local0) expect='local0regular' -match=`echo $ret | grep -EZo "$expect"` +match=`echo $ret | grep --null -Eo "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" fi diff --git a/test/test_rpc.sh b/test/test_rpc.sh index e952dc1c..42abdd09 100755 --- a/test/test_rpc.sh +++ b/test/test_rpc.sh @@ -61,7 +61,7 @@ new "rpc tests" new "restconf empty rpc" ret=$(curl -is -X POST http://localhost/restconf/operations/clixon-example:empty) expect="204 No Content" -match=`echo $ret | grep -EZo "$expect"` +match=`echo $ret | grep --null -Eo "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" fi @@ -108,7 +108,7 @@ expecteof "$clixon_netconf -qf $cfg" 0 '