Allow specification of username in URL

This commit is contained in:
pooler 2012-08-21 17:49:43 +02:00
parent b53230ce9b
commit 5b9fd9c731

View file

@ -880,14 +880,17 @@ static void parse_arg (int key, char *arg)
rpc_url = malloc((strlen(arg) + 8) * sizeof(char));
sprintf(rpc_url, "http://%s", arg);
}
p = strchr(rpc_url, '@');
p = strrchr(rpc_url, '@');
if (p) {
char *ap = strstr(rpc_url, "://") + 3;
*p = '\0';
if (!strchr(ap, ':'))
show_usage_and_exit(1);
free(rpc_userpass);
rpc_userpass = strdup(ap);
if (strchr(ap, ':')) {
free(rpc_userpass);
rpc_userpass = strdup(ap);
} else {
free(rpc_user);
rpc_user = strdup(ap);
}
memmove(ap, p + 1, (strlen(p + 1) + 1) * sizeof(char));
}
break;