Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/login make krb5 compile again. XXX: one function lef...
details: https://anonhg.NetBSD.org/src/rev/287efd6953dc
branches: trunk
changeset: 778969:287efd6953dc
user: christos <christos%NetBSD.org@localhost>
date: Sun Apr 22 23:26:19 2012 +0000
description:
make krb5 compile again. XXX: one function left that is deprecated, what's
the new equivalent?
diffstat:
usr.bin/login/Makefile | 6 ++-
usr.bin/login/common.c | 24 ++++++++++-----
usr.bin/login/common.h | 10 +++--
usr.bin/login/k5login.c | 75 +++++++++++++++++++++++-----------------------
usr.bin/login/login.c | 33 ++++++++++----------
usr.bin/login/login_pam.c | 20 +++++------
6 files changed, 89 insertions(+), 79 deletions(-)
diffs (truncated from 499 to 300 lines):
diff -r 8aae73459a18 -r 287efd6953dc usr.bin/login/Makefile
--- a/usr.bin/login/Makefile Sun Apr 22 21:29:27 2012 +0000
+++ b/usr.bin/login/Makefile Sun Apr 22 23:26:19 2012 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.52 2011/04/24 21:42:06 elric Exp $
+# $NetBSD: Makefile,v 1.53 2012/04/22 23:26:19 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 7/19/93
-WARNS?= 2 # XXX -Wcast-qual issues
+WARNS?= 5 # XXX -Wcast-qual issues
.include <bsd.own.mk>
@@ -25,6 +25,8 @@
.if (${USE_KERBEROS} != "no")
SRCS+= k5login.c
CPPFLAGS+=-DKERBEROS5
+# XXX: for krb5_get_in_tkt_with_password
+CPPFLAGS+=-DKRB5_DEPRECATED=
DPADD+= ${LIBKRB5} ${LIBASN1}
LDADD+= -lkrb5 -lasn1
diff -r 8aae73459a18 -r 287efd6953dc usr.bin/login/common.c
--- a/usr.bin/login/common.c Sun Apr 22 21:29:27 2012 +0000
+++ b/usr.bin/login/common.c Sun Apr 22 23:26:19 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: common.c,v 1.3 2009/12/29 20:15:15 christos Exp $ */
+/* $NetBSD: common.c,v 1.4 2012/04/22 23:26:19 christos Exp $ */
/*-
* Copyright (c) 1980, 1987, 1988, 1991, 1993, 1994
@@ -29,7 +29,7 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: common.c,v 1.3 2009/12/29 20:15:15 christos Exp $");
+__RCSID("$NetBSD: common.c,v 1.4 2012/04/22 23:26:19 christos Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -77,11 +77,20 @@
void decode_ss(const char *);
struct passwd *pwd;
int failures, have_ss;
-char term[64], *envinit[1], *hostname, *username, *tty, *nested;
+char term[64], *envinit[1], *hostname, *tty, *nested;
+const char *username;
struct timeval now;
struct sockaddr_storage ss;
-void
+char *
+trimloginname(char *u)
+{
+ if (strlen(u) > MAXLOGNAME)
+ u[MAXLOGNAME] = '\0';
+ return u;
+}
+
+char *
getloginname(void)
{
int ch;
@@ -104,8 +113,7 @@
"login names may not start with '-'.\n");
else {
*p = '\0';
- username = nbuf;
- break;
+ return nbuf;
}
}
}
@@ -122,7 +130,7 @@
static jmp_buf motdinterrupt;
void
-motd(char *fname)
+motd(const char *fname)
{
int fd, nchars;
sig_t oldint;
@@ -243,7 +251,7 @@
utmpx.ut_type = USER_PROCESS;
utmpx.ut_pid = getpid();
t = tty + strlen(tty);
- if (t - tty >= sizeof(utmpx.ut_id)) {
+ if ((size_t)(t - tty) >= sizeof(utmpx.ut_id)) {
(void)strncpy(utmpx.ut_id, t - sizeof(utmpx.ut_id),
sizeof(utmpx.ut_id));
} else {
diff -r 8aae73459a18 -r 287efd6953dc usr.bin/login/common.h
--- a/usr.bin/login/common.h Sun Apr 22 21:29:27 2012 +0000
+++ b/usr.bin/login/common.h Sun Apr 22 23:26:19 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: common.h,v 1.1 2009/12/29 19:26:13 christos Exp $ */
+/* $NetBSD: common.h,v 1.2 2012/04/22 23:26:19 christos Exp $ */
/*-
* Copyright (c) 1980, 1987, 1988, 1991, 1993, 1994
@@ -33,8 +33,9 @@
void badlogin(const char *);
void update_db(int, int, int);
-void getloginname(void);
-void motd(char *);
+char *trimloginname(char *);
+char *getloginname(void);
+void motd(const char *);
int rootterm(char *);
void sigint(int);
void sleepexit(int);
@@ -45,7 +46,8 @@
extern u_int timeout;
extern struct passwd *pwd;
extern int failures, have_ss;
-extern char term[64], *envinit[1], *hostname, *username, *tty, *nested;
+extern char term[64], *envinit[1], *hostname, *tty, *nested;
+extern const char *username;
extern struct timeval now;
extern struct sockaddr_storage ss;
extern const char copyrightstr[];
diff -r 8aae73459a18 -r 287efd6953dc usr.bin/login/k5login.c
--- a/usr.bin/login/k5login.c Sun Apr 22 21:29:27 2012 +0000
+++ b/usr.bin/login/k5login.c Sun Apr 22 23:26:19 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: k5login.c,v 1.27 2006/03/23 23:33:28 wiz Exp $ */
+/* $NetBSD: k5login.c,v 1.28 2012/04/22 23:26:19 christos Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -51,7 +51,7 @@
#if 0
static char sccsid[] = "@(#)klogin.c 5.11 (Berkeley) 7/12/92";
#endif
-__RCSID("$NetBSD: k5login.c,v 1.27 2006/03/23 23:33:28 wiz Exp $");
+__RCSID("$NetBSD: k5login.c,v 1.28 2012/04/22 23:26:19 christos Exp $");
#endif /* not lint */
#ifdef KERBEROS5
@@ -89,13 +89,6 @@
int k5login(struct passwd *, char *, char *, char *);
void k5destroy(void);
-#ifndef krb5_realm_length
-#define krb5_realm_length(r) ((r).length)
-#endif
-#ifndef krb5_realm_data
-#define krb5_realm_data(r) ((r).data)
-#endif
-
/*
* Verify the Kerberos ticket-granting ticket just retrieved for the
* user. If the Kerberos server doesn't respond, assume the user is
@@ -163,8 +156,9 @@
else if (kerror) {
krb5_warn(kcontext, kerror,
"Unable to verify Kerberos V5 TGT: %s", phost);
- syslog(LOG_NOTICE, "Kerberos V5 TGT bad: %s",
- krb5_get_err_text(kcontext, kerror));
+ const char *msg = krb5_get_error_message(kcontext, kerror);
+ syslog(LOG_NOTICE, "Kerberos V5 TGT bad: %s", msg);
+ krb5_free_error_message(kcontext, msg);
retval = -1;
goto EGRESS;
}
@@ -192,11 +186,11 @@
retval = -1;
}
krb5_warn(kcontext, kerror, "Unable to verify host ticket");
+ const char *msg = krb5_get_error_message(kcontext, kerror);
syslog(LOG_NOTICE, "can't verify v5 ticket: %s; %s\n",
- krb5_get_err_text(kcontext, kerror),
- retval
- ? "keytab found, assuming failure"
- : "no keytab found, assuming success");
+ msg, retval ? "keytab found, assuming failure"
+ : "no keytab found, assuming success");
+ krb5_free_error_message(kcontext, msg);
goto EGRESS;
}
/*
@@ -243,13 +237,13 @@
}
mcreds.client = me;
+ const char *realm = krb5_principal_get_realm(kcontext, me);
+ size_t rlen = strlen(realm);
kerror = krb5_build_principal_ext(kcontext, &mcreds.server,
- krb5_realm_length(*krb5_princ_realm(kcontext, me)),
- krb5_realm_data(*krb5_princ_realm(kcontext, me)),
+ rlen, realm,
KRB5_TGS_NAME_SIZE,
KRB5_TGS_NAME,
- krb5_realm_length(*krb5_princ_realm(kcontext, me)),
- krb5_realm_data(*krb5_princ_realm(kcontext, me)),
+ rlen, realm,
0);
if (kerror) {
krb5_warn(kcontext, kerror, "while building server name");
@@ -372,27 +366,35 @@
}
if ((kerror = krb5_cc_resolve(kcontext, tkt_location, &ccache)) != 0) {
+ const char *msg = krb5_get_error_message(kcontext, kerror);
syslog(LOG_NOTICE, "warning: %s while getting default ccache",
- krb5_get_err_text(kcontext, kerror));
+ msg);
+ krb5_free_error_message(kcontext, msg);
return (1);
}
if ((kerror = krb5_parse_name(kcontext, principal, &me)) != 0) {
- syslog(LOG_NOTICE, "warning: %s when parsing name %s",
- krb5_get_err_text(kcontext, kerror), principal);
+ const char *msg = krb5_get_error_message(kcontext, kerror);
+ syslog(LOG_NOTICE, "warning: %s when parsing name %s", msg,
+ principal);
+ krb5_free_error_message(kcontext, msg);
return (1);
}
if ((kerror = krb5_unparse_name(kcontext, me, &client_name)) != 0) {
+ const char *msg = krb5_get_error_message(kcontext, kerror);
syslog(LOG_NOTICE, "warning: %s when unparsing name %s",
- krb5_get_err_text(kcontext, kerror), principal);
+ msg, principal);
+ krb5_free_error_message(kcontext, msg);
return (1);
}
kerror = krb5_cc_initialize(kcontext, ccache, me);
if (kerror != 0) {
+ const char *msg = krb5_get_error_message(kcontext, kerror);
syslog(LOG_NOTICE, "%s when initializing cache %s",
- krb5_get_err_text(kcontext, kerror), tkt_location);
+ msg, tkt_location);
+ krb5_free_error_message(kcontext, msg);
return (1);
}
@@ -400,25 +402,27 @@
my_creds.client = me;
+ const char *xrealm = krb5_principal_get_realm(kcontext, me);
+ size_t rlen = strlen(xrealm);
if ((kerror = krb5_build_principal_ext(kcontext,
&server,
- krb5_realm_length(*krb5_princ_realm(kcontext, me)),
- krb5_realm_data(*krb5_princ_realm(kcontext, me)),
+ rlen, xrealm,
KRB5_TGS_NAME_SIZE,
KRB5_TGS_NAME,
- krb5_realm_length(*krb5_princ_realm(kcontext, me)),
- krb5_realm_data(*krb5_princ_realm(kcontext, me)),
+ rlen, xrealm,
0)) != 0) {
- syslog(LOG_NOTICE, "%s while building server name",
- krb5_get_err_text(kcontext, kerror));
+ const char *msg = krb5_get_error_message(kcontext, kerror);
+ syslog(LOG_NOTICE, "%s while building server name", msg);
+ krb5_free_error_message(kcontext, msg);
return (1);
}
my_creds.server = server;
if ((kerror = krb5_timeofday(kcontext, &now)) != 0) {
- syslog(LOG_NOTICE, "%s while getting time of day",
- krb5_get_err_text(kcontext, kerror));
+ const char *msg = krb5_get_error_message(kcontext, kerror);
+ syslog(LOG_NOTICE, "%s while getting time of day", msg);
+ krb5_free_error_message(kcontext, msg);
return (1);
}
@@ -428,12 +432,7 @@
my_creds.times.renew_till = 0;
kerror = krb5_get_in_tkt_with_password(kcontext, options,
- NULL,
- NULL,
- NULL,
- password,
- ccache,
- &my_creds, 0);
+ NULL, NULL, NULL, password, ccache, &my_creds, 0);
if (my_creds.server != NULL)
krb5_free_principal(kcontext, my_creds.server);
diff -r 8aae73459a18 -r 287efd6953dc usr.bin/login/login.c
--- a/usr.bin/login/login.c Sun Apr 22 21:29:27 2012 +0000
+++ b/usr.bin/login/login.c Sun Apr 22 23:26:19 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: login.c,v 1.98 2011/08/31 16:24:57 plunky Exp $ */
+/* $NetBSD: login.c,v 1.99 2012/04/22 23:26:19 christos Exp $ */
/*-
* Copyright (c) 1980, 1987, 1988, 1991, 1993, 1994
Home |
Main Index |
Thread Index |
Old Index