const gchar *password,
gboolean encrypted)
{
+ const gchar *p = password;
PasswordBlock *block;
gchar *encrypted_password;
g_return_val_if_fail(block_name != NULL, FALSE);
g_return_val_if_fail(password_id != NULL, FALSE);
+ /* Empty password string equals null password for us. */
+ if (strlen(password) == 0)
+ p = NULL;
+
debug_print("%s password '%s' in block (%d/%s)%s\n",
- (password == NULL ? "Deleting" : "Storing"),
+ (p == NULL ? "Deleting" : "Storing"),
password_id, block_type, block_name,
(encrypted ? ", already encrypted" : "") );
if ((block = _get_block(block_type, block_name)) == NULL) {
/* If caller wants to delete a password, and even its block
* doesn't exist, we're done. */
- if (password == NULL)
+ if (p == NULL)
return TRUE;
if ((block = _new_block(block_type, block_name)) == NULL) {
}
}
- if (password == NULL) {
+ if (p == NULL) {
/* NULL password was passed to us, so delete the entry with
* corresponding id */
g_hash_table_remove(block->entries, password_id);
if (!encrypted) {
/* encrypt password before saving it */
if ((encrypted_password =
- password_encrypt(password, NULL)) == NULL) {
+ password_encrypt(p, NULL)) == NULL) {
debug_print("Could not encrypt password '%s' for block (%d/%s).\n",
password_id, block_type, block_name);
return FALSE;
}
} else {
/* password is already in encrypted form already */
- encrypted_password = g_strdup(password);
+ encrypted_password = g_strdup(p);
}
// add encrypted password to the block
#if GDATA_CHECK_VERSION(0,17,2)
/* store refresh token */
pass = gdata_oauth2_authorizer_dup_refresh_token(authorizer);
+ passwd_store_set(PWS_PLUGIN, "GData", GDATA_TOKEN_PWD_STRING,
+ pass, FALSE);
if (pass != NULL) {
- passwd_store_set(PWS_PLUGIN, "GData", GDATA_TOKEN_PWD_STRING, pass,
- FALSE);
memset(pass, 0, strlen(pass));
g_free(pass);
}
/* Move passwords that are still in main config to password store. */
for (i = 0; i < INTF_LAST; i++) {
- if (spamreport_prefs.pass[i] != NULL &&
- strlen(spamreport_prefs.pass[i]) > 0) {
+ if (spamreport_prefs.pass[i] != NULL) {
spamreport_passwd_set(spam_interfaces[i].name,
spamreport_prefs.pass[i]);
passwords_migrated = TRUE;
GTK_EDITABLE(prefs_page->user_entry[i]), 0, -1);
pass = gtk_editable_get_chars(GTK_EDITABLE(prefs_page->pass_entry[i]), 0, -1);
- if (strlen(pass) > 0) {
- spamreport_passwd_set(spam_interfaces[i].name, pass);
- memset(pass, 0, strlen(pass));
- }
+ spamreport_passwd_set(spam_interfaces[i].name, pass);
+ memset(pass, 0, strlen(pass));
g_free(pass);
}