pamsrv.c revision 2f6a94e30458df92fb26c3d810f613d1e4cff99b
/*
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 <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <popt.h>
#include "sbus/sssd_dbus.h"
#include "responder/common/responder_packet.h"
#include "providers/data_provider.h"
#include "monitor/monitor_interfaces.h"
#include "sbus/sbus_client.h"
#include "responder/common/negcache.h"
#include "responder/common/responder_sbus.h"
#define DEFAULT_PAM_FD_LIMIT 8192
#define ALL_UIDS_ALLOWED "all"
#define ALL_DOMAIMS_ARE_PUBLIC "all"
#define NO_DOMAIMS_ARE_PUBLIC "none"
#define DEFAULT_ALLOWED_UIDS ALL_UIDS_ALLOWED
#define DEFAULT_PAM_CERT_AUTH false
struct mon_cli_iface monitor_pam_methods = {
{ &mon_cli_iface_meta, 0 },
.resetOffline = NULL,
.clearMemcache = NULL,
.clearEnumCache = NULL,
.sysbusReconnect = NULL,
};
static struct data_provider_iface pam_dp_methods = {
{ &data_provider_iface_meta, 0 },
.RegisterService = NULL,
.pamHandler = NULL,
.sudoHandler = NULL,
.autofsHandler = NULL,
.hostHandler = NULL,
.getDomains = NULL,
.getAccountInfo = NULL,
};
{
int ret;
/* Did we reconnect successfully? */
if (status == SBUS_RECONNECT_SUCCESS) {
/* Identify ourselves to the data provider */
"PAM");
/* all fine */
return;
}
}
/* Handle failure */
/* FIXME: kill the frontend and let the monitor restart it ? */
/* pam_shutdown(rctx); */
}
{
char *uid_str;
goto done;
}
pctx->trusted_uids_count = 0;
} else {
&pctx->trusted_uids);
}
goto done;
}
done:
return ret;
}
{
char *domains_str = NULL;
goto done;
}
/* copy all domains */
goto done;
}
pctx->public_domains_count = 0;
} else {
goto done;
}
}
done:
return ret;
}
struct tevent_context *ev,
struct confdb_ctx *cdb,
int pipe_fd, int priv_pipe_fd)
{
struct sss_cmd_table *pam_cmds;
int ret, max_retries;
int id_timeout;
int fd_limit;
pam_cmds = get_pam_cmds();
&rctx);
return ret;
}
if (!pctx) {
goto done;
}
goto done;
}
goto done;
}
/* Enable automatic reconnection to the Data Provider */
/* FIXME: "retries" is too generic, either get it from a global config
* or specify these retries are about the sbus connections to DP */
"Failed to set up automatic reconnection\n");
goto done;
}
}
/* Set up the negative cache */
&pctx->neg_timeout);
/* Set up the PAM identity timeout */
&id_timeout);
"fatal error initializing negative cache\n");
goto done;
}
goto done;
}
/* Create table for initgroup lookups */
"Could not create initgroups hash table: [%s]\n",
goto done;
}
/* Set up file descriptor limits */
&fd_limit);
"Failed to set up file descriptor limit\n");
goto done;
}
goto done;
}
/* Check if certificate based authentication is enabled */
goto done;
}
goto done;
}
"Failed to determine if certificate based authentication is " \
"enabled or not.\n");
goto done;
}
}
done:
}
return ret;
}
{
int opt;
struct main_context *main_ctx;
int ret;
int pipe_fd;
int priv_pipe_fd;
struct poptOption long_options[] = {
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
switch(opt) {
default:
return 1;
}
}
/* set up things like debug, signals, daemonization, etc... */
debug_log_file = "sssd_pam";
/* Crate pipe file descriptors here before privileges are dropped
* in server_setup() */
"create_pipe_fd failed [%d]: %s.\n",
return 2;
}
"create_pipe_fd failed (priviledged pipe) [%d]: %s.\n",
return 2;
}
ret = die_if_parent_died();
/* This is not fatal, don't return */
"Could not set up to exit when parent process does\n");
}
/* loop on main */
return 0;
}