summaryrefslogtreecommitdiffstats
path: root/crypto/heimdal/kdc/hpropd.c
diff options
context:
space:
mode:
authorstas <stas@FreeBSD.org>2012-03-22 08:48:42 +0000
committerstas <stas@FreeBSD.org>2012-03-22 08:48:42 +0000
commite7e0b349883e80d63c4e856f16351aaa6607766d (patch)
tree5518cb944fa25f627a797b58451ccf506b720fcf /crypto/heimdal/kdc/hpropd.c
parente02fd6b8423e63f1fdbfc1f984d7c7291a1bacd1 (diff)
parent2db247d3fc10ef5304f61dbd66448efff8cc6684 (diff)
downloadFreeBSD-src-e7e0b349883e80d63c4e856f16351aaa6607766d.zip
FreeBSD-src-e7e0b349883e80d63c4e856f16351aaa6607766d.tar.gz
- Update FreeBSD Heimdal distribution to version 1.5.1. This also brings
several new kerberos related libraries and applications to FreeBSD: o kgetcred(1) allows one to manually get a ticket for a particular service. o kf(1) securily forwards ticket to another host through an authenticated and encrypted stream. o kcc(1) is an umbrella program around klist(1), kswitch(1), kgetcred(1) and other user kerberos operations. klist and kswitch are just symlinks to kcc(1) now. o kswitch(1) allows you to easily switch between kerberos credentials if you're running KCM. o hxtool(1) is a certificate management tool to use with PKINIT. o string2key(1) maps a password into key. o kdigest(8) is a userland tool to access the KDC's digest interface. o kimpersonate(8) creates a "fake" ticket for a service. We also now install manpages for some lirbaries that were not installed before, libheimntlm and libhx509. - The new HEIMDAL version no longer supports Kerberos 4. All users are recommended to switch to Kerberos 5. - Weak ciphers are now disabled by default. To enable DES support (used by telnet(8)), use "allow_weak_crypto" option in krb5.conf. - libtelnet, pam_ksu and pam_krb5 are now compiled with error on warnings disabled due to the function they use (krb5_get_err_text(3)) being deprecated. I plan to work on this next. - Heimdal's KDC now require sqlite to operate. We use the bundled version and install it as libheimsqlite. If some other FreeBSD components will require it in the future we can rename it to libbsdsqlite and use for these components as well. - This is not a latest Heimdal version, the new one was released while I was working on the update. I will update it to 1.5.2 soon, as it fixes some important bugs and security issues.
Diffstat (limited to 'crypto/heimdal/kdc/hpropd.c')
-rw-r--r--crypto/heimdal/kdc/hpropd.c132
1 files changed, 71 insertions, 61 deletions
diff --git a/crypto/heimdal/kdc/hpropd.c b/crypto/heimdal/kdc/hpropd.c
index 12a9766..75b26a1 100644
--- a/crypto/heimdal/kdc/hpropd.c
+++ b/crypto/heimdal/kdc/hpropd.c
@@ -1,40 +1,38 @@
/*
- * Copyright (c) 1997-2006 Kungliga Tekniska Högskolan
- * (Royal Institute of Technology, Stockholm, Sweden).
- * All rights reserved.
+ * Copyright (c) 1997-2006 Kungliga Tekniska Högskolan
+ * (Royal Institute of Technology, Stockholm, Sweden).
+ * All rights reserved.
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
*
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
*
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
*
- * 3. Neither the name of the Institute nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
*/
#include "hprop.h"
-RCSID("$Id: hpropd.c 22245 2007-12-08 23:48:52Z lha $");
-
static int inetd_flag = -1;
static int help_flag;
static int version_flag;
@@ -45,18 +43,21 @@ static char *local_realm;
static char *ktname = NULL;
struct getargs args[] = {
- { "database", 'd', arg_string, &database, "database", "file" },
- { "stdin", 'n', arg_flag, &from_stdin, "read from stdin" },
- { "print", 0, arg_flag, &print_dump, "print dump to stdout" },
+ { "database", 'd', arg_string, rk_UNCONST(&database), "database", "file" },
+ { "stdin", 'n', arg_flag, &from_stdin, "read from stdin", NULL },
+ { "print", 0, arg_flag, &print_dump, "print dump to stdout", NULL },
+#ifdef SUPPORT_INETD
{ "inetd", 'i', arg_negative_flag, &inetd_flag,
- "Not started from inetd" },
+ "Not started from inetd", NULL },
+#endif
{ "keytab", 'k', arg_string, &ktname, "keytab to use for authentication", "keytab" },
- { "realm", 'r', arg_string, &local_realm, "realm to use" },
+ { "realm", 'r', arg_string, &local_realm, "realm to use", NULL },
{ "version", 0, arg_flag, &version_flag, NULL, NULL },
{ "help", 'h', arg_flag, &help_flag, NULL, NULL}
};
static int num_args = sizeof(args) / sizeof(args[0]);
+static char unparseable_name[] = "unparseable name";
static void
usage(int ret)
@@ -74,8 +75,8 @@ main(int argc, char **argv)
krb5_principal c1, c2;
krb5_authenticator authent;
krb5_keytab keytab;
- int fd;
- HDB *db;
+ krb5_socket_t sock = rk_INVALID_SOCKET;
+ HDB *db = NULL;
int optidx = 0;
char *tmp_db;
krb5_log_facility *fac;
@@ -89,22 +90,22 @@ main(int argc, char **argv)
ret = krb5_openlog(context, "hpropd", &fac);
if(ret)
- ;
+ errx(1, "krb5_openlog");
krb5_set_warn_dest(context, fac);
-
+
if(getarg(args, num_args, argc, argv, &optidx))
usage(1);
if(local_realm != NULL)
krb5_set_default_realm(context, local_realm);
-
+
if(help_flag)
usage(0);
if(version_flag) {
print_version(NULL);
exit(0);
}
-
+
argc -= optidx;
argv += optidx;
@@ -114,9 +115,9 @@ main(int argc, char **argv)
if (database == NULL)
database = hdb_default_db(context);
- if(from_stdin)
- fd = STDIN_FILENO;
- else {
+ if(from_stdin) {
+ sock = STDIN_FILENO;
+ } else {
struct sockaddr_storage ss;
struct sockaddr *sa = (struct sockaddr *)&ss;
socklen_t sin_len = sizeof(ss);
@@ -124,19 +125,24 @@ main(int argc, char **argv)
krb5_ticket *ticket;
char *server;
- fd = STDIN_FILENO;
+ sock = STDIN_FILENO;
+#ifdef SUPPORT_INETD
if (inetd_flag == -1) {
- if (getpeername (fd, sa, &sin_len) < 0)
+ if (getpeername (sock, sa, &sin_len) < 0) {
inetd_flag = 0;
- else
+ } else {
inetd_flag = 1;
+ }
}
+#else
+ inetd_flag = 0;
+#endif
if (!inetd_flag) {
mini_inetd (krb5_getportbyname (context, "hprop", "tcp",
- HPROP_PORT));
+ HPROP_PORT), &sock);
}
sin_len = sizeof(ss);
- if(getpeername(fd, sa, &sin_len) < 0)
+ if(getpeername(sock, sa, &sin_len) < 0)
krb5_err(context, 1, errno, "getpeername");
if (inet_ntop(sa->sa_family,
@@ -147,7 +153,7 @@ main(int argc, char **argv)
sizeof(addr_name));
krb5_log(context, fac, 0, "Connection from %s", addr_name);
-
+
ret = krb5_kt_register(context, &hdb_kt_ops);
if(ret)
krb5_err(context, 1, ret, "krb5_kt_register");
@@ -162,11 +168,11 @@ main(int argc, char **argv)
krb5_err (context, 1, ret, "krb5_kt_default");
}
- ret = krb5_recvauth(context, &ac, &fd, HPROP_VERSION, NULL,
+ ret = krb5_recvauth(context, &ac, &sock, HPROP_VERSION, NULL,
0, keytab, &ticket);
if(ret)
krb5_err(context, 1, ret, "krb5_recvauth");
-
+
ret = krb5_unparse_name(context, ticket->server, &server);
if (ret)
krb5_err(context, 1, ret, "krb5_unparse_name");
@@ -179,17 +185,17 @@ main(int argc, char **argv)
ret = krb5_auth_con_getauthenticator(context, ac, &authent);
if(ret)
krb5_err(context, 1, ret, "krb5_auth_con_getauthenticator");
-
+
ret = krb5_make_principal(context, &c1, NULL, "kadmin", "hprop", NULL);
if(ret)
krb5_err(context, 1, ret, "krb5_make_principal");
- _krb5_principalname2krb5_principal(context, &c2,
+ _krb5_principalname2krb5_principal(context, &c2,
authent->cname, authent->crealm);
if(!krb5_principal_compare(context, c1, c2)) {
char *s;
ret = krb5_unparse_name(context, c2, &s);
if (ret)
- s = "unparseable name";
+ s = unparseable_name;
krb5_errx(context, 1, "Unauthorized connection from %s", s);
}
krb5_free_principal(context, c1);
@@ -199,7 +205,7 @@ main(int argc, char **argv)
if(ret)
krb5_err(context, 1, ret, "krb5_kt_close");
}
-
+
if(!print_dump) {
asprintf(&tmp_db, "%s~", database);
@@ -217,11 +223,11 @@ main(int argc, char **argv)
hdb_entry_ex entry;
if(from_stdin) {
- ret = krb5_read_message(context, &fd, &data);
+ ret = krb5_read_message(context, &sock, &data);
if(ret != 0 && ret != HEIM_ERR_EOF)
krb5_err(context, 1, ret, "krb5_read_message");
} else {
- ret = krb5_read_priv_message(context, ac, &fd, &data);
+ ret = krb5_read_priv_message(context, ac, &sock, &data);
if(ret)
krb5_err(context, 1, ret, "krb5_read_priv_message");
}
@@ -230,15 +236,15 @@ main(int argc, char **argv)
if(!from_stdin) {
data.data = NULL;
data.length = 0;
- krb5_write_priv_message(context, ac, &fd, &data);
+ krb5_write_priv_message(context, ac, &sock, &data);
}
if(!print_dump) {
- ret = db->hdb_rename(context, db, database);
- if(ret)
- krb5_err(context, 1, ret, "db_rename");
ret = db->hdb_close(context, db);
if(ret)
krb5_err(context, 1, ret, "db_close");
+ ret = db->hdb_rename(context, db, database);
+ if(ret)
+ krb5_err(context, 1, ret, "db_rename");
}
break;
}
@@ -255,10 +261,10 @@ main(int argc, char **argv)
char *s;
ret = krb5_unparse_name(context, entry.entry.principal, &s);
if (ret)
- s = strdup("unparseable name");
+ s = strdup(unparseable_name);
krb5_warnx(context, "Entry exists: %s", s);
free(s);
- } else if(ret)
+ } else if(ret)
krb5_err(context, 1, ret, "db_store");
else
nprincs++;
@@ -267,5 +273,9 @@ main(int argc, char **argv)
}
if (!print_dump)
krb5_log(context, fac, 0, "Received %d principals", nprincs);
+
+ if (inetd_flag == 0)
+ rk_closesocket(sock);
+
exit(0);
}
OpenPOWER on IntegriCloud