Skip to content

Commit

Permalink
backend socket options -a -u
Browse files Browse the repository at this point in the history
  • Loading branch information
olofhagsand committed Jul 25, 2018
1 parent c6a62b9 commit 539a60d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 10 deletions.
12 changes: 7 additions & 5 deletions apps/cli/cli_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
#include "cli_handle.h"

/* Command line options to be passed to getopt(3) */
#define CLI_OPTS "hD:f:xl:F:1u:d:m:qpGLy:c:U:"
#define CLI_OPTS "hD:f:xl:F:1a:u:d:m:qpGLy:c:U:"

/*! terminate cli application */
static int
Expand Down Expand Up @@ -197,7 +197,6 @@ static void
usage(clicon_handle h,
char *argv0)
{
char *confsock = clicon_sock(h);
char *plgdir = clicon_cli_dir(h);

fprintf(stderr, "usage:%s [options] [commands]\n"
Expand All @@ -209,7 +208,8 @@ usage(clicon_handle h,
"\t-x\t\tDump configuration file as XML on stdout (migration utility)\n"
"\t-F <file> \tRead commands from file (default stdin)\n"
"\t-1\t\tDo not enter interactive mode\n"
"\t-u <sockpath>\tconfig UNIX domain path (default: %s)\n"
"\t-a UNIX|IPv4|IPv6\tInternal backend socket family\n"
"\t-u <path|addr>\tInternal socket domain path or IP addr (see -a)\n"
"\t-d <dir>\tSpecify plugin directory (default: %s)\n"
"\t-m <mode>\tSpecify plugin syntax mode\n"
"\t-q \t\tQuiet mode, dont print greetings or prompt, terminate on ctrl-C\n"
Expand All @@ -221,7 +221,6 @@ usage(clicon_handle h,
"\t-c <file>\tSpecify cli spec file.\n"
"\t-U <user>\tOver-ride unix user with a pseudo user for NACM.\n",
argv0,
confsock ? confsock : "none",
plgdir ? plgdir : "none"
);
exit(1);
Expand Down Expand Up @@ -354,7 +353,10 @@ main(int argc, char **argv)
case '1' : /* Quit after reading database once - dont wait for events */
once = 1;
break;
case 'u': /* config unix domain path/ ip host */
case 'a': /* internal backend socket address family */
clicon_option_str_set(h, "CLICON_SOCK_FAMILY", optarg);
break;
case 'u': /* internal backend socket unix domain path or ip host */
if (!strlen(optarg))
usage(h, argv[0]);
clicon_option_str_set(h, "CLICON_SOCK", optarg);
Expand Down
12 changes: 11 additions & 1 deletion apps/netconf/netconf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
#include "netconf_rpc.h"

/* Command line options to be passed to getopt(3) */
#define NETCONF_OPTS "hDqf:d:Sy:U:"
#define NETCONF_OPTS "hDqf:a:u:d:Sy:U:"

/*! Process incoming packet
* @param[in] h Clicon handle
Expand Down Expand Up @@ -296,6 +296,8 @@ usage(clicon_handle h,
"\t-D\t\tDebug\n"
"\t-q\t\tQuiet: dont send hello prompt\n"
"\t-f <file>\tConfiguration file (mandatory)\n"
"\t-a UNIX|IPv4|IPv6\tInternal backend socket family\n"
"\t-u <path|addr>\tInternal socket domain path or IP addr (see -a)\n"
"\t-d <dir>\tSpecify netconf plugin directory dir (default: %s)\n"
"\t-S\t\tLog on syslog\n"
"\t-y <file>\tOverride yang spec file (dont include .yang suffix)\n"
Expand Down Expand Up @@ -374,6 +376,14 @@ main(int argc,
case 'f': /* config file */
case 'S': /* Log on syslog */
break; /* see above */
case 'a': /* internal backend socket address family */
clicon_option_str_set(h, "CLICON_SOCK_FAMILY", optarg);
break;
case 'u': /* internal backend socket unix domain path or ip host */
if (!strlen(optarg))
usage(h, argv[0]);
clicon_option_str_set(h, "CLICON_SOCK", optarg);
break;
case 'q': /* quiet: dont write hello */
quiet++;
break;
Expand Down
14 changes: 12 additions & 2 deletions apps/restconf/restconf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
#include "restconf_methods.h"

/* Command line options to be passed to getopt(3) */
#define RESTCONF_OPTS "hDf:p:y:"
#define RESTCONF_OPTS "hDf:p:y:a:u:"

/* RESTCONF enables deployments to specify where the RESTCONF API is
located. The client discovers this by getting the "/.well-known/host-meta"
Expand Down Expand Up @@ -488,7 +488,9 @@ usage(clicon_handle h,
"\t-D \t\tDebug. Log to syslog\n"
"\t-f <file>\tConfiguration file (mandatory)\n"
"\t-d <dir>\tSpecify restconf plugin directory dir (default: %s)\n"
"\t-y <file>\tOverride yang spec file (dont include .yang suffix)\n",
"\t-y <file>\tOverride yang spec file (dont include .yang suffix)\n"
"\t-a UNIX|IPv4|IPv6\tInternal backend socket family\n"
"\t-u <path|addr>\tInternal socket domain path or IP addr (see -a)\n",
argv0,
clicon_restconf_dir(h)
);
Expand Down Expand Up @@ -541,6 +543,14 @@ main(int argc,
case 'y' : /* yang module */
yangspec = optarg;
break;
case 'a': /* internal backend socket address family */
clicon_option_str_set(h, "CLICON_SOCK_FAMILY", optarg);
break;
case 'u': /* internal backend socket unix domain path or ip host */
if (!strlen(optarg))
usage(h, argv[0]);
clicon_option_str_set(h, "CLICON_SOCK", optarg);
break;
default:
usage(h, argv[0]);
break;
Expand Down
2 changes: 1 addition & 1 deletion doc/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The example:

## Do I need to setup anything? (IMPORTANT)

The config demon requires a valid group to create a server UNIX socket.
The config demon requires a valid group to create a server UNIX domain socket.
Define a valid CLICON_SOCK_GROUP in the config file or via the -g option
or create the group and add the user to it. The default group is 'clicon'.
Add yourself and www-data, if you intend to use restconf.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/clixon_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ plugin_load_one(clicon_handle h,
char *name;
char *p;

clicon_debug(1, "%s", __FUNCTION__);
clicon_debug(1, "%s file:%s function:%s", __FUNCTION__, file, function);
dlerror(); /* Clear any existing error */
if ((handle = dlopen(file, dlflags)) == NULL) {
error = (char*)dlerror();
Expand Down

0 comments on commit 539a60d

Please sign in to comment.