krb5_common.c revision 83f24636ef8d3d2b9c5be46272781ed5e0497ca7
/*
SSSD
Kerberos Provider Common Functions
Authors:
Sumit Bose <sbose@redhat.com>
Copyright (C) 2008-2009 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 <unistd.h>
#include <netdb.h>
#include <ctype.h>
#include "providers/dp_backend.h"
#include "providers/krb5/krb5_common.h"
#include "providers/krb5/krb5_opts.h"
#include "providers/krb5/krb5_utils.h"
const char *env_name)
{
int ret;
char *str;
bool free_str = false;
return EOK;
}
return ENOMEM;
}
free_str = true;
goto done;
}
}
if (ret != 0) {
goto done;
}
goto done;
}
done:
if (free_str) {
}
return ret;
}
struct sss_domain_info *dom,
{
int ret;
const char *realm;
const char *dummy;
char *use_fast_str;
char *fast_principal;
enum sss_krb5_cc_type cc_be;
return ret;
}
}
}
return ret;
}
return ret;
}
if (use_fast_str != NULL) {
return ret;
}
} else {
if (fast_principal != NULL) {
}
}
}
}
}
} else {
}
}
}
"using the KDC or defaults.\n"));
}
return EINVAL;
}
switch (cc_be) {
case SSS_KRB5_TYPE_FILE:
if (dummy[0] != '/') {
break;
}
"missing an explicit type, but is an absolute "
"path specifier. Assuming FILE:\n"));
return ret;
}
break;
#ifdef HAVE_KRB5_DIRCACHE
case SSS_KRB5_TYPE_DIR:
break;
#endif
default:
return EINVAL;
break;
}
return EOK;
}
{
char *krb5_servers = NULL;
if (krb5_servers == NULL) {
return ret;
}
if (krb5_servers != NULL)
{
return ret;
}
("Set krb5 server [%s] based on legacy krb5_kdcip option\n",
krb5_servers));
("Your configuration uses the deprecated option "
"'krb5_kdcip' to specify the KDC. Please change the "
"configuration to use the 'krb5_server' option "
"instead.\n"));
}
}
return EOK;
}
{
int ret;
return ENOMEM;
}
goto done;
}
/* If there is no KDC, try the deprecated krb5_kdcip option, too */
/* FIXME - this can be removed in a future version */
goto done;
}
done:
}
return ret;
}
const char *service)
{
int ret;
int fd = -1;
char *krb5info_name = NULL;
int server_len;
return EINVAL;
}
} else {
return EINVAL;
}
return ENOMEM;
}
goto done;
}
if (krb5info_name == NULL) {
goto done;
}
if (fd == -1) {
goto done;
}
errno = 0;
if (written == -1) {
goto done;
}
if (written != server_len) {
("Write error, wrote [%d] bytes, expected [%d]\n",
written, server_len));
goto done;
}
if (ret == -1) {
goto done;
}
if (ret == -1) {
goto done;
}
if (ret == -1) {
goto done;
}
done:
return ret;
}
{
struct krb5_service *krb5_service;
struct resolv_hostent *srvaddr;
char *address;
char *safe_address;
int ret;
return;
}
if (!krb5_service) {
return;
}
if (!srvaddr) {
return;
}
return;
}
address);
if (safe_address == NULL) {
return;
}
if (safe_address == NULL) {
return;
}
krb5_service->name);
}
return;
}
struct krb5_service *service,
const char *service_name,
const char *servers,
bool primary)
{
int i;
char *port_str;
long port;
char *server_spec;
char *endptr;
if (!tmp_ctx) {
return ENOMEM;
}
goto done;
}
for (i = 0; list[i]; i++) {
if (!server_spec) {
goto done;
}
if (be_fo_is_srv_identifier(server_spec)) {
if (!primary) {
("Failed to add server [%s] to failover service: "
"SRV resolution only allowed for primary servers!\n",
list[i]));
continue;
}
BE_FO_PROTO_UDP, true, NULL);
if (ret) {
goto done;
}
continue;
}
/* Do not try to get port number if last character is ']' */
} else {
}
port = 0;
} else {
*port_str = '\0';
++port_str;
errno = 0;
if (errno != 0) {
goto done;
}
if (*endptr != '\0') {
goto done;
}
goto done;
}
port_str));
goto done;
}
} else {
goto done;
}
}
/* It could be ipv6 address in square brackets. Remove
* the brackets if needed. */
goto done;
}
goto done;
}
}
done:
return ret;
}
{
}
const char *service_name,
const char *primary_servers,
const char *backup_servers,
{
struct krb5_service *service;
int ret;
if (!tmp_ctx) {
return ENOMEM;
}
if (!service) {
goto done;
}
goto done;
}
goto done;
}
goto done;
}
if (!primary_servers) {
("No primary servers defined, using service discovery\n"));
}
goto done;
}
if (backup_servers) {
goto done;
}
}
goto done;
}
done:
}
return ret;
}
{
int ret;
char *file;
return ENOMEM;
}
errno = 0;
if (ret == -1) {
}
return ENOMEM;
}
errno = 0;
if (ret == -1) {
}
return EOK;
}
void remove_krb5_info_files_callback(void *pvt)
{
int ret;
struct remove_info_files_ctx);
"krb5 info files will not be removed, because "
"it is unclear if they will be recreated properly.\n"));
return;
}
"krb5 info files will not be removed, because "
"it is unclear if they will be recreated properly.\n"));
return;
}
}
return;
}
}
}
struct tevent_signal *se,
int signum,
int count,
void *siginfo,
void *private_data)
{
char *realm = (char *)private_data;
int ret;
}
}
{
int ret;
struct remove_info_files_ctx *ctx;
const char *krb5_realm;
return EINVAL;
}
return ENOMEM;
}
if (krb5_realm == NULL) {
goto done;
}
goto done;
}
} else {
}
NULL);
goto done;
}
done:
}
return ret;
}
{
const char *krb5_realm;
char *sig_realm;
struct tevent_signal *sige;
BlockSignals(false, SIGTERM);
if (krb5_realm == NULL) {
return EINVAL;
}
return ENOMEM;
}
return ENOMEM;
}
return EOK;
}
{
const char *realm;
char *upn;
return ENOENT;
}
/* NOTE: this is a hack, works only in some environments */
return ENOMEM;
}
return EOK;
}
bool *different_realm)
{
char *at_sign;
return EINVAL;
}
/* if coming from the same realm the upn must be at least the size of the
* realm plus 1 for the '@' char. */
return EINVAL;
}
*different_realm = false;
} else {
*different_realm = true;
}
return EOK;
}