1b18a3fc310932e5afcdaa4bb401c8d368e79c0bSumit Bose Utilities to for tha pam_data structure
1b18a3fc310932e5afcdaa4bb401c8d368e79c0bSumit Bose Sumit Bose <sbose@redhat.com>
1b18a3fc310932e5afcdaa4bb401c8d368e79c0bSumit Bose Copyright (C) 2009 Red Hat
1b18a3fc310932e5afcdaa4bb401c8d368e79c0bSumit Bose This program is free software; you can redistribute it and/or modify
1b18a3fc310932e5afcdaa4bb401c8d368e79c0bSumit Bose it under the terms of the GNU General Public License as published by
1b18a3fc310932e5afcdaa4bb401c8d368e79c0bSumit Bose the Free Software Foundation; either version 3 of the License, or
1b18a3fc310932e5afcdaa4bb401c8d368e79c0bSumit Bose (at your option) any later version.
1b18a3fc310932e5afcdaa4bb401c8d368e79c0bSumit Bose This program is distributed in the hope that it will be useful,
1b18a3fc310932e5afcdaa4bb401c8d368e79c0bSumit Bose but WITHOUT ANY WARRANTY; without even the implied warranty of
1b18a3fc310932e5afcdaa4bb401c8d368e79c0bSumit Bose MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1b18a3fc310932e5afcdaa4bb401c8d368e79c0bSumit Bose GNU General Public License for more details.
1b18a3fc310932e5afcdaa4bb401c8d368e79c0bSumit Bose You should have received a copy of the GNU General Public License
1b18a3fc310932e5afcdaa4bb401c8d368e79c0bSumit Bose along with this program. If not, see <http://www.gnu.org/licenses/>.
bd09ead65cded3207cf228c44a31bbc87c2979bdJakub Hrozek#define PAM_SAFE_ITEM(item) item ? item : "not set"
02e38eae1b9cb5df2036a707dafd86f6047c17deSumit Bose struct pam_data *pd = talloc_get_type(ptr, struct pam_data);
64af76e2bef2565caa9738f675c108a4b3789237Simo Sorce /* make sure to wipe any password from memory before freeing */
02e38eae1b9cb5df2036a707dafd86f6047c17deSumit Bosestruct pam_data *create_pam_data(TALLOC_CTX *mem_ctx)
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_CRIT_FAILURE, "talloc_zero failed.\n");
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_CRIT_FAILURE, "talloc_zero failed.\n");
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_CRIT_FAILURE, "talloc_zero failed.\n");
02e38eae1b9cb5df2036a707dafd86f6047c17deSumit Bose talloc_set_destructor((TALLOC_CTX *) pd, pam_data_destructor);
64af76e2bef2565caa9738f675c108a4b3789237Simo Sorceerrno_t copy_pam_data(TALLOC_CTX *mem_ctx, struct pam_data *src,
64af76e2bef2565caa9738f675c108a4b3789237Simo Sorce if (pd->service == NULL && src->service != NULL) {
9acfb09f7969a69f58bd45c856b01700541853caLukas Slebodnik /* if structure pam_data was allocated on stack and zero initialized,
9acfb09f7969a69f58bd45c856b01700541853caLukas Slebodnik * than src->authtok and src->newauthtok are NULL, therefore
9acfb09f7969a69f58bd45c856b01700541853caLukas Slebodnik * instead of copying, new empty authtok will be created.
9acfb09f7969a69f58bd45c856b01700541853caLukas Slebodnik ret = sss_authtok_copy(src->authtok, pd->authtok);
9acfb09f7969a69f58bd45c856b01700541853caLukas Slebodnik ret = sss_authtok_copy(src->newauthtok, pd->newauthtok);
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov "copy_pam_data failed: (%d) %s.\n", ret, strerror(ret));
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(l, "domain: %s\n", PAM_SAFE_ITEM(pd->domain));
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(l, "user: %s\n", PAM_SAFE_ITEM(pd->user));
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(l, "service: %s\n", PAM_SAFE_ITEM(pd->service));
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(l, "tty: %s\n", PAM_SAFE_ITEM(pd->tty));
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(l, "ruser: %s\n", PAM_SAFE_ITEM(pd->ruser));
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(l, "rhost: %s\n", PAM_SAFE_ITEM(pd->rhost));
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(l, "authtok type: %d\n", sss_authtok_get_type(pd->authtok));
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(l, "newauthtok type: %d\n", sss_authtok_get_type(pd->newauthtok));
cda952ca3e00d324c7e53eeaeda394eb0d142818Sumit Bose DEBUG(l, "logon name: %s\n", PAM_SAFE_ITEM(pd->logon_name));