Browse code

Add patch to remove call to OpenSSL's list digest method in ntpq

Change-Id: I485d620e9cf962d9c90b93a6f5ad1b59d17f1c5f
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/3903
Reviewed-by: Sharath George
Tested-by: Sharath George

suezzelur authored on 2017/09/29 06:54:33
Showing 2 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:        Network Time Protocol reference implementation
2 2
 Name:           ntp
3 3
 Version:        4.2.8p10
4
-Release:        3%{?dist}
4
+Release:        4%{?dist}
5 5
 License:        NTP
6 6
 URL:            http://www.ntp.org/
7 7
 Group:          System Environment/NetworkingPrograms
... ...
@@ -14,6 +14,7 @@ Source0:        https://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/%{name}-%
14 14
 Source1: ntpstat-master.zip
15 15
 %define sha1 ntpstat=729cf2c9f10da43554f26875e91e1973d4498761
16 16
 Source2: ntp.sysconfig
17
+Patch0:  ntpq-remove-list-digest-call.patch
17 18
 BuildRequires:  which
18 19
 BuildRequires:  libcap-devel
19 20
 BuildRequires:  unzip
... ...
@@ -38,6 +39,7 @@ state of the NTP daemon running on the local machine.
38 38
 
39 39
 %prep
40 40
 %setup -q -a 1
41
+%patch0 -p1
41 42
 
42 43
 %build
43 44
 ./configure \
... ...
@@ -138,6 +140,8 @@ rm -rf %{buildroot}/*
138 138
 %{_mandir}/man8/ntpstat.8*
139 139
 
140 140
 %changelog
141
+*   Wed Sep 27 2017 Anish Swaminathan <anishs@vmware.com> 4.2.8p10-4
142
+-   Add patch to remove call to OpenSSL's list digest method in ntpq
141 143
 *   Thu Jul 27 2017 Dheeraj Shetty <dheerajs@vmware.com> 4.2.8p10-3
142 144
 -   Remove syslog.target from service file
143 145
 *   Mon Apr 10 2017 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 4.2.8p10-2
144 146
new file mode 100644
... ...
@@ -0,0 +1,199 @@
0
+diff -rup ntp-4.2.8p10/ntpq/ntpq.c ntp-4.2.8p10-new/ntpq/ntpq.c
1
+--- ntp-4.2.8p10/ntpq/ntpq.c	2017-03-21 06:04:30.000000000 -0700
2
+@@ -33,7 +33,6 @@
3
+ #ifdef OPENSSL
4
+ #include "openssl/evp.h"
5
+ #include "openssl/objects.h"
6
+-#include "openssl/err.h"
7
+ #include "libssl_compat.h"
8
+ #endif
9
+ #include <ssl_applink.c>
10
+@@ -227,13 +226,6 @@ static	void	on_ctrlc	(void);
11
+ static	int	my_easprintf	(char**, const char *, ...) NTP_PRINTF(2, 3);
12
+ void	ntpq_custom_opt_handler	(tOptions *, tOptDesc *);
13
+ 
14
+-#ifdef OPENSSL
15
+-# ifdef HAVE_EVP_MD_DO_ALL_SORTED
16
+-static void list_md_fn(const EVP_MD *m, const char *from,
17
+-		       const char *to, void *arg );
18
+-# endif
19
+-#endif
20
+-static char *list_digest_names(void);
21
+ 
22
+ /*
23
+  * Built-in commands we understand
24
+@@ -294,8 +286,8 @@ struct xcmd builtins[] = {
25
+ 	  { "version number", "", "", "" },
26
+ 	  "set the NTP version number to use for requests" },
27
+ 	{ "keytype",	keytype,	{ OPT|NTP_STR, NO, NO, NO },
28
+-	  { "key type %s", "", "", "" },
29
+-	  NULL },
30
++	  { "key type (md5|des)", "", "", "" },
31
++	  "set key type to use for authenticated requests (des|md5)" },
32
+ 	{ 0,		0,		{ NO, NO, NO, NO },
33
+ 	  { "", "", "", "" }, "" }
34
+ };
35
+@@ -477,37 +469,6 @@ ntpqmain(
36
+ 	if (!ipv6_works)
37
+ 		ai_fam_default = AF_INET;
38
+ 
39
+-	/* Fixup keytype's help based on available digest names */
40
+-
41
+-	{
42
+-	    char *list;
43
+-	    char *msg;
44
+-
45
+-	    list = list_digest_names();
46
+-	    for (icmd = 0; icmd < sizeof(builtins)/sizeof(builtins[0]); icmd++) {
47
+-		if (strcmp("keytype", builtins[icmd].keyword) == 0)
48
+-		    break;
49
+-	    }
50
+-
51
+-	    /* CID: 1295478 */
52
+-	    /* This should only "trip" if "keytype" is removed from builtins */
53
+-	    INSIST(icmd < sizeof(builtins)/sizeof(builtins[0]));
54
+-
55
+-#ifdef OPENSSL
56
+-	    builtins[icmd].desc[0] = "digest-name";
57
+-	    my_easprintf(&msg,
58
+-			 "set key type to use for authenticated requests, one of:%s",
59
+-			 list);
60
+-#else
61
+-	    builtins[icmd].desc[0] = "md5";
62
+-	    my_easprintf(&msg,
63
+-			 "set key type to use for authenticated requests (%s)",
64
+-			 list);
65
+-#endif
66
+-	    builtins[icmd].comment = msg;
67
+-	    free(list);
68
+-	}
69
+-
70
+ 	progname = argv[0];
71
+ 
72
+ 	{
73
+@@ -2558,11 +2519,11 @@ keytype(
74
+ 	key_type = keytype_from_text(digest_name, &digest_len);
75
+ 
76
+ 	if (!key_type) {
77
+-		fprintf(fp, "keytype is not valid. "
78
++		fprintf(fp, "keytype must be 'md5'%s\n",
79
+ #ifdef OPENSSL
80
+-			"Type \"help keytype\" for the available digest types.\n");
81
++			" or a digest type provided by OpenSSL");
82
+ #else
83
+-			"Only \"md5\" is available.\n");
84
++			"");
85
+ #endif
86
+ 		return;
87
+ 	}
88
+@@ -3580,109 +3541,6 @@ ntpq_custom_opt_handler(
89
+ 		break;
90
+ 	}
91
+ }
92
+-/*
93
+- * Obtain list of digest names
94
+- */
95
+-
96
+-#ifdef OPENSSL
97
+-# ifdef HAVE_EVP_MD_DO_ALL_SORTED
98
+-struct hstate {
99
+-   char *list;
100
+-   const char **seen;
101
+-   int idx;
102
+-};
103
+-#define K_PER_LINE 8
104
+-#define K_NL_PFX_STR "\n    "
105
+-#define K_DELIM_STR ", "
106
+-static void list_md_fn(const EVP_MD *m, const char *from, const char *to, void *arg )
107
+-{
108
+-    size_t len, n;
109
+-    const char *name, *cp, **seen;
110
+-    struct hstate *hstate = arg;
111
+-    EVP_MD_CTX *ctx;
112
+-    u_int digest_len;
113
+-    u_char digest[EVP_MAX_MD_SIZE];
114
+-
115
+-    if (!m)
116
+-        return; /* Ignore aliases */
117
+-
118
+-    name = EVP_MD_name(m);
119
+-
120
+-    /* Lowercase names aren't accepted by keytype_from_text in ssl_init.c */
121
+-
122
+-    for( cp = name; *cp; cp++ ) {
123
+-	if( islower((unsigned char)*cp) )
124
+-	    return;
125
+-    }
126
+-    len = (cp - name) + 1;
127
+-
128
+-    /* There are duplicates.  Discard if name has been seen. */
129
+-
130
+-    for (seen = hstate->seen; *seen; seen++)
131
+-        if (!strcmp(*seen, name))
132
+-	    return;
133
+-    n = (seen - hstate->seen) + 2;
134
+-    hstate->seen = erealloc(hstate->seen, n * sizeof(*seen));
135
+-    hstate->seen[n-2] = name;
136
+-    hstate->seen[n-1] = NULL;
137
+-
138
+-    /* Discard MACs that NTP won't accept.
139
+-     * Keep this consistent with keytype_from_text() in ssl_init.c.
140
+-     */
141
+-
142
+-    ctx = EVP_MD_CTX_new();
143
+-    EVP_DigestInit(ctx, EVP_get_digestbyname(name));
144
+-    EVP_DigestFinal(ctx, digest, &digest_len);
145
+-    EVP_MD_CTX_free(ctx);
146
+-    if (digest_len > (MAX_MAC_LEN - sizeof(keyid_t)))
147
+-        return;
148
+-
149
+-    if (hstate->list != NULL)
150
+-	len += strlen(hstate->list);
151
+-    len += (hstate->idx >= K_PER_LINE)? strlen(K_NL_PFX_STR): strlen(K_DELIM_STR);
152
+-
153
+-    if (hstate->list == NULL) {
154
+-	hstate->list = (char *)emalloc(len);
155
+-	hstate->list[0] = '\0';
156
+-    } else
157
+-	hstate->list = (char *)erealloc(hstate->list, len);
158
+-
159
+-    sprintf(hstate->list + strlen(hstate->list), "%s%s",
160
+-	    ((hstate->idx >= K_PER_LINE)? K_NL_PFX_STR : K_DELIM_STR),
161
+-	    name);
162
+-    if (hstate->idx >= K_PER_LINE)
163
+-	hstate->idx = 1;
164
+-    else
165
+-	hstate->idx++;
166
+-}
167
+-# endif
168
+-#endif
169
+-
170
+-static char *list_digest_names(void)
171
+-{
172
+-    char *list = NULL;
173
+-
174
+-#ifdef OPENSSL
175
+-# ifdef HAVE_EVP_MD_DO_ALL_SORTED
176
+-    struct hstate hstate = { NULL, NULL, K_PER_LINE+1 };
177
+-
178
+-    hstate.seen = (const char **) emalloc_zero(1*sizeof( const char * )); // replaces -> calloc(1, sizeof( const char * ));
179
+-
180
+-    INIT_SSL();
181
+-    EVP_MD_do_all_sorted(list_md_fn, &hstate);
182
+-    list = hstate.list;
183
+-    free(hstate.seen);
184
+-# else
185
+-    list = (char *)emalloc(sizeof("md5, others (upgrade to OpenSSL-1.0 for full list)"));
186
+-    strcpy(list, "md5, others (upgrade to OpenSSL-1.0 for full list)");
187
+-# endif
188
+-#else
189
+-    list = (char *)emalloc(sizeof("md5"));
190
+-    strcpy(list, "md5");
191
+-#endif
192
+-
193
+-    return list;
194
+-}
195
+ 
196
+ #define CTRLC_STACK_MAX 4
197
+ static volatile size_t		ctrlc_stack_len = 0;