proxy_child.c revision 19b4bb652f5cdc2797b66595eaf8811881aa9873
/*
SSSD
Pam Proxy Child
Authors:
Sumit Bose <sbose@redhat.com>
Copyright (C) 2010 Red Hat
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 <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <dlfcn.h>
#include <popt.h>
#include <security/pam_appl.h>
#include <security/pam_modules.h>
#include "sbus/sssd_dbus.h"
#include "providers/dp_backend.h"
struct sbus_method pc_methods[] = {
};
struct sbus_interface pc_interface = {
};
struct pc_ctx {
struct tevent_context *ev;
struct confdb_ctx *cdb;
struct sss_domain_info *domain;
const char *identity;
const char *conf_path;
struct sbus_connection *mon_conn;
struct sbus_connection *conn;
const char *pam_target;
};
struct pam_response **response,
void *appdata_ptr) {
int i;
struct pam_response *reply;
struct authtok_conv *auth_data;
const char *password;
if (num_msg <= 0) return PAM_CONV_ERR;
sizeof(struct pam_response));
for (i=0; i < num_msg; i++) {
case PAM_PROMPT_ECHO_OFF:
reply[i].resp_retcode = 0;
break;
default:
goto failed;
}
}
return PAM_SUCCESS;
return PAM_CONV_ERR;
}
struct pam_response **response,
void *appdata_ptr) {
int i;
struct pam_response *reply;
struct authtok_conv *auth_data;
const char *password;
if (num_msg <= 0) return PAM_CONV_ERR;
sizeof(struct pam_response));
for (i=0; i < num_msg; i++) {
case PAM_PROMPT_ECHO_OFF:
reply[i].resp_retcode = 0;
/* The first prompt will be asking for the old authtok */
}
else {
/* Subsequent prompts are looking for the new authtok */
}
break;
default:
goto failed;
}
}
return PAM_SUCCESS;
return PAM_CONV_ERR;
}
{
int ret;
int pam_status;
struct authtok_conv *auth_data;
}
else {
}
return ENOMEM;
}
goto fail;
}
goto fail;
}
if (ret == PAM_SUCCESS) {
pam_target));
if (ret != PAM_SUCCESS) {
}
if (ret != PAM_SUCCESS) {
}
if (ret != PAM_SUCCESS) {
}
case SSS_PAM_AUTHENTICATE:
break;
case SSS_PAM_SETCRED:
break;
case SSS_PAM_ACCT_MGMT:
break;
case SSS_PAM_OPEN_SESSION:
break;
case SSS_PAM_CLOSE_SESSION:
break;
case SSS_PAM_CHAUTHTOK:
if (pam_status != PAM_SUCCESS) break;
}
break;
case SSS_PAM_CHAUTHTOK_PRELIM:
} else {
}
break;
default:
}
if (ret != PAM_SUCCESS) {
}
} else {
}
return EOK;
fail:
return ret;
}
{
void *user_data;
if (!user_data) {
goto done;
}
if (!pc_ctx) {
goto done;
}
if (!reply) {
"cannot send reply.\n"));
goto done;
}
if (!ret) {
goto done;
}
goto done;
}
}
if (!ret) {
goto done;
}
/* We'll return the message and let the
* parent process kill us.
*/
return EOK;
done:
}
{
char *sbus_address;
int ret;
if (sbus_address == NULL) {
return ENOMEM;
}
return ret;
}
DEBUG(0, ("dp_common_send_id failed.\n"));
return ret;
}
return EOK;
}
{
int retval;
/* create the message */
DEBUG(0, ("Out of memory?!\n"));
return ENOMEM;
}
if (!ret) {
return EIO;
}
return retval;
}
{
int ret;
if (!ctx) {
DEBUG(0, ("fatal error initializing pc_ctx\n"));
return ENOMEM;
}
DEBUG(0, ("Out of memory!?\n"));
return ENOMEM;
}
DEBUG(0, ("fatal error retrieving domain configuration\n"));
return ret;
}
DEBUG(0, ("fatal error setting up server bus\n"));
return ret;
}
return EOK;
}
{
int opt;
char *conf_entry = NULL;
struct main_context *main_ctx;
int ret;
long id;
char *pam_target = NULL;
struct poptOption long_options[] = {
_("Domain of the information provider (mandatory)"), NULL },
_("Child identifier (mandatory)"), NULL },
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
switch(opt) {
default:
return 1;
}
}
"--domain is a mandatory option.\n\n");
return 1;
}
if (id == 0) {
"--id is a mandatory option.\n\n");
return 1;
}
/* set up things like debug , signals, daemonization, etc... */
if (!debug_log_file) return 2;
if (!srv_name) return 2;
if (!conf_entry) return 2;
return 2;
}
"pam modules might not work as expected.\n"));
}
DEBUG(0, ("Error reading from confdb (%d) [%s]\n",
return 4;
}
if (pam_target == NULL) {
return 4;
}
ret = die_if_parent_died();
/* This is not fatal, don't return */
}
return 3;
}
/* loop on main */
return 0;
}