pamsrv_cmd.c revision 953e07b7c43bc9bb7c7616180b1ba1730e22c59a
/*
SSSD
PAM Responder
Copyright (C) Simo Sorce <ssorce@redhat.com> 2009
Copyright (C) Sumit Bose <sbose@redhat.com> 2009
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <time.h>
#include "responder/common/responder_packet.h"
#include "responder/common/responder.h"
#include "providers/data_provider.h"
static int extract_authtok(uint32_t *type, uint32_t *size, uint8_t **tok, uint8_t *body, size_t blen, size_t *c) {
*c += sizeof(uint32_t);
*c += sizeof(uint32_t);
*c += (*size);
return EOK;
}
*c += sizeof(uint32_t);
*c += size;
return EOK;
}
*c += sizeof(uint32_t);
*c += sizeof(uint32_t);
return EOK;
}
{
size_t c;
char *pam_user;
int ret;
return EINVAL;
}
c = sizeof(uint32_t);
do {
c += sizeof(uint32_t);
switch(type) {
case SSS_PAM_ITEM_USER:
break;
case SSS_PAM_ITEM_SERVICE:
break;
case SSS_PAM_ITEM_TTY:
break;
case SSS_PAM_ITEM_RUSER:
break;
case SSS_PAM_ITEM_RHOST:
break;
case SSS_PAM_ITEM_CLI_PID:
break;
case SSS_PAM_ITEM_AUTHTOK:
break;
case SSS_PAM_ITEM_NEWAUTHTOK:
break;
case SSS_END_OF_PAM_REQUEST:
break;
default:
}
} while(c < blen);
return EOK;
}
{
int ret;
return ret;
}
return EINVAL;
}
return EOK;
}
{
int start;
int end;
int last;
int ret;
end = 0;
/* user name */
if (pd->authtok_size == 0) {
} else {
} else {
return EINVAL;
}
}
if (pd->newauthtok_size == 0) {
} else {
} else {
return EINVAL;
}
}
return EOK;
}
/*=Save-Last-Login-State===================================================*/
struct set_last_login_state {
struct tevent_context *ev;
struct sss_domain_info *dom;
const char *username;
struct sysdb_attrs *attrs;
struct sysdb_handle *handle;
struct ldb_result *res;
};
struct tevent_context *ev,
struct sss_domain_info *dom,
const char *username,
struct sysdb_attrs *attrs)
{
struct set_last_login_state *state;
if (!req) {
return NULL;
}
if (!subreq) {
return NULL;
}
return req;
}
{
struct tevent_req);
struct set_last_login_state);
int ret;
return;
}
if (!subreq) {
return;
}
}
{
struct tevent_req);
struct set_last_login_state);
int ret;
return;
}
if (!subreq) {
return;
}
}
{
struct tevent_req);
int ret;
return;
}
}
{
return EOK;
}
/*=========================================================================*/
{
struct tevent_req *req;
struct sysdb_attrs *attrs;
if (!attrs) {
goto fail;
}
goto fail;
}
&dbctx);
DEBUG(0, ("Fatal: Sysdb context not found for this domain!\n"));
goto fail;
}
if (!req) {
goto fail;
}
return EOK;
fail:
return ret;
}
{
struct pam_auth_req);
int ret;
} else {
}
}
{
struct pam_auth_req *preq;
}
{
int ret;
struct response_data *resp;
int p;
struct tevent_timer *te;
struct tevent_req *req;
case SSS_PAM_AUTHENTICATE:
(pd->offline_auth == false)) {
/* do auth with offline credentials */
pd->offline_auth = true;
DEBUG(0, ("Fatal: Sysdb CTX not found for "
goto done;
}
struct pam_ctx);
/* this error is not fatal, continue */
} else {
return;
}
}
break;
case SSS_PAM_CHAUTHTOK_PRELIM:
case SSS_PAM_CHAUTHTOK:
(const uint8_t *) &user_info_type);
break;
/* TODO: we need the pam session cookie here to make sure that cached
* authentication was successful */
case SSS_PAM_SETCRED:
case SSS_PAM_ACCT_MGMT:
case SSS_PAM_OPEN_SESSION:
case SSS_PAM_CLOSE_SESSION:
break;
default:
}
}
if (pd->response_delay > 0) {
goto done;
}
pd->response_delay = 0;
goto done;
}
return;
}
/* If this was a successful login, save the lastLogin time */
!pd->offline_auth &&
!pd->last_auth_saved &&
goto done;
}
return;
}
goto done;
}
}
resp_c = 0;
resp_size = 0;
resp_c++;
}
sizeof(int32_t) +
goto done;
}
p = 0;
p += sizeof(int32_t);
p += sizeof(int32_t);
p += sizeof(int32_t);
p += sizeof(int32_t);
}
done:
}
{
int ret;
struct pam_auth_req);
time_t expire_date = 0;
long long dummy;
switch (ret) {
case EOK:
} else {
dummy = (long long) expire_date;
}
}
break;
case ENOENT:
break;
case EINVAL:
break;
case EACCES:
if (delayed_until >= 0) {
} else {
dummy = (long long) delayed_until;
}
}
}
break;
default:
}
return;
}
struct ldb_result *res);
/* TODO: we should probably return some sort of cookie that is set in the
* PAM_ENVIRONMENT, so that we can save performing some calls and cache
* data. */
{
struct sss_domain_info *dom;
struct pam_auth_req *preq;
int timeout;
int ret;
if (!preq) {
return ENOMEM;
}
return ENOMEM;
}
goto done;
}
case 1:
break;
case 2:
break;
case 3:
break;
default:
}
goto done;
}
/* now check user is valid */
}
if (!dom) {
goto done;
}
}
else {
/* FIXME: need to support negative cache */
#if HAVE_NEG_CACHE
#endif
break;
}
if (!dom) {
goto done;
}
}
goto done;
}
/* When auth is requested always search the provider first,
* do not rely on cached data unless the provider is completely
* offline */
/* no need to re-check later on */
preq->check_provider = false;
false, SSS_DP_INITGROUPS,
}
else {
DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n"));
goto done;
}
}
done:
switch (ret) {
case ENOENT:
default:
}
}
return EOK;
}
{
int ret;
if (err_maj) {
"Error: %u, %u, %s\n",
}
/* always try to see if we have the user in cache even if the provider
* returned an error */
DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n"));
goto done;
}
done:
}
}
struct ldb_result *res)
{
struct sss_domain_info *dom;
bool call_provider = false;
int ret;
if (status != LDB_SUCCESS) {
return;
}
if (preq->check_provider) {
case 0:
call_provider = true;
break;
case 1:
SYSDB_CACHE_EXPIRE, 0);
call_provider = true;
}
break;
default:
return;
}
}
if (call_provider) {
/* dont loop forever :-) */
preq->check_provider = false;
/* keep around current data in case backend is offline */
}
false, SSS_DP_USER,
}
return;
}
case 0:
/* search next as the domain was unknown */
/* skip domains that require FQnames or have negative caches */
#if HAVE_NEG_CACHE
neghit = true;
#endif
break;
}
#if HAVE_NEG_CACHE
/* reset neghit if we still have a domain to check */
if (neghit) {
}
#endif
}
/* When auth is requested always search the provider first,
* do not rely on cached data unless the provider is
* completely offline */
/* no need to re-check later on */
preq->check_provider = false;
false, SSS_DP_USER,
}
else {
DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n"));
return;
}
}
}
}
/* we made another call, end here */
}
else {
}
#if HAVE_NEG_CACHE
/* set negative cache only if not result of cache check */
if (!neghit) {
}
}
#endif
} else {
}
return;
}
break;
case 1:
/* BINGO */
return;
default:
}
}
{
int ret;
}
}
else {
}
}
}
}
}
}
}
}
}
}
struct cli_protocol_version *register_cli_protocol_version(void)
{
static struct cli_protocol_version pam_cli_protocol_version[] = {
{3, "2009-09-14", "make cli_pid mandatory"},
{2, "2009-05-12", "new format <type><size><data>"},
{1, "2008-09-05", "initial version, \\0 terminated strings"},
};
return pam_cli_protocol_version;
}
struct sss_cmd_table *get_pam_cmds(void)
{
static struct sss_cmd_table sss_cmds[] = {
{SSS_CLI_NULL, NULL}
};
return sss_cmds;
}