diff options
Diffstat (limited to 'pith/imap.c')
-rw-r--r-- | pith/imap.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/pith/imap.c b/pith/imap.c index f91937b1..7c74efaf 100644 --- a/pith/imap.c +++ b/pith/imap.c @@ -1149,6 +1149,64 @@ imap_flush_passwd_cache(int dumpcache) } } +void +imap_delete_passwd(MMLOGIN_S **m_list, char *user, STRLIST_S *hostlist, int altflag) +{ + if(m_list == NULL || *m_list == NULL) return; + imap_delete_passwd_auth(m_list, user, hostlist, altflag, + strchr((*m_list)->user, PWDAUTHSEP) != NULL ? OA2NAME : NULL); +} + +void +imap_delete_passwd_auth(MMLOGIN_S **m_list, char *user, + STRLIST_S *hostlist, int altflag, char *authtype) +{ + MMLOGIN_S *l, *p; + int len, offset; + + if(m_list == NULL || *m_list == NULL) return; + + dprint((9, "imap_delete_password: user=%s, host=%s, authtype=%s.", + user ? user : "no user!?", + hostlist && hostlist->name ? hostlist->name : "unknown host", + authtype ? authtype : "password authentication")); + + len = authtype ? strlen(authtype) : 0; + offset = authtype ? 1 : 0; + for(p = *m_list; p; p = p->next){ + if(imap_same_host_auth(p->hosts, hostlist, authtype) + && *user + && (len == 0 || (!struncmp(p->user, authtype, len) + && p->user[len] == PWDAUTHSEP)) + && !strcmp(user, p->user + len + offset) + && p->altflag == altflag) + break; + } + + dprint((9, "imap_delete_password: %s", + p ? "found a match!" : "did not find a match!")); + + if(!p) return; + + /* relink *mlist */ + if(p == *m_list) + *m_list = (*m_list)->next; + else{ + for(l = *m_list; l && l->next != p; l = l->next); + l->next = p->next; + } + /* so now p is out of the list. Free it */ + p->next = NULL; + if(p->user) fs_give((void **) &p->user); + + if(!(p->passwd >= (char *) private_store + && p->passwd <= (char *) private_store + sizeof(private_store))) + fs_give((void **) &p->passwd); + + free_strlist(&p->hosts); + fs_give((void **) &p); + dprint((9, "imap_delete_password: done with deletion.")); +} /* * Mimics fs_get except it only works for char * (no alignment hacks), it |