From: Harlan Stenn Date: Fri, 30 Apr 2010 09:03:12 +0000 (+0000) Subject: [Bug 1512] ntpsnmpd should connect to net-snmpd via a unix-domain socket by default... X-Git-Tag: NTP_4_2_7P28~3^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4628f3294c13821f7a33674fcfaefbf8546ac09f;p=thirdparty%2Fntp.git [Bug 1512] ntpsnmpd should connect to net-snmpd via a unix-domain socket by default. Provide a command-line 'socket name' option. bk: 4bda9cd0JPGKzNo86sMh8ZGbHjPM1Q --- diff --git a/ChangeLog b/ChangeLog index eb93b075c..5fdd59380 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ --- +* [Bug 1512] ntpsnmpd should connect to net-snmpd via a unix-domain + socket by default. Provide a command-line 'socket name' option. * [Bug 1538] update refclock_nmea.c's call to getprotobyname(). --- diff --git a/ntpsnmpd/ntpsnmpd-opts.c b/ntpsnmpd/ntpsnmpd-opts.c index 232494203..6b101b2a5 100644 --- a/ntpsnmpd/ntpsnmpd-opts.c +++ b/ntpsnmpd/ntpsnmpd-opts.c @@ -1,7 +1,7 @@ /* * EDIT THIS FILE WITH CAUTION (ntpsnmpd-opts.c) * - * It has been AutoGen-ed April 27, 2010 at 02:52:13 AM by AutoGen 5.10 + * It has been AutoGen-ed April 29, 2010 at 07:33:02 AM by AutoGen 5.10 * From the definitions ntpsnmpd-opts.def * and the template file options * @@ -75,6 +75,17 @@ tSCC zSyslog_NAME[] = "SYSLOG"; tSCC zSyslog_Name[] = "syslog"; #define SYSLOG_FLAGS (OPTST_DISABLED) +/* + * Agentxsocket option description: + */ +tSCC zAgentxsocketText[] = + "The socket address ntpsnmpd uses to connect to net-snmpd"; +tSCC zAgentxsocket_NAME[] = "AGENTXSOCKET"; +tSCC zAgentxsocket_Name[] = "agentxsocket"; +tSCC zAgentxsocketDefaultArg[] = "unix:/var/agentx/master"; +#define AGENTXSOCKET_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + /* * Help/More_Help/Version option descriptions: */ @@ -162,6 +173,18 @@ static tOptDesc optDesc[ OPTION_CT ] = { /* desc, NAME, name */ zSyslogText, zSyslog_NAME, zSyslog_Name, /* disablement strs */ NULL, NULL }, + { /* entry idx, value */ 2, VALUE_OPT_AGENTXSOCKET, + /* equiv idx, value */ 2, VALUE_OPT_AGENTXSOCKET, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ AGENTXSOCKET_FLAGS, 0, + /* last opt argumnt */ { zAgentxsocketDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zAgentxsocketText, zAgentxsocket_NAME, zAgentxsocket_Name, + /* disablement strs */ NULL, NULL }, + { /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION, /* equiv idx value */ NO_EQUIVALENT, 0, /* equivalenced to */ NO_EQUIVALENT, @@ -234,7 +257,7 @@ static tOptDesc optDesc[ OPTION_CT ] = { tSCC zPROGNAME[] = "NTPSNMPD"; tSCC zUsageTitle[] = "ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.6p2-RC2\n\ -USAGE: %s [ - | -- ]...\n"; +USAGE: %s [ - [] | --[{=| }] ]...\n"; tSCC zRcName[] = ".ntprc"; tSCC* apzHomeList[] = { "$HOME", @@ -245,7 +268,7 @@ tSCC zBugsAddr[] = "http://bugs.ntp.org, bugs@ntp.org"; #define zExplain NULL #define zDetail NULL tSCC zFullVersion[] = NTPSNMPD_FULL_VERSION; -/* extracted from /usr/local/gnu/share/autogen/optcode.tpl near line 495 */ +/* extracted from /usr/local/share/autogen/optcode.tpl near line 495 */ #if defined(ENABLE_NLS) # define OPTPROC_BASE OPTPROC_TRANSLATE @@ -285,7 +308,7 @@ tOptions ntpsnmpdOptions = { NO_EQUIVALENT, /* '-#' option index */ NO_EQUIVALENT /* index of default opt */ }, - 7 /* full option count */, 2 /* user option count */, + 8 /* full option count */, 3 /* user option count */, ntpsnmpd_full_usage, ntpsnmpd_short_usage, NULL, NULL }; @@ -301,7 +324,7 @@ doUsageOpt( (void)pOptions; USAGE( EXIT_SUCCESS ); } -/* extracted from /usr/local/gnu/share/autogen/optmain.tpl near line 109 */ +/* extracted from /usr/local/share/autogen/optmain.tpl near line 109 */ #if defined(TEST_NTPSNMPD_OPTS) /* TEST MAIN PROCEDURE: */ @@ -316,7 +339,7 @@ main(int argc, char** argv) return res; } #endif /* defined TEST_NTPSNMPD_OPTS */ -/* extracted from /usr/local/gnu/share/autogen/optcode.tpl near line 627 */ +/* extracted from /usr/local/share/autogen/optcode.tpl near line 627 */ #if ENABLE_NLS #include diff --git a/ntpsnmpd/ntpsnmpd-opts.def b/ntpsnmpd/ntpsnmpd-opts.def index 04bb7792c..7145f6347 100644 --- a/ntpsnmpd/ntpsnmpd-opts.def +++ b/ntpsnmpd/ntpsnmpd-opts.def @@ -26,3 +26,15 @@ flag = { doc = <<- _EndOfDoc_ _EndOfDoc_; }; + +flag = { + name = agentXSocket; +/* value = x; */ + arg-type = string; + arg-default = "unix:/var/agentx/master"; + descrip = "The socket address ntpsnmpd uses to connect to net-snmpd"; + doc = <<- _EndOfDoc_ + [:] + The default is the Unix Domain socket "unix:/var/agentx/master". Another common alternative is tcp:localhost:705. + _EndOfDoc_; +}; diff --git a/ntpsnmpd/ntpsnmpd-opts.h b/ntpsnmpd/ntpsnmpd-opts.h index b73f33943..c03596d52 100644 --- a/ntpsnmpd/ntpsnmpd-opts.h +++ b/ntpsnmpd/ntpsnmpd-opts.h @@ -1,7 +1,7 @@ /* * EDIT THIS FILE WITH CAUTION (ntpsnmpd-opts.h) * - * It has been AutoGen-ed April 27, 2010 at 02:52:13 AM by AutoGen 5.10 + * It has been AutoGen-ed April 29, 2010 at 07:33:02 AM by AutoGen 5.10 * From the definitions ntpsnmpd-opts.def * and the template file options * @@ -52,16 +52,17 @@ * Enumeration of each option: */ typedef enum { - INDEX_OPT_NOFORK = 0, - INDEX_OPT_SYSLOG = 1, - INDEX_OPT_VERSION = 2, - INDEX_OPT_HELP = 3, - INDEX_OPT_MORE_HELP = 4, - INDEX_OPT_SAVE_OPTS = 5, - INDEX_OPT_LOAD_OPTS = 6 + INDEX_OPT_NOFORK = 0, + INDEX_OPT_SYSLOG = 1, + INDEX_OPT_AGENTXSOCKET = 2, + INDEX_OPT_VERSION = 3, + INDEX_OPT_HELP = 4, + INDEX_OPT_MORE_HELP = 5, + INDEX_OPT_SAVE_OPTS = 6, + INDEX_OPT_LOAD_OPTS = 7 } teOptIndex; -#define OPTION_CT 7 +#define OPTION_CT 8 #define NTPSNMPD_VERSION "4.2.6p2-RC2" #define NTPSNMPD_FULL_VERSION "ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.6p2-RC2" @@ -98,9 +99,14 @@ typedef enum { # warning undefining SYSLOG due to option name conflict # undef SYSLOG # endif +# ifdef AGENTXSOCKET +# warning undefining AGENTXSOCKET due to option name conflict +# undef AGENTXSOCKET +# endif #else /* NO_OPTION_NAME_WARNINGS */ # undef NOFORK # undef SYSLOG +# undef AGENTXSOCKET #endif /* NO_OPTION_NAME_WARNINGS */ /* * * * * * @@ -109,6 +115,7 @@ typedef enum { */ #define VALUE_OPT_NOFORK 'n' #define VALUE_OPT_SYSLOG 'p' +#define VALUE_OPT_AGENTXSOCKET 2 #define VALUE_OPT_HELP '?' #define VALUE_OPT_MORE_HELP '!' #define VALUE_OPT_VERSION INDEX_OPT_VERSION @@ -128,7 +135,7 @@ typedef enum { ntpsnmpdOptions.pzCurOpt = NULL ) #define START_OPT RESTART_OPT(1) #define USAGE(c) (*ntpsnmpdOptions.pUsageProc)( &ntpsnmpdOptions, c ) -/* extracted from /usr/local/gnu/share/autogen/opthead.tpl near line 409 */ +/* extracted from /usr/local/share/autogen/opthead.tpl near line 409 */ /* * * * * * * diff --git a/ntpsnmpd/ntpsnmpd-opts.texi b/ntpsnmpd/ntpsnmpd-opts.texi index 2c1c80173..895c9ff61 100644 --- a/ntpsnmpd/ntpsnmpd-opts.texi +++ b/ntpsnmpd/ntpsnmpd-opts.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (ntpsnmpd-opts.texi) # -# It has been AutoGen-ed April 27, 2010 at 02:52:14 AM by AutoGen 5.10 +# It has been AutoGen-ed April 29, 2010 at 07:33:08 AM by AutoGen 5.10 # From the definitions ntpsnmpd-opts.def # and the template file aginfo.tpl @end ignore @@ -21,6 +21,7 @@ This software is released under a specialized copyright license. @menu * ntpsnmpd usage:: ntpsnmpd usage help (-?) +* ntpsnmpd agentxsocket:: agentxsocket option * ntpsnmpd nofork:: nofork option (-n) * ntpsnmpd syslog:: syslog option (-p) @end menu @@ -33,7 +34,29 @@ This is the automatically generated usage text for ntpsnmpd: @exampleindent 0 @example -ntpsnmpd is unavailable - no --help +ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.6p2-RC2 +USAGE: ntpsnmpd [ - [] | --[@{=| @}] ]... + Flg Arg Option-Name Description + -n no nofork Do not fork + -p no syslog Log to syslog() + Str agentxsocket The socket address ntpsnmpd uses to connect to net-snmpd + opt version Output version information and exit + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + -> opt save-opts Save the option state to a config file + -< Str load-opts Load options from a config file + - disabled as --no-load-opts + - may appear multiple times + +Options are specified by doubled hyphens and their name +or by a single hyphen and the flag character. + +The following option preset mechanisms are supported: + - reading file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/.ntprc + - reading file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/ntp-stable-1512-38/ntpsnmpd/.ntprc + - examining environment variables named NTPSNMPD_* + +please send bug reports to: http://bugs.ntp.org, bugs@@ntp.org @end example @exampleindent 4 @@ -50,3 +73,11 @@ This is the ``do not fork'' option. This is the ``log to syslog()'' option. + +@node ntpsnmpd agentxsocket +@subsection agentxsocket option +@cindex ntpsnmpd-agentxsocket + +This is the ``the socket address ntpsnmpd uses to connect to net-snmpd'' option. +[:] +The default is the Unix Domain socket "unix:/var/agentx/master". Another common alternative is tcp:localhost:705. diff --git a/ntpsnmpd/ntpsnmpd.1 b/ntpsnmpd/ntpsnmpd.1 index be5173220..128037148 100644 --- a/ntpsnmpd/ntpsnmpd.1 +++ b/ntpsnmpd/ntpsnmpd.1 @@ -1,7 +1,7 @@ -.TH NTPSNMPD 1 2010-04-27 "( 4.2.6p2-RC2)" "Programmer's Manual" +.TH NTPSNMPD 1 2010-04-29 "( 4.2.6p2-RC2)" "Programmer's Manual" .\" EDIT THIS FILE WITH CAUTION (ntpsnmpd.1) .\" -.\" It has been AutoGen-ed April 27, 2010 at 02:52:14 AM by AutoGen 5.10 +.\" It has been AutoGen-ed April 29, 2010 at 07:33:08 AM by AutoGen 5.10 .\" From the definitions ntpsnmpd-opts.def .\" and the template file agman1.tpl .\" @@ -27,6 +27,15 @@ Do not fork. Log to syslog(). .sp +.TP +.BR \--agentxsocket "=\fIstring\fP" +The socket address ntpsnmpd uses to connect to net-snmpd. +The default \fIstring\fP for this option is: +.ti +4 + unix:/var/agentx/master +.sp +[:] +The default is the Unix Domain socket "unix:/var/agentx/master". Another common alternative is tcp:localhost:705. .TP .BR \-? , " \--help" Display extended usage information and exit. diff --git a/ntpsnmpd/ntpsnmpd.c b/ntpsnmpd/ntpsnmpd.c index 449631b47..194080783 100644 --- a/ntpsnmpd/ntpsnmpd.c +++ b/ntpsnmpd/ntpsnmpd.c @@ -91,7 +91,7 @@ main (int argc, char **argv) { /* Set AgentX socket interface */ netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, - NETSNMP_DS_AGENT_X_SOCKET, "tcp:localhost:705"); + NETSNMP_DS_AGENT_X_SOCKET, OPT_ARG( AGENTXSOCKET )); init_agent("ntpsnmpd");