[Git][NTPsec/ntpsec][master] TESTFRAME progess - intercept calls to read authkeys.

Eric S. Raymond gitlab at mg.gitlab.com
Sun Nov 29 20:00:41 UTC 2015


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
a19447d8 by Eric S. Raymond at 2015-11-29T14:59:00Z
TESTFRAME progess - intercept calls to read authkeys.

- - - - -


4 changed files:

- include/ntp_intercept.h
- ntpd/ntp_config.c
- ntpd/ntp_intercept.c
- ntpd/ntpd.c


Changes:

=====================================
include/ntp_intercept.h
=====================================
--- a/include/ntp_intercept.h
+++ b/include/ntp_intercept.h
@@ -39,5 +39,6 @@ int intercept_kernel_pll_adjtime(struct timex *);
 #endif
 extern bool intercept_leapsec_load_file(const char * fname, struct stat * sb,
 					bool force, bool logall);
+void intercept_getauthkeys(const char *);
 
 /* end */


=====================================
ntpd/ntp_config.c
=====================================
--- a/ntpd/ntp_config.c
+++ b/ntpd/ntp_config.c
@@ -1891,7 +1891,7 @@ config_auth(
 
 	/* Keys Command */
 	if (ptree->auth.keys)
-		getauthkeys(ptree->auth.keys);
+		intercept_getauthkeys(ptree->auth.keys);
 
 	/* Control Key Command */
 	if (ptree->auth.control_key)


=====================================
ntpd/ntp_intercept.c
=====================================
--- a/ntpd/ntp_intercept.c
+++ b/ntpd/ntp_intercept.c
@@ -28,7 +28,7 @@ following kinds:
 
 11. Packets outgoing to NTP daemons.  (TODO)
 
-12. Read of authkey file  (TODO)
+12. Read of authkey file
 
 13. getaddrinfo() calls (TODO)
 
@@ -330,3 +330,28 @@ void intercept_sendpkt(const char *legend,
 	fputs("\n", stdout);
     }
 }
+
+void
+intercept_getauthkeys(
+	const char  * fname)
+{
+    if (mode != replay)
+	getauthkeys(fname);
+
+    if (mode == capture) {
+	FILE *fp = fopen(fname, "r");
+	if (fp != NULL) {
+	    int c;
+
+	    fputs("startauthkeys\n", stdout);
+	    while ((c = fgetc(fp)) != EOF)
+		putchar(c);
+	    fclose(fp);
+	    fputs("endauthkeys\n", stdout);
+	}
+    }
+
+    /* FIXME: replay logic goes here */
+}
+
+/* end */


=====================================
ntpd/ntpd.c
=====================================
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -802,7 +802,7 @@ ntpdmain(
 	        }
 		break;
 	    case 'k':
-		getauthkeys(ntp_optarg);
+		intercept_getauthkeys(ntp_optarg);
 		break;
 	    case 'M':
 # ifdef SYS_WINNT



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/a19447d830271c725bdd9603adc511a8198b9aac
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20151129/ecbb7a9f/attachment.html>


More information about the vc mailing list