/*
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/proxy/proxy_iface_generated.h"
struct pc_ctx {
const char *identity;
const char *conf_path;
const char *pam_target;
};
struct pam_response **response,
void *appdata_ptr) {
int i;
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:
"Conversation style %d not supported.\n",
goto failed;
}
}
return PAM_SUCCESS;
return PAM_CONV_ERR;
}
struct pam_response **response,
void *appdata_ptr) {
int i;
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:
"Conversation style %d not supported.\n",
goto failed;
}
}
return PAM_SUCCESS;
return PAM_CONV_ERR;
}
{
int ret;
int pam_status;
char *shortname;
}
else {
}
return ENOMEM;
}
goto fail;
}
goto fail;
}
goto fail;
}
if (ret == PAM_SUCCESS) {
"Pam transaction started with service name [%s].\n",
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;
}
{
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 ret;
done:
}
{
/* reply should never be null. This function shouldn't be called
* until reply is valid or timeout has occurred. If reply is NULL
* here, something is seriously wrong and we should bail out.
*/
"called but no reply was received and no timeout occurred\n");
goto done;
}
}
done:
}
{
DBUS_TYPE_UINT32, &id);
return ENOMEM;
}
return ret;
}
{
char *sbus_address;
int ret;
{ &iface_proxy_auth_meta, 0 },
.PAM = pc_pam_handler,
};
if (sbus_address == NULL) {
return ENOMEM;
}
return ret;
}
return ret;
}
return ret;
}
return EOK;
}
{
int ret;
if (!ctx) {
return ENOMEM;
}
return ENOMEM;
}
"fatal error retrieving domain configuration\n");
return ret;
}
return ret;
}
return EOK;
}
{
int opt;
int ret;
long id;
_("Domain of the information provider (mandatory)"), NULL },
_("Child identifier (mandatory)"), NULL },
};
/* Set debug level to invalid value so we can decide 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");
}
return 4;
}
if (pam_target == NULL) {
return 4;
}
ret = die_if_parent_died();
/* This is not fatal, don't return */
"Could not set up to exit when parent process does\n");
}
"Could not initialize proxy child [%d].\n", ret);
return 3;
}
"Proxy child for domain [%s] started!\n", domain);
/* loop on main */
return 0;
}