+* [Bug 2227] Enable mrulist access control via "restrict ... nomrulist".
+* Conditionalize msyslog messages about rejected mode 6 requests due to
+ nomodify and nomrulist restrictions under "logconfig +sysinfo".
+* Increment sys_restricted in a few rejection paths due to nomodify
+ restrictions where previosuly overlooked.
(4.2.7p284) 2012/06/16 Released by Harlan Stenn <stenn@ntp.org>
* [Bug 2225] libevent configure hangs.
* Update bundled libevent to git master, post libevent 2.1.1-alpha.
#define RES_NOTRAP 0x0100 /* mode 6/7 set trap denied */
#define RES_LPTRAP 0x0200 /* mode 6/7 low priority trap */
-#define RES_KOD 0x0400 /* send kiss of death packet */
+#define RES_KOD 0x0400 /* send kiss of death packet */
#define RES_MSSNTP 0x0800 /* enable MS-SNTP authentication */
-#define RES_FLAKE 0x1000 /* flakeway - drop 10% */
+#define RES_FLAKE 0x1000 /* flakeway - drop 10% */
+#define RES_NOMRULIST 0x2000 /* mode 6 mrulist denied */
#define RES_ALLFLAGS (RES_FLAGS | RES_NOQUERY | \
RES_NOMODIFY | RES_NOTRAP | \
RES_LPTRAP | RES_KOD | \
- RES_MSSNTP | RES_FLAKE)
+ RES_MSSNTP | RES_FLAKE | \
+ RES_NOMRULIST)
/*
* Match flags
#define INFO_ERR_FMT 3 /* format error */
#define INFO_ERR_NODATA 4 /* no data for this request */
#define INFO_ERR_AUTH 7 /* authentication failure */
+#define MAX_INFO_ERR INFO_ERR_AUTH
/*
* Maximum sequence number.
mru maxage 64 mindepth 600 initalloc 600 initmem 16 incalloc 99 incmem 4 maxdepth 1024 maxmem 4096
discard minimum 1 average 3 monitor 3000
restrict default
-restrict default nomodify limited kod noserve
+restrict default nomodify limited kod noserve nomrulist
restrict source
restrict source nomodify limited kod
restrict trusted.host.name.example.com. nomodify
{ "lowpriotrap", T_Lowpriotrap, FOLLBY_TOKEN },
{ "mask", T_Mask, FOLLBY_TOKEN },
{ "nomodify", T_Nomodify, FOLLBY_TOKEN },
+{ "nomrulist", T_Nomrulist, FOLLBY_TOKEN },
{ "nopeer", T_Nopeer, FOLLBY_TOKEN },
{ "noquery", T_Noquery, FOLLBY_TOKEN },
{ "noserve", T_Noserve, FOLLBY_TOKEN },
flags |= RES_NOMODIFY;
break;
+ case T_Nomrulist:
+ flags |= RES_NOMRULIST;
+ break;
+
case T_Nopeer:
flags |= RES_NOPEER;
break;
"saveconfig prohibited by restrict ... nomodify");
ctl_putdata(reply, strlen(reply), 0);
ctl_flushpkt(0);
- msyslog(LOG_NOTICE,
- "saveconfig from %s rejected due to nomodify restriction",
- stoa(&rbufp->recv_srcadr));
+ NLOG(NLOG_SYSINFO)
+ msyslog(LOG_NOTICE,
+ "saveconfig from %s rejected due to nomodify restriction",
+ stoa(&rbufp->recv_srcadr));
+ sys_restricted++;
return;
}
"saveconfig prohibited, no saveconfigdir configured");
ctl_putdata(reply, strlen(reply), 0);
ctl_flushpkt(0);
- msyslog(LOG_NOTICE,
- "saveconfig from %s rejected, no saveconfigdir",
- stoa(&rbufp->recv_srcadr));
+ NLOG(NLOG_SYSINFO)
+ msyslog(LOG_NOTICE,
+ "saveconfig from %s rejected, no saveconfigdir",
+ stoa(&rbufp->recv_srcadr));
return;
}
return;
}
- if (restrict_mask & RES_NOMODIFY) {
+ if (RES_NOMODIFY & restrict_mask) {
snprintf(remote_config.err_msg,
sizeof(remote_config.err_msg),
"runtime configuration prohibited by restrict ... nomodify");
ctl_putdata(remote_config.err_msg,
strlen(remote_config.err_msg), 0);
ctl_flushpkt(0);
- msyslog(LOG_NOTICE,
- "runtime config from %s rejected due to nomodify restriction",
- stoa(&rbufp->recv_srcadr));
+ NLOG(NLOG_SYSINFO)
+ msyslog(LOG_NOTICE,
+ "runtime config from %s rejected due to nomodify restriction",
+ stoa(&rbufp->recv_srcadr));
+ sys_restricted++;
return;
}
mon_entry * prior_mon;
l_fp now;
+ if (RES_NOMRULIST & restrict_mask) {
+ ctl_error(CERR_PERMISSION);
+ NLOG(NLOG_SYSINFO)
+ msyslog(LOG_NOTICE,
+ "mrulist from %s rejected due to nomrulist restriction",
+ stoa(&rbufp->recv_srcadr));
+ sys_restricted++;
+ return;
+ }
/*
* fill in_parms var list with all possible input parameters.
*/
%token <Integer> T_Nic
%token <Integer> T_Nolink
%token <Integer> T_Nomodify
+%token <Integer> T_Nomrulist
%token <Integer> T_None
%token <Integer> T_Nonvolatile
%token <Integer> T_Nopeer
| T_Limited
| T_Lowpriotrap
| T_Nomodify
+ | T_Nomrulist
| T_Nopeer
| T_Noquery
| T_Noserve
u_long numrequests; /* number of requests we've received */
u_long numresppkts; /* number of resp packets sent with data */
-u_long errorcounter[INFO_ERR_AUTH+1]; /* lazy way to count errors, indexed */
-/* by the error code */
+/*
+ * lazy way to count errors, indexed by the error code
+ */
+u_long errorcounter[MAX_INFO_ERR + 1];
/*
* A hack. To keep the authentication module clear of ntp-ism's, we
"process_private: failed auth mod_okay %d\n",
mod_okay);
#endif
+ if (!mod_okay) {
+ sys_restricted++;
+ }
req_ack(srcadr, inter, inpkt, INFO_ERR_AUTH);
return;
}