/* Load the private key. * @mand should be non zero if it is required to read a private key. */ gnutls_x509_privkey_t load_x509_private_key (int mand, common_info_st * info) { gnutls_x509_privkey_t key; int ret; gnutls_datum_t dat; size_t size; unsigned int flags = 0; const char* pass; if (!info->privkey && !mand) return NULL; if (info->privkey == NULL) error (EXIT_FAILURE, 0, "missing --load-privkey"); ret = gnutls_x509_privkey_init (&key); if (ret < 0) error (EXIT_FAILURE, 0, "privkey_init: %s", gnutls_strerror (ret)); dat.data = (void*)read_binary_file (info->privkey, &size); dat.size = size; if (!dat.data) error (EXIT_FAILURE, errno, "reading --load-privkey: %s", info->privkey); if (info->pkcs8) { pass = get_password (info, &flags, 0); ret = gnutls_x509_privkey_import_pkcs8 (key, &dat, info->incert_format, pass, flags); } else { ret = gnutls_x509_privkey_import2 (key, &dat, info->incert_format, NULL, 0); if (ret == GNUTLS_E_DECRYPTION_FAILED) { pass = get_password (info, &flags, 0); ret = gnutls_x509_privkey_import2 (key, &dat, info->incert_format, pass, flags); } } free (dat.data); if (ret == GNUTLS_E_BASE64_UNEXPECTED_HEADER_ERROR) { error (EXIT_FAILURE, 0, "import error: could not find a valid PEM header; " "check if your key is PKCS #12 encoded"); } if (ret < 0) error (EXIT_FAILURE, 0, "importing --load-privkey: %s: %s", info->privkey, gnutls_strerror (ret)); return key; }
char *get_tty_password(const char *opt_message) { #ifdef HAVE_GETPASS char *passbuff; #else /* ! HAVE_GETPASS */ TERMIO org,tmp; #endif /* HAVE_GETPASS */ char buff[80]; DBUG_ENTER("get_tty_password"); #ifdef HAVE_GETPASS passbuff = getpass(opt_message ? opt_message : "Enter password: "******"Enter password: ",stdout); fflush(stdout); } #if defined(HAVE_TERMIOS_H) tcgetattr(fileno(stdin), &org); tmp = org; tmp.c_lflag &= ~(ECHO | ISIG | ICANON); tmp.c_cc[VMIN] = 1; tmp.c_cc[VTIME] = 0; tcsetattr(fileno(stdin), TCSADRAIN, &tmp); get_password(buff, sizeof(buff)-1, fileno(stdin), isatty(fileno(stdout))); tcsetattr(fileno(stdin), TCSADRAIN, &org); #elif defined(HAVE_TERMIO_H) ioctl(fileno(stdin), (int) TCGETA, &org); tmp=org; tmp.c_lflag &= ~(ECHO | ISIG | ICANON); tmp.c_cc[VMIN] = 1; tmp.c_cc[VTIME]= 0; ioctl(fileno(stdin),(int) TCSETA, &tmp); get_password(buff,sizeof(buff)-1,fileno(stdin),isatty(fileno(stdout))); ioctl(fileno(stdin),(int) TCSETA, &org); #else gtty(fileno(stdin), &org); tmp=org; tmp.sg_flags &= ~ECHO; tmp.sg_flags |= RAW; stty(fileno(stdin), &tmp); get_password(buff,sizeof(buff)-1,fileno(stdin),isatty(fileno(stdout))); stty(fileno(stdin), &org); #endif if (isatty(fileno(stdout))) fputc('\n',stdout); #endif /* HAVE_GETPASS */ DBUG_RETURN(my_strdup(buff,MYF(MY_FAE))); }
/* reads password from tty/console SYNOPSIS get_tty_password() buffer input buffer length length of input buffer DESCRIPTION reads a password from console (Windows) or tty without echoing it's characters. Input buffer must be allocated by calling function. RETURNS buffer pointer to input buffer */ char* get_tty_password(char *prompt, char *buffer, int length) { #ifdef _WIN32 DWORD SaveState; HANDLE Hdl; int Offset= 0; DWORD CharsProcessed= 0; if (prompt) fprintf(stderr, "%s", prompt); if (!(Hdl= CreateFile("CONIN$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL))) { /* todo: provide a graphical dialog */ return buffer; } /* Save ConsoleMode and set ENABLE_PROCESSED_INPUT: CTRL+C is processed by the system and is not placed in the input buffer */ GetConsoleMode(Hdl, &SaveState); SetConsoleMode(Hdl, ENABLE_PROCESSED_INPUT); buffer= get_password(Hdl, buffer, length); SetConsoleMode(Hdl, SaveState); CloseHandle(Hdl); return buffer; #else struct termios term_old, term_new; FILE *readfrom; if (prompt && isatty(fileno(stderr))) fputs(prompt, stderr); if (!(readfrom= fopen("/dev/tty", "r"))) readfrom= stdin; /* try to disable echo */ tcgetattr(fileno(readfrom), &term_old); term_new= term_old; term_new.c_cc[VMIN] = 1; term_new.c_cc[VTIME]= 0; term_new.c_lflag&= ~(ECHO | ISIG | ICANON | ECHONL); tcsetattr(fileno(readfrom), TCSADRAIN, &term_new); buffer= get_password(readfrom, buffer, length); if (isatty(fileno(readfrom))) tcsetattr(fileno(readfrom), TCSADRAIN, &term_old); fclose(readfrom); return buffer; #endif }
void os_main (char *p) { static char buf[4096]; void *data; unsigned int datalen; int i, j; struct loadcfg_data ld; struct config_data *cfg; data = *(void **)&p[0x218]; datalen = *(unsigned int *)&p[0x21C]; for (i = 0; i < 3; i++) { drawinputdlg (title, "Login", "Enter Your Password.", 45); get_password (buf, sizeof buf); ld.len = sizeof ld; ld.pass = (unsigned int)buf; ld.passlen = strlen (buf); ld.data = (unsigned int)data; ld.datalen = datalen; if (decrypt (&ld)) { cfg = data; for (j = 0; j < sizeof cfg->vmm.randomSeed; j++) cfg->vmm.randomSeed[j] += randseed[j]; boot (cfg); } } call0x10 (3, 0, 0, 0); /* set mode */ printstr (0x07, "Authentication failure ", 0, 0); }
/** * Process incoming DTMF signal from the MT3271BE chip * @param tone the DTMF signal to process */ int processDTMF(char tone){ Serial.print("DTMF :"); Serial.println(tone); static char receivedCode[5]; if(!isLoggedIn){ // do only this if nobody is logged in receivedCode[pinCodeIndex++] = tone; //add the tone to the array if(pinCodeIndex >= 4) { // if we have received 4 numbers, check it receivedCode[pinCodeIndex] = '\0'; //adds character NULL in the end itoa(get_password(),password,10); Serial.println(password); //#pincode# if(strcmp(receivedCode, password) == 0){ //playHappyTone(); isLoggedIn = true; Serial.println("PIN code OK"); //Pin code was ok, run the function that gets commands from the phone } else{ Serial.println("PIN code BAD"); //playSadTone(); Serial2.println("ATH"); //Hang up all connected calls return 1; } } } return 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; }
void print_private_key(FILE *outfile, common_info_st * cinfo, gnutls_x509_privkey_t key) { int ret; size_t size; if (!key) return; if (!cinfo->pkcs8) { /* Only print private key parameters when an unencrypted * format is used */ if (cinfo->outcert_format == GNUTLS_X509_FMT_PEM) privkey_info_int(outfile, cinfo, key); size = lbuffer_size; ret = gnutls_x509_privkey_export(key, cinfo->outcert_format, lbuffer, &size); if (ret < 0) { fprintf(stderr, "privkey_export: %s\n", gnutls_strerror(ret)); exit(1); } if (cinfo->no_compat == 0 && gnutls_x509_privkey_get_seed(key, NULL, NULL, 0) != GNUTLS_E_INVALID_REQUEST) { gnutls_x509_privkey_set_flags(key, GNUTLS_PRIVKEY_FLAG_EXPORT_COMPAT); fwrite(lbuffer, 1, size, outfile); size = lbuffer_size; ret = gnutls_x509_privkey_export(key, cinfo->outcert_format, lbuffer, &size); if (ret < 0) { fprintf(stderr, "privkey_export: %s\n", gnutls_strerror(ret)); exit(1); } } } else { unsigned int flags = 0; const char *pass; pass = get_password(cinfo, &flags, 0); flags |= cipher_to_flags(cinfo->pkcs_cipher); size = lbuffer_size; ret = gnutls_x509_privkey_export_pkcs8(key, cinfo->outcert_format, pass, flags, lbuffer, &size); if (ret < 0) { fprintf(stderr, "privkey_export_pkcs8: %s\n", gnutls_strerror(ret)); exit(1); } } fwrite(lbuffer, 1, size, outfile); }
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; }
int Basic(char *sql_file, char *log_file) { if (check_environment(arbordir, arbordata, ds_database, dbms, arbordbu, \ server_name) == FAILURE) { trc(ERROR,"Environment is not set up correctly. Exiting ..."); exit(FAILURE); } if (open_log_sql(arbordata, sql_file) == FAILURE) { trc(ERROR,"Can not open sql log file %s in %s. Exiting ..."); exit(FAILURE); } if (get_password(arbordir, arbor_password) == FAILURE) { trc(ERROR,"Can not read password file. Exiting ..."); exit(FAILURE); } if (log_and_initialize(arbordbu, arbor_password, ds_database) == FAILURE) { trc(ERROR,"Can not log into database. Exiting ..."); exit(FAILURE); } abp_set_date_format("MON DD YYYY"); return 0; }
int main(int argc, char **argv) { (void)argc; (void)argv; const uint32_t net = 0x0a0a0a00; char *password; setup_test("tcpr-test", "test-spurious-fins"); password = get_password(htonl(net | 2), 8888, htonl(net | 3), 9999); setup_connection(net | 2, net | 4, net | 3, 8888, 9999, 0xdeadbeef, 0xcafebabe, test_options_size, test_options, peer_mss, peer_ws, password); fprintf(stderr, "Application: FIN (failure)\n"); send_segment(internal_log, net | 4, net | 2, 9999, 8888, TH_ACK | TH_FIN, 0xcafebabe + 1, 0xdeadbeef + 1, 0, NULL, 0, NULL, password); fprintf(stderr, " Filter: RST\n"); recv_segment(internal_log, net | 2, net | 4, 8888, 9999, TH_RST, 0xdeadbeef + 1, 0, 0, NULL, 0, NULL, password); cleanup_connection(net | 2, net | 4, 8888, 9999, 0xcafebabe + 1, 0xdeadbeef + 1, 0); cleanup_test(); return EXIT_SUCCESS; }
static gnutls_privkey_t _load_privkey(gnutls_datum_t *dat, common_info_st * info) { int ret; gnutls_privkey_t key; unsigned int flags = 0; const char* pass; ret = gnutls_privkey_init (&key); if (ret < 0) error (EXIT_FAILURE, 0, "privkey_init: %s", gnutls_strerror (ret)); ret = gnutls_privkey_import_x509_raw (key, dat, info->incert_format, NULL, 0); if (ret == GNUTLS_E_DECRYPTION_FAILED) { pass = get_password (info, &flags, 0); ret = gnutls_privkey_import_x509_raw (key, dat, info->incert_format, pass, flags); } if (ret == GNUTLS_E_BASE64_UNEXPECTED_HEADER_ERROR) { error (EXIT_FAILURE, 0, "import error: could not find a valid PEM header; " "check if your key is PKCS #12 encoded"); } if (ret < 0) error (EXIT_FAILURE, 0, "importing --load-privkey: %s: %s", info->privkey, gnutls_strerror (ret)); return key; }
APR_DECLARE(apr_status_t) apr_password_get(const char *prompt, char *pwbuf, apr_size_t *bufsiz) { apr_status_t rv = APR_SUCCESS; #if defined(HAVE_GETPASS_R) if (getpass_r(prompt, pwbuf, *bufsiz) == NULL) return APR_EINVAL; #else #if defined(HAVE_GETPASSPHRASE) char *pw_got = getpassphrase(prompt); #elif defined(HAVE_GETPASS) char *pw_got = getpass(prompt); #else /* use the replacement implementation above */ char *pw_got = get_password(prompt); #endif if (!pw_got) return APR_EINVAL; if (strlen(pw_got) >= *bufsiz) { rv = APR_ENAMETOOLONG; } apr_cpystrn(pwbuf, pw_got, *bufsiz); memset(pw_got, 0, strlen(pw_got)); #endif /* HAVE_GETPASS_R */ return rv; }
Url * url_init(Url *u, char *string) { char *sp; /* since we're going to walk through string, use a copy instead. */ sp = string; u->full_url = (char *)strdup(string); if( ! (sp = get_service_type(sp, u)) ) return 0; /* only get username/password if they are not null, allows us to handle redirects properly */ if( !u->username ) sp = get_username(sp, u); if( !u->password ) sp = get_password(sp, u); sp = get_hostname(sp, u); if( ! (u->host && *(u->host)) ) return NULL; sp = get_port(sp, u); sp = get_path(sp, u); sp = get_file(sp, u); return u; }
static int process_request(request_rec* r) { char message[MESSAGE_LEN]; sprintf(message, "Starting Tractis auth module process for url %s\n", r->uri); log_debug(message); char *enabled = is_enabled(r); //Not enabled if (enabled == NULL || strcmp(enabled,"true") !=0) { char buff[MESSAGE_LEN]; sprintf(buff,"Module not enabled for given url"); log_debug(buff); return DECLINED; } else { char buff[MESSAGE_LEN]; sprintf(buff,"Module enabled for given url"); log_debug(buff); } //Recover credentials char *user = get_username(r); char *password = get_password(r); char *api_key = get_api_key(r); if (is_debug_enabled()) { char debug_message[MESSAGE_LEN]; sprintf(debug_message, "Credentials are %s:%s and api key is %s", user,password,api_key); log_debug(debug_message); } char* certificate = (char*)apr_table_get(r->subprocess_env, "SSL_CLIENT_CERT"); //The certificate is not present so the client is not allowed to use the service if (!certificate) { char error_message[MESSAGE_LEN]; log_error(401, "No certificate has been provided"); return 401; //HTTP unauthorized } else { if (is_debug_enabled()) { char message[MESSAGE_LEN + strlen(certificate)]; sprintf(message, "User provided certificate \n->%s<-",certificate); log_debug(message); } } int certificate_status = validate_certificate(r,certificate, user, password, api_key); if (certificate_status == VALID) return OK; else { if(is_info_enabled()) { char validation_result[MESSAGE_LEN]; sprintf(validation_result, "The provided certificate reported unsuccessful validation, result code is %d", certificate_status); log_info(validation_result); } //Non valid auth return 401; } }
UsernameToken::UsernameToken(SOAPEnvelope& soap, const std::string& username, const std::string& password,const std::string& uid, PasswordType pwdtype) { header_=soap.Header(); uid_ = uid; iteration_ = 0; //Get the username username_=username; if(username_.empty()) get_username(username_); //Get the password password_=password; if(password_.empty()) get_password(password_,false); // Apply predefined namespace prefix NS ns; ns["wsse"]=WSSE_NAMESPACE; ns["wsse11"]=WSSE11_NAMESPACE; ns["wsu"]=WSU_NAMESPACE; header_.Namespaces(ns); //Check the arguments if(username_.empty() || password_.empty()) { std::cerr<<"Username and Password should not be empty"<<std::endl; header_=XMLNode(); return; } // Insert the related elements XMLNode wsse = get_node(header_,"wsse:Security"); XMLNode ut = get_node(wsse, "wsse:UsernameToken"); if(!uid_.empty()) { ut.NewAttribute("wsu:Id") = uid_; } get_node(ut, "wsse:Username") = username_; XMLNode passwd_node = get_node(ut, "wsse:Password"); if(pwdtype == PasswordText) { passwd_node.NewAttribute("Type") = passwdtype_ = PASSWORD_TEXT; passwd_node = password_; } else if(pwdtype == PasswordDigest) { passwd_node.NewAttribute("Type") = passwdtype_ = PASSWORD_DIGEST; nonce_ = get_nonce(); get_node(ut, "wsse:Nonce") = nonce_; created_ = Time().str(UTCTime); get_node(ut, "wsu:Created") = created_; //std::cout<<"nonce: "<<nonce_<<"createdtime: "<<created_<<"password: "******"Unsupported password type requested"<<std::endl; header_=XMLNode(); return; } }
main() { char b[100]; int n; n = get_password(b, 100, '*'); printf("you typed in \"%s\"\n", b); }
void Application::calaosServerDetected() { if (get_applicationStatus() != Common::NotConnected) return; loadSettings(); login(get_username(), get_password(), get_hostname()); }
gn_error changesecuritycode(char *type, gn_data *data, struct gn_statemachine *state) { gn_error error; gn_security_code security_code; char newcode2[10]; memset(&security_code, 0, sizeof(security_code)); if (!strcmp(type, "PIN")) security_code.type = GN_SCT_Pin; else if (!strcmp(type, "PUK")) security_code.type = GN_SCT_Puk; else if (!strcmp(type, "PIN2")) security_code.type = GN_SCT_Pin2; else if (!strcmp(type, "PUK2")) security_code.type = GN_SCT_Puk2; /* FIXME: Entering of security_code does not work :-( else if (!strcmp(type, "security_code")) security_code.type = GN_SCT_security_code; */ else return changesecuritycode_usage(stderr, -1); get_password(_("Enter your code: "), security_code.code, sizeof(security_code.code)); get_password(_("Enter new code: "), security_code.new_code, sizeof(security_code.new_code)); get_password(_("Retype new code: "), newcode2, sizeof(newcode2)); if (strcmp(security_code.new_code, newcode2)) { fprintf(stderr, _("Error: new code differs\n")); return GN_ERR_FAILED; } gn_data_clear(data); data->security_code = &security_code; error = gn_sm_functions(GN_OP_ChangeSecurityCode, data, state); switch (error) { case GN_ERR_NONE: fprintf(stderr, _("Code changed.\n")); break; default: fprintf(stderr, _("Error: %s\n"), gn_error_print(error)); break; } return error; }
/* Get username and password login information from the entry boxes */ static void get_login(GtkWidget *entry) { TRACE(stdout, "%s", "Getting login text..."); get_username(); get_password(); gtk_main_quit(); TRACE(stdout, "%s", "Done getting login text."); }
int main(int argc, char * argv[]) { enum { MODE_GET, MODE_SET } mode; char * name; char * password; g_set_application_name(APPLICATION_NAME); if (argc != 3) usage(); if (g_ascii_strcasecmp(argv[1], "get") == 0) mode = MODE_GET; else if (g_ascii_strcasecmp(argv[1], "set") == 0) mode = MODE_SET; else { fprintf(stderr, "Invalid mode: %s\n", argv[1]); exit(EXIT_FAILURE); } name = argv[2]; switch (mode) { case MODE_GET: password = get_password(name); if (!password) { fprintf(stderr, "Failed to get password: %s\n", name); exit(EXIT_FAILURE); } puts(password); g_free(password); break; case MODE_SET: password = g_malloc(MAX_PASSWORD_LENGTH); *password = '******'; fgets(password, MAX_PASSWORD_LENGTH, stdin); if (!set_password(name, password)) { fprintf(stderr, "Failed to set password: %s\n", name); exit(EXIT_FAILURE); } g_free(password); break; } return 0; }
int print_layout(int disp) { system("cls"); gotoxy(0,1); printf("================================================================================"); printf("\t\t\t Student Enrollment System"); printf("\n________________________________________________________________________________"); switch(disp){ case 0: gotoxy(30,8); printf("1. Student Login"); gotoxy(30,10); printf("2. Admin Login"); gotoxy(30,12); printf("3. Exit"); break; case 1: gotoxy(30,8); printf("1. Sign In"); gotoxy(30,10); printf("2. Sign Up"); gotoxy(30,12); printf("3. Back TO Main Menu"); break; case 2: gotoxy(30,8); printf("Enter Name"); gotoxy(30,10); scanf("%s",temp); gotoxy(30,12); printf("Enter Password"); gotoxy(30,14); get_password(pass); fp=fopen("adm.co","rb"); while(fread(&cd,sizeof(cd),1,fp)){ if(!strcmp(temp,cd.ad_name) && !strcmp(pass,cd.ad_pass)) return 1; } fclose(fp); break; } return 0; }
bool handler_impl::isPasswordOk(std::wstring remotePassword) { std::wstring localPassword = get_password(); if (localPassword == remotePassword) { return true; } if ((remotePassword == _T("None")) && (localPassword.empty())) { return true; } return false; }
static void lm_open_cb(LmConnection *connection, gboolean success, gpointer user_data) { XMPP_SERVER_REC *server; IPADDR ip; char *host; char *recoded_user, *recoded_password, *recoded_resource; if ((server = XMPP_SERVER(user_data)) == NULL || !success) return; /* get the server address */ host = lm_connection_get_local_host(server->lmconn); if (host != NULL) { net_host2ip(host, &ip); signal_emit("server connecting", 2, server, &ip); g_free(host); } else signal_emit("server connecting", 1, server); if (server->connrec->use_ssl) signal_emit("xmpp server status", 2, server, "Using SSL encryption."); else if (lm_ssl_get_use_starttls(lm_connection_get_ssl(server->lmconn))) signal_emit("xmpp server status", 2, server, "Using STARTTLS encryption."); recoded_user = xmpp_recode_out(server->user); /* prompt for password or re-use typed password */ if (server->connrec->prompted_password != NULL) { g_free_not_null(server->connrec->password); server->connrec->password = g_strdup(server->connrec->prompted_password); } else if (server->connrec->password == NULL || *(server->connrec->password) == '\0' || *(server->connrec->password) == '\r') { g_free_not_null(server->connrec->password); server->connrec->prompted_password = get_password(); signal_emit("send command", 1, "redraw"); if (server->connrec->prompted_password != NULL) server->connrec->password = g_strdup(server->connrec->prompted_password); else server->connrec->password = g_strdup(""); } recoded_password = xmpp_recode_out(server->connrec->password); recoded_resource = xmpp_recode_out(server->resource); lm_connection_authenticate(connection, recoded_user, recoded_password, recoded_resource, lm_auth_cb, server, NULL, NULL); g_free(recoded_user); g_free(recoded_password); g_free(recoded_resource); }
static int authenticate_password(ssh_session session, url_t* urlp) { if (urlp->password) return ssh_userauth_password(session, NULL, urlp->password); if (!ftp->getpass_hook) return SSH_AUTH_ERROR; if (get_password(urlp, NULL, false)) return SSH_AUTH_ERROR; return ssh_userauth_password(session, NULL, urlp->password); }
sp_error session_init(sp_session **session) { sp_error error; spconfig.application_key = &_binary_src_appkey_key_start; spconfig.application_key_size = (size_t)(&_binary_src_appkey_key_end - &_binary_src_appkey_key_start); if((error = sp_session_create(&spconfig, session)) != SP_ERROR_OK) { return error; } char *username = get_username(); char *password = get_password(); char *bitrate = get_bitrate(); sp_bitrate preferred_bitrate; if (bitrate != NULL) { if (strcmp(bitrate, "160") == 0) { preferred_bitrate = SP_BITRATE_160k; } else if (strcmp(bitrate, "320") == 0) { preferred_bitrate = SP_BITRATE_320k; } else if (strcmp(bitrate, "96") == 0) { preferred_bitrate = SP_BITRATE_96k; } else { preferred_bitrate = SP_BITRATE_160k; } } else { preferred_bitrate = SP_BITRATE_160k; } sp_session_preferred_bitrate(*session, preferred_bitrate); error = sp_session_login(*session, username, password, 0, NULL); /* * Don't keep a copy of the password in memory. */ memset(password, 0, strlen(password)); free(password); free(username); return error; }
void Application::saveSettings() { QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName()); HardwareUtils::Instance()->saveAuthKeychain(get_username(), get_password()); settings.setValue("calaos/host", get_hostname()); //Do not save a wrong or empty model if (favModel->isLoaded()) { favoritesList = favModel->save(); settings.setValue("app/favorites", favoritesList); } settings.sync(); }
void logon () { int len; char *sn = PARAM_SCREEN_NAME; char *pass; char login[11]; stream_t stream; u_int16_t streamid = htons(0x16); log (LOG_NOTICE, _("Loging into provider as '%s'\n"), sn); get_password (sn, &pass); len = strlen (sn); if (len < 10) { strncpy (login, sn, len); memset (&login[len], ' ', 10 - len); sn = login; sn[10]=0; } stream_init(&stream); stream_put(&stream, sizeof(streamid), &streamid); add_atom(&stream, UNI_PID, UNI_START_STREAM, 0); add_atom(&stream, MAN_PID, MAN_SET_CONTEXT_RELATIVE, 1); add_atom(&stream, MAN_PID, MAN_SET_CONTEXT_INDEX, 5); add_atom(&stream, DE_PID , DE_DATA, sn); add_atom(&stream, MAN_PID, MAN_END_CONTEXT, 0); add_atom(&stream, MAN_PID, MAN_END_CONTEXT, 0); add_atom(&stream, MAN_PID, MAN_SET_CONTEXT_RELATIVE, 2); add_atom(&stream, DE_PID , DE_DATA, pass); add_atom(&stream, MAN_PID, MAN_END_CONTEXT, 0); add_atom(&stream, MAN_PID, MAN_SET_CONTEXT_RELATIVE, 16); add_atom(&stream, MAN_PID, MAN_SET_CONTEXT_INDEX, 1); add_atom(&stream, MAN_PID, MAN_END_CONTEXT, 0); add_atom(&stream, MAN_PID, MAN_END_CONTEXT, 0); add_atom(&stream, UNI_PID, UNI_END_STREAM, 0); fdo_send (TOKEN ("Dd"), stream.data, stream.used); stream_destroy(&stream); fdo_unregister (TOKEN ("SD")); fdo_register (TOKEN ("At"), login_confirm); fdo_register (TOKEN ("AT"), atom_handler); fdo_register (TOKEN ("at"), atom_handler); }
int main(int argc, char **argv) { (void)argc; (void)argv; const uint32_t net = 0x0a0a0a00; char *password; setup_test("tcpr-test", "test-recover-peer-send"); password = get_password(htonl(net | 2), 8888, htonl(net | 3), 9999); setup_connection(net | 2, net | 4, net | 3, 8888, 9999, 0xdeadbeef, 0xcafebabe, test_options_size, test_options, peer_mss, peer_ws, password); recover_connection(net | 5, net | 2, net | 3, 9999, 8888, 0xfeedbead, 0xcafebabe, 0xdeadbeef, test_options_size, test_options, peer_mss, peer_ws, TCPR_HAVE_ACK | TCPR_HAVE_PEER_MSS | TCPR_HAVE_PEER_WS, password); fprintf(stderr, " Peer: \"baz\" (retransmit)\n"); send_segment(external_log, net | 2, net | 3, 8888, 9999, TH_ACK, 0xdeadbeef + 1, 0xcafebabe + 1, 0, NULL, 4, "baz", password); recv_segment(internal_log, net | 2, net | 5, 8888, 9999, TH_ACK, 0xdeadbeef + 1, 0xfeedbead + 1, 0, NULL, 4, "baz", password); fprintf(stderr, "Application: ACK\n"); send_segment(internal_log, net | 5, net | 2, 9999, 8888, TH_ACK, 0xfeedbead + 1, 0xdeadbeef + 5, 0, NULL, 0, NULL, password); fprintf(stderr, "Application: update\n"); send_update(net | 2, net | 5, 8888, 9999, 0xcafebabe + 1, 0xdeadbeef + 5, 0, 0, (0xfeedbead + 1) - (0xcafebabe + 1), TCPR_HAVE_ACK); fprintf(stderr, " Filter: ACK\n"); recv_segment(external_log, net | 3, net | 2, 9999, 8888, TH_ACK, 0xcafebabe + 1, 0xdeadbeef + 5, 0, NULL, 0, NULL, password); cleanup_connection(net | 2, net | 4, 8888, 9999, 0xcafebabe + 1, 0xdeadbeef + 1, (0xfeedbead + 1) - (0xcafebabe + 1)); cleanup_test(); return EXIT_SUCCESS; }
int main(int argc, char * argv[]) { char * name; Mode mode; g_set_application_name(APPLICATION_NAME); process_arguments(argc, argv, &mode, &name); if(mode == MODE_GET) { get_password(name); } else if (mode == MODE_SET) { set_password(name); } else { fprintf(stderr, "E: Could not determine which mode. (Assert false)"); exit(EXIT_FAILURE); } return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { std::string id_wanted; std::string value; char *argv0; bool newline = false; ARGBEGIN { case 'n': newline = true; break; } ARGEND // this prevents us from going on if we don't know what password if(argv == NULL || *argv == NULL) exit(EXIT_FAILURE); id_wanted = std::string(*argv); try { value = get_password(id_wanted); } catch(std::system_error& e) { errno = e.code().value(); sd_journal_perror("Unable to read key"); exit(EXIT_FAILURE); } catch(std::runtime_error& e) { sd_journal_print(LOG_INFO, e.what()); exit(EXIT_FAILURE); } std::cout << value; if(newline) std::cout << "\n"; exit(EXIT_SUCCESS); }