toolbox

Check-in [454cd3f8a2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:renew: add checks after popen calls
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 454cd3f8a24a44b2ccf3a22c2fa2ef4264287793e125bb22cf0f36fcaef1b06f
User & Date: jef 2019-04-23 08:43:43
Context
2019-05-02
21:32
http-code: add timeout flag check-in: f1da0d93bc user: jef tags: trunk
2019-04-23
08:43
renew: add checks after popen calls check-in: 454cd3f8a2 user: jef tags: trunk
2019-04-17
08:56
radios-check: simplify job data structure check-in: f049f8915e user: jef tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/renew/renew.c.

138
139
140
141
142
143
144


145
146
147
148
149
150
151
...
195
196
197
198
199
200
201


202
203
204
205
206
207
208
	char prefix[] = "Registry Expiry Date: ";
	char *deadline, *line = NULL;
	struct tm time;
	size_t linecapp;

	xasprintf(&cmd, "whois %s", renew->data.domain.domainname);
	file = popen(cmd, "r");


	while (getline(&line, &linecapp, file) != -1) {
		if ((deadline = strstr(line, prefix)) != NULL) {
			deadline += strlen(prefix);
			if (strptime(deadline, "%Y-%m-%dT%H:%M:%SZ", &time) == NULL) {
				die("unable to parse expiration date for domain '%s'",
						renew->data.domain.domainname);
			}
................................................................................

	xasprintf(&cmd, "openssl s_client -servername %s -connect %s:%d 2>/dev/null "
			"| openssl x509 -enddate -noout 2>/dev/null",
			renew->data.tls.servername,
			renew->data.tls.address,
			renew->data.tls.port);
	file = popen(cmd, "r+");


	fwrite("QUIT", 1, strlen("QUIT"), file);
	while (getline(&line, &linecapp, file) != -1) {
		if ((deadline = strstr(line, prefix)) != NULL) {
			deadline += strlen(prefix);
			if (strptime(deadline, "%b %d %H:%M:%S %Y GMT", &time) == NULL) {
				die("unable to parse expiration date for tls '%s'",
						renew->data.tls.servername);







>
>







 







>
>







138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
...
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
	char prefix[] = "Registry Expiry Date: ";
	char *deadline, *line = NULL;
	struct tm time;
	size_t linecapp;

	xasprintf(&cmd, "whois %s", renew->data.domain.domainname);
	file = popen(cmd, "r");
	if (file == NULL)
		die("unable to launch command '%s'", cmd);
	while (getline(&line, &linecapp, file) != -1) {
		if ((deadline = strstr(line, prefix)) != NULL) {
			deadline += strlen(prefix);
			if (strptime(deadline, "%Y-%m-%dT%H:%M:%SZ", &time) == NULL) {
				die("unable to parse expiration date for domain '%s'",
						renew->data.domain.domainname);
			}
................................................................................

	xasprintf(&cmd, "openssl s_client -servername %s -connect %s:%d 2>/dev/null "
			"| openssl x509 -enddate -noout 2>/dev/null",
			renew->data.tls.servername,
			renew->data.tls.address,
			renew->data.tls.port);
	file = popen(cmd, "r+");
	if (file == NULL)
		die("unable to launch command '%s'", cmd);
	fwrite("QUIT", 1, strlen("QUIT"), file);
	while (getline(&line, &linecapp, file) != -1) {
		if ((deadline = strstr(line, prefix)) != NULL) {
			deadline += strlen(prefix);
			if (strptime(deadline, "%b %d %H:%M:%S %Y GMT", &time) == NULL) {
				die("unable to parse expiration date for tls '%s'",
						renew->data.tls.servername);