krb5_child-test.c revision 95cc3f4be93d3cb5bb28bb3787f0aace4edb3124
/*
SSSD
Unit tests - exercise the krb5 child
Authors:
Jakub Hrozek <jhrozek@redhat.com>
Copyright (C) 2012 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 <stdlib.h>
#include <talloc.h>
#include <popt.h>
#include <errno.h>
#include <unistd.h>
#include <limits.h>
#include "src/tools/tools_util.h"
/* Interfaces being tested */
#include "providers/krb5/krb5_auth.h"
#include "providers/krb5/krb5_common.h"
#include "providers/krb5/krb5_utils.h"
extern struct dp_option default_krb5_opts[];
extern struct sss_krb5_cc_be file_cc;
extern struct sss_krb5_cc_be dir_cc;
static krb5_context krb5_error_ctx;
if (kret) { \
return err; \
} \
} while(0) \
if (kret) { \
goto label; \
} \
} while(0) \
struct krb5_child_test_ctx {
struct tevent_context *ev;
struct krb5child_req *kr;
bool done;
struct krb5_child_response *res;
};
static errno_t
{
struct krb5_child_test_ctx *ctx;
return EFAULT;
}
return EOK;
}
int re_destructor(void *memctx)
{
if (ctx->illegal_path_re) {
}
return 0;
}
static struct krb5_ctx *
{
const char *errstr;
int errval;
int errpos;
int i;
("Invalid Regular Expression pattern at position %d. "
goto fail;
}
/* Kerberos options */
for (i = 0; i < KRB5_OPTS; i++) {
case DP_OPT_STRING:
break;
case DP_OPT_BLOB:
break;
case DP_OPT_NUMBER:
break;
case DP_OPT_BOOL:
break;
}
}
return krb5_ctx;
fail:
return NULL;
}
static struct pam_data *
const char *password)
{
return pd;
fail:
return NULL;
}
static struct krb5child_req *
const char *ccname, const char *ccname_template,
int timeout)
{
enum sss_krb5_cc_type cc_be;
struct krb5child_req *kr;
bool private;
const char *tmpl;
/* The top level child request */
if (!pwd) {
("Cannot get info on user [%s]\n", user));
goto fail;
}
/* The Kerberos context */
/* PAM Data structure */
goto fail;
}
/* Override options with what was provided by the user */
if (ccname_template) {
} else {
}
if (timeout) {
}
if (!ccname) {
true, true, &private);
} else {
}
switch (cc_be) {
case SSS_KRB5_TYPE_FILE:
break;
case SSS_KRB5_TYPE_DIR:
break;
default:
if (tmpl[0] != '/') {
goto fail;
}
"missing an explicit type, but looks like an absolute "
"path specifier. Assuming FILE:\n"));
break;
}
goto fail;
}
return kr;
fail:
return NULL;
}
static void
{
struct krb5_child_test_ctx);
}
static void
{
char timestring[BUFSIZ];
char fill = '\0';
if (kret) {
}
}
static void
{
}
printf("\n");
}
done:
}
static errno_t
print_ccache(const char *cc)
{
int i = 1;
printf("\nTicket cache: %s:%s\nDefault principal: %s\n\n",
printf("Ticket #%d:\n", i);
}
done:
return ret;
}
int
{
int opt;
struct tevent_req *req;
int pc_debug = 0;
int pc_timeout = 0;
const char *pc_ccname_tp = NULL;;
bool rm_ccache = true;
struct poptOption long_options[] = {
"The debug level to run with", NULL },
"The user to log in as", NULL },
"The authtok to use", NULL },
"Ask interactively for authtok", NULL },
"Force usage of a certain credential cache", NULL },
"Specify the credential cache template", NULL },
"The Kerberos realm to use", NULL },
"Do not delete the ccache when the tool finishes", NULL },
"The timeout for the child, in seconds", NULL },
};
debug_prg_name = argv[0];
switch(opt) {
case 'W':
errno = 0;
if (!password) {
return 1;
}
break;
case 'k':
rm_ccache = false;
break;
default:
return 1;
}
}
if (opt != -1) {
return 1;
}
if (!pc_user) {
return 1;
}
if (!pc_realm) {
return 1;
}
("Password was not provided or asked for\n"));
return 1;
}
if (pc_ccname && pc_ccname_tp) {
("Both ccname and ccname template specified, "
"will prefer ccname\n"));
}
return 3;
}
ret = 4;
goto done;
}
if (!req) {
ret = 4;
goto done;
}
}
ret = 5;
goto done;
}
ret = 6;
goto done;
}
ret = 0;
done:
}
return ret;
}