Ejemplo n.º 1
0
int
main(int argc, const char **argv)
{
    jaro_credential_t cred = {0};
    int res = 0;

    if (argc < 2) {
	error("Usage: jaro-gnome-keyring <get|check|store|erase>");
	error("input from stdin: newline separated parameter=value tuples");
	error("i.e: protocol, path, username, host, password (password on store)");
	return 1;
    }

    if (read_credential(&cred)) {
	clear_credential(&cred);
	return 1;
    }

    if (strcmp(argv[1], "get") == 0) {
      res = get_password(&cred);
    }
    if (strcmp(argv[1], "check") == 0) {
      res = check_password(&cred);
    }
    else if (strcmp(argv[1], "store") == 0) {
      res = store_password(&cred);
    }
    else if (strcmp(argv[1], "erase") == 0) {
      res = erase_password(&cred);
    }
    clear_credential(&cred);

    return res;
}
int
main(int argc, const char **argv)
{
    git_credential_t cred = {0};

    if (argc < 2) {
	error("Usage: git credential-gnomekeyring <get|store|erase>");
	return 1;
    }

    if (read_credential(&cred)) {
	clear_credential(&cred);
	return 1;
    }

    if (strcmp(argv[1], "get") == 0) {
	get_password(&cred);
    }
    else if (strcmp(argv[1], "store") == 0) {
	store_password(&cred);
    }
    else if (strcmp(argv[1], "erase") == 0) {
	erase_password(&cred);
    }
    clear_credential(&cred);

    return 0;
}
Ejemplo n.º 3
0
int write_password_to_file(char *password) {

    FILE *password_file = fopen(PASSWORD_FILE, "w");
    if (NULL != password_file) {
        store_password(password, password_file);
        fclose(password_file);
        return 0;
    }
    return 1;
}