Esempio n. 1
0
File: http.c Progetto: 777/test-proj
static void init_curl_http_auth(CURL *result)
{
	if (user_name) {
		struct strbuf up = STRBUF_INIT;
		if (!user_pass)
			user_pass = xstrdup(git_getpass("Password: "******"%s:%s", user_name, user_pass);
		curl_easy_setopt(result, CURLOPT_USERPWD,
				 strbuf_detach(&up, NULL));
	}
}
Esempio n. 2
0
File: http.c Progetto: 777/test-proj
static int has_cert_password(void)
{
	if (ssl_cert_password != NULL)
		return 1;
	if (ssl_cert == NULL || ssl_cert_password_required != 1)
		return 0;
	/* Only prompt the user once. */
	ssl_cert_password_required = -1;
	ssl_cert_password = git_getpass("Certificate Password: ");
	if (ssl_cert_password != NULL) {
		ssl_cert_password = xstrdup(ssl_cert_password);
		return 1;
	} else
		return 0;
}
Esempio n. 3
0
static char *git_getpass_with_description(const char *what, const char *desc)
{
	struct strbuf prompt = STRBUF_INIT;
	char *r;

	if (desc)
		strbuf_addf(&prompt, "%s for '%s': ", what, desc);
	else
		strbuf_addf(&prompt, "%s: ", what);
	/*
	 * NEEDSWORK: for usernames, we should do something less magical that
	 * actually echoes the characters. However, we need to read from
	 * /dev/tty and not stdio, which is not portable (but getpass will do
	 * it for us). http.c uses the same workaround.
	 */
	r = git_getpass(prompt.buf);

	strbuf_release(&prompt);
	return xstrdup(r);
}
Esempio n. 4
0
static char *credential_ask_one(const char *what, struct credential *c)
{
	struct strbuf desc = STRBUF_INIT;
	struct strbuf prompt = STRBUF_INIT;
	char *r;

	credential_describe(c, &desc);
	if (desc.len)
		strbuf_addf(&prompt, "%s for '%s': ", what, desc.buf);
	else
		strbuf_addf(&prompt, "%s: ", what);

	/* FIXME: for usernames, we should do something less magical that
	 * actually echoes the characters. However, we need to read from
	 * /dev/tty and not stdio, which is not portable (but getpass will do
	 * it for us). http.c uses the same workaround. */
	r = git_getpass(prompt.buf);

	strbuf_release(&desc);
	strbuf_release(&prompt);
	return xstrdup(r);
}