[iwhd patch 1/2] Support registration in RHEV-M 2.2

Jim Meyering jim at meyering.net
Thu May 12 15:47:27 UTC 2011


Pete Zaitcev wrote:
> Support registration in RHEV-M 2.2.
>
> The following small adjustments were required:
>
>  - Cancel the workaround for bz#670397, because it used hardcoded
>    base API. But the base differs in 2.2.
>
>  - Make sure that we transmit data over SSL (albeit in an insecure way).
>
>  - Make some comparisons case-insensitive.

Hi Pete,
Nice change.

Please mention in the log that this is to accommodate
a recent RHEV-M API change (maybe even referencing the URL
that Mark McLoughlin provided) and adjust this comment,
assuming the same change is (going to be?) required for 2.3 and on.

...
> @@ -579,7 +594,8 @@ static struct stor_dom *apistordom(struct config *cfg,
...
> -		if (strcmp((char *)ettext->content, "NFS") != 0)
> +		/* RHEV-M 2.2 uses "nfs", RHEV-M 2.3 and 3 use "NFS" */
> +		if (stricmp((char *)ettext->content, "NFS") != 0)
>  			continue;
>
>  		uuidsd = xmlGetProp(et, (xmlChar *)"id");
...
> @@ -812,7 +829,8 @@ static struct stor_dom *apistart(struct config *cfg)
>  {
>  	struct http_uri huri;
>  	struct stor_dom *sd;
> -	char *host, *path, *base;
> +	char *scheme, *host, *path, *base;
> +	int is_ssl;

Please use "bool" here, rather than "int".
(and false/true below, in place of 0/1)

>  	char *pathsd, *pathdc;
>  	char *authraw, *authhdr;
>  	size_t authrlen, authhlen;
> @@ -837,16 +855,35 @@ static struct stor_dom *apistart(struct config *cfg)
>  	host = strndup(huri.hostname, huri.hostname_len);
>  	if (!host)
>  		goto err_alloc;
> +	scheme = strndup(huri.scheme, huri.scheme_len);
> +	if (!host)
> +		goto err_alloc;
> +
> +	if (strcmp(scheme, "http") == 0) {
> +		is_ssl = 0;
> +	} else if (strcmp(scheme, "https") == 0) {
> +		is_ssl = 1;
> +	} else {
> +		fprintf(stderr, "ERROR Invalid URL scheme `%s'\n", scheme);
> +		exit(EXIT_FAILURE);
> +	}
>
>  	if (huri.port)
> -		rc = asprintf(&base, "http://%s:%u", host, huri.port);
> +		rc = asprintf(&base, "%s://%s:%u", scheme, host, huri.port);
>  	else
> -		rc = asprintf(&base, "http://%s", host);
> +		rc = asprintf(&base, "%s://%s", scheme, host);
>  	if (rc < 0)
>  		goto err_alloc;
>
>  	connection.base = base;
>  	connection.curl = curl_easy_init();
> +	if (is_ssl) {
> +		/*
> +		 * We are sorry about not checking the certificates.
> +		 */

How about adding a FIXME comment instead,
so that we are more likely to spot it later when looking
for things to improve:

                /*
                 * FIXME: check certificates, eventually
                 */

> +		curl_easy_setopt(connection.curl, CURLOPT_SSL_VERIFYHOST, 0);
> +		curl_easy_setopt(connection.curl, CURLOPT_SSL_VERIFYPEER, 0);
> +	}
>
>  	headers = NULL;


More information about the iwhd-devel mailing list