krb5_child.c revision a777a485bf73be24404fe3094c3688e604d8cbf8
640b2adac05bb7f5e9fba064434c91852c3a72e6nd Kerberos 5 Backend Module -- tgt_req and changepw child
640b2adac05bb7f5e9fba064434c91852c3a72e6nd Sumit Bose <sbose@redhat.com>
640b2adac05bb7f5e9fba064434c91852c3a72e6nd Copyright (C) 2009-2010 Red Hat
8e34905974b7a442a55adac3b3fdb196c389e807takashi This program is free software; you can redistribute it and/or modify
640b2adac05bb7f5e9fba064434c91852c3a72e6nd it under the terms of the GNU General Public License as published by
640b2adac05bb7f5e9fba064434c91852c3a72e6nd the Free Software Foundation; either version 3 of the License, or
640b2adac05bb7f5e9fba064434c91852c3a72e6nd (at your option) any later version.
8e34905974b7a442a55adac3b3fdb196c389e807takashi This program is distributed in the hope that it will be useful,
640b2adac05bb7f5e9fba064434c91852c3a72e6nd but WITHOUT ANY WARRANTY; without even the implied warranty of
640b2adac05bb7f5e9fba064434c91852c3a72e6nd MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
640b2adac05bb7f5e9fba064434c91852c3a72e6nd GNU General Public License for more details.
640b2adac05bb7f5e9fba064434c91852c3a72e6nd You should have received a copy of the GNU General Public License
640b2adac05bb7f5e9fba064434c91852c3a72e6nd along with this program. If not, see <http://www.gnu.org/licenses/>.
51853aa2ebfdf9903a094467e1d02099f143639daaron /* opts taken from kinit */
a27e9e05958bc51ea09edb8d8d862fe8b125313bslive /* in seconds */
a27e9e05958bc51ea09edb8d8d862fe8b125313bslive const char *upn;
222f0f03c2f9ee6343c18f80f0cb6e9aad21bc58slivestatic const char *__krb5_error_msg;
222f0f03c2f9ee6343c18f80f0cb6e9aad21bc58slive __krb5_error_msg = sss_krb5_get_error_message(krb5_error_ctx, krb5_error); \
222f0f03c2f9ee6343c18f80f0cb6e9aad21bc58slive DEBUG(level, ("%d: [%d][%s]\n", __LINE__, krb5_error, __krb5_error_msg)); \
222f0f03c2f9ee6343c18f80f0cb6e9aad21bc58slive sss_krb5_free_error_message(krb5_error_ctx, __krb5_error_msg); \
222f0f03c2f9ee6343c18f80f0cb6e9aad21bc58slivestatic krb5_error_code sss_krb5_prompter(krb5_context context, void *data,
a27e9e05958bc51ea09edb8d8d862fe8b125313bslive struct krb5_req *kr = talloc_get_type(data, struct krb5_req);
95e8cab14596a61826fa52477dcaebc07bfbad00colm DEBUG(5, ("Prompter called with empty banner, nothing to do.\n"));
95e8cab14596a61826fa52477dcaebc07bfbad00colm ret = pam_add_response(kr->pd, SSS_PAM_TEXT_MSG, strlen(banner)+1,
95e8cab14596a61826fa52477dcaebc07bfbad00colmstatic krb5_error_code create_empty_cred(struct krb5_req *kr, krb5_creds **_cred)
17efa6b5344b7574597eec03f02ef28103e19265nd kerr = krb5_copy_principal(kr->ctx, kr->princ, &cred->client);
cd51960ffc0f49d7a9e702162ed49b3eb0909276dirkx if (kerr != 0) {
cd51960ffc0f49d7a9e702162ed49b3eb0909276dirkx kerr = krb5_build_principal_ext(kr->ctx, &cred->server,
86bb9693d63dfc1be14519a5b444467e4b0cdaf8kawai if (kerr != 0) {
86bb9693d63dfc1be14519a5b444467e4b0cdaf8kawai if (kerr != 0) {
86bb9693d63dfc1be14519a5b444467e4b0cdaf8kawaistatic krb5_error_code create_ccache_file(struct krb5_req *kr, krb5_creds *creds)
b5468eddc0cb1691af19ddc70a6e205daf00a94ctrawick DEBUG(1, ("Ccache filename is not an absolute path.\n"));
b5468eddc0cb1691af19ddc70a6e205daf00a94ctrawick tmp_ccname = talloc_strndup(kr, cc_file_name, (size_t) (dummy-cc_file_name));
8e34905974b7a442a55adac3b3fdb196c389e807takashi tmp_ccname = talloc_asprintf_append(tmp_ccname, "/.krb5cc_dummy_XXXXXX");
ef685e00a47967e27d89709461728a229d762172nd DEBUG(1, ("mkstemp failed [%d][%s].\n", errno, strerror(errno)));
17efa6b5344b7574597eec03f02ef28103e19265nd if (kerr != 0) {
222f0f03c2f9ee6343c18f80f0cb6e9aad21bc58slive if (kerr != 0) {
94abf1cc80072ea31506946ac6595631ca6d2c14rbowen if (kerr != 0) {
94abf1cc80072ea31506946ac6595631ca6d2c14rbowen if (kerr != 0) {
94abf1cc80072ea31506946ac6595631ca6d2c14rbowen if (kerr != 0) {
17efa6b5344b7574597eec03f02ef28103e19265nd if (ccname_len >= 6 && strcmp(cc_file_name + (ccname_len-6), "XXXXXX")==0 ) {
1f2a7403f1389cbf2da0a53a2b2fb425dea75506erikabele DEBUG(1, ("mkstemp failed [%d][%s].\n", errno, strerror(errno)));
1f666f93c91dbb492dc7706573b369cd03b84265poirier DEBUG(1, ("rename failed [%d][%s].\n", errno, strerror(errno)));
81622596373177e079337e956f7a5800895443b3erikabelestatic errno_t pack_response_packet(struct response *resp, int status,
81622596373177e079337e956f7a5800895443b3erikabele /* A buffer with the following structure must be created:
81622596373177e079337e956f7a5800895443b3erikabele * int32_t status of the request (required)
81622596373177e079337e956f7a5800895443b3erikabele * message (zero or more)
81622596373177e079337e956f7a5800895443b3erikabele * A message consists of:
81622596373177e079337e956f7a5800895443b3erikabele * int32_t type of the message
81622596373177e079337e956f7a5800895443b3erikabele * int32_t length of the following data
81622596373177e079337e956f7a5800895443b3erikabele * uint8_t[len] data
e554dd2dae4ba2c32dbd05fc0d4e0a42ef4ba902rbowen DEBUG(1, ("Insufficient memory to create message.\n"));
e554dd2dae4ba2c32dbd05fc0d4e0a42ef4ba902rbowen safealign_memcpy(&resp->buf[p], pdr->data, pdr->len, &p);
6e89d4f6c259afc94f8806c74a33a8fe81392499sfstatic struct response *prepare_response_message(struct krb5_req *kr,
f4166cb2bf5e48c1b0f18b0d1f6757fce82230a8nd if (kerr == 0) {
8e34905974b7a442a55adac3b3fdb196c389e807takashi msg = talloc_asprintf(kr, "%s=%s",CCACHE_ENV_NAME, kr->ccname);
f4166cb2bf5e48c1b0f18b0d1f6757fce82230a8nd ret = pam_add_response(kr->pd, SSS_PAM_ENV_ITEM, strlen(msg) + 1,
17efa6b5344b7574597eec03f02ef28103e19265nd krb5_msg = sss_krb5_get_error_message(krb5_error_ctx, kerr);
e9e8e471353eaa5576e1e96530968d02f208e39fndstatic errno_t sendresponse(int fd, krb5_error_code kerr, int pam_status,
1e1be8a0871405df3c1ec4d6d33aab71996ad0c9nilgun ret = write(fd, resp->buf + written, resp->size - written);
e9e8e471353eaa5576e1e96530968d02f208e39fnd DEBUG(1, ("write failed [%d][%s].\n", ret, strerror(ret)));
return ret;
return EOK;
char *principal;
if (kerr != 0) {
return kerr;
if (kerr != 0) {
return kerr;
if (kerr != 0) {
if (kerr != 0) {
goto done;
goto done;
if (kerr != 0) {
goto done;
if (kerr == 0) {
done:
return kerr;
char *password)
int ret;
if (kerr != 0) {
return kerr;
if (kerr != 0) {
return kerr;
return ret;
if (kerr != 0) {
goto done;
kerr = 0;
done:
return kerr;
int ret;
goto sendresponse;
if (kerr != 0) {
goto sendresponse;
goto sendresponse;
goto sendresponse;
goto sendresponse;
if (kerr != 0) {
goto sendresponse;
if (kerr != 0) {
return ret;
int ret;
goto sendresponse;
if (kerr == 0) {
if (kerr != 0) {
switch (kerr) {
case KRB5_KDC_UNREACH:
case KRB5KDC_ERR_KEY_EXP:
return ret;
int ret;
if (ret != 0) {
return ret;
size_t p = 0;
p += len;
p += len;
p += len;
p += len;
p += len;
return EOK;
return EOK;
goto failed;
goto failed;
case SSS_PAM_AUTHENTICATE:
if (offline) {
case SSS_PAM_CHAUTHTOK:
case SSS_PAM_CHAUTHTOK_PRELIM:
goto failed;
if (kerr != 0) {
goto failed;
if (kerr != 0) {
goto failed;
if (kerr != 0) {
goto failed;
goto failed;
if (kerr != 0) {
goto failed;
if (kerr != 0) {
goto failed;
return EOK;
return kerr;
int ret;
int opt;
switch(opt) {
goto fail;
} else if (ret > 0) {
goto fail;
goto fail;
goto fail;
goto fail;
goto fail;
goto fail;
fail: