krb5/krb5-1.6.1-empty.patch

226 lines
9.0 KiB
Diff
Raw Normal View History

Treat empty values of KRB5CCNAME (and other variables which can't usefully
be set to empty values) as if they were not set. Incomplete and needs more
thought about whether or not it's even correct.
diff -ur krb5-1.6.1/src/appl/bsd/krshd.c krb5-1.6.1/src/appl/bsd/krshd.c
--- krb5-1.6.1/src/appl/bsd/krshd.c 2006-10-15 03:50:16.000000000 -0400
+++ krb5-1.6.1/src/appl/bsd/krshd.c 2007-05-18 19:51:18.000000000 -0400
@@ -1438,7 +1438,7 @@
* child's environment. This can't really have
* a fixed position because tz may or may not be set.
*/
- if (getenv("KRB5CCNAME")) {
+ if (getenv("KRB5CCNAME") && getenv("KRB5CCNAME")[0]) {
int i;
char *buf2 = (char *)malloc(strlen(getenv("KRB5CCNAME"))
+strlen("KRB5CCNAME=")+1);
diff -ur krb5-1.6.1/src/appl/bsd/login.c krb5-1.6.1/src/appl/bsd/login.c
--- krb5-1.6.1/src/appl/bsd/login.c 2006-08-08 15:26:40.000000000 -0400
+++ krb5-1.6.1/src/appl/bsd/login.c 2007-05-18 19:49:32.000000000 -0400
@@ -528,7 +528,7 @@
login_get_kconf(kcontext);
/* Set up the credential cache environment variable */
- if (!getenv(KRB5_ENV_CCNAME)) {
+ if (!getenv(KRB5_ENV_CCNAME) || !getenv(KRB5_ENV_CCNAME)[0]) {
sprintf(ccfile, "FILE:/tmp/krb5cc_p%ld", (long) getpid());
setenv(KRB5_ENV_CCNAME, ccfile, 1);
krb5_cc_set_default_name(kcontext, ccfile);
@@ -1763,7 +1763,7 @@
setenv ("TZ", tz, 1);
#endif
- if (ccname)
+ if (ccname && ccname[0])
setenv("KRB5CCNAME", ccname, 1);
setenv("HOME", pwd->pw_dir, 1);
diff -ur krb5-1.6.1/src/appl/bsd/v4rcp.c krb5-1.6.1/src/appl/bsd/v4rcp.c
--- krb5-1.6.1/src/appl/bsd/v4rcp.c 2006-08-08 15:26:40.000000000 -0400
+++ krb5-1.6.1/src/appl/bsd/v4rcp.c 2007-05-18 19:50:40.000000000 -0400
@@ -1060,7 +1060,7 @@
fprintf(stderr, "v4rcp: couldn't get local address (KRB5LOCALADDR)\n");
exit(1);
}
- if ((envaddr = getenv("KRB5REMOTEADDR"))) {
+ if ((envaddr = getenv("KRB5REMOTEADDR")) && envaddr[0]) {
#ifdef HAVE_INET_ATON
inet_aton(envaddr, &foreign.sin_addr);
#else
@@ -1068,7 +1068,7 @@
#endif
foreign.sin_family = AF_INET;
envaddr = getenv("KRB5REMOTEPORT");
- if (envaddr)
+ if (envaddr && envaddr[0])
foreign.sin_port = htons(atoi(envaddr));
else
foreign.sin_port = 0;
diff -ur krb5-1.6.1/src/appl/telnet/libtelnet/kerberos5.c krb5-1.6.1/src/appl/telnet/libtelnet/kerberos5.c
--- krb5-1.6.1/src/appl/telnet/libtelnet/kerberos5.c 2006-12-01 16:27:28.000000000 -0500
+++ krb5-1.6.1/src/appl/telnet/libtelnet/kerberos5.c 2007-05-18 19:48:51.000000000 -0400
@@ -205,7 +205,7 @@
return;
ccname = getenv("KRB5CCNAME");
- if (ccname) {
+ if (ccname && ccname[0]) {
retval = krb5_cc_resolve(telnet_context, ccname, &ccache);
if (!retval)
retval = krb5_cc_destroy(telnet_context, ccache);
diff -ur krb5-1.6.1/src/lib/kadm5/alt_prof.c krb5-1.6.1/src/lib/kadm5/alt_prof.c
--- krb5-1.6.1/src/lib/kadm5/alt_prof.c 2006-05-15 21:45:00.000000000 -0400
+++ krb5-1.6.1/src/lib/kadm5/alt_prof.c 2007-05-18 19:17:53.000000000 -0400
@@ -82,7 +82,8 @@
if (i > 0)
krb5_config_len--;
if (envname == NULL
- || (kdc_config = getenv(envname)) == NULL)
+ || (kdc_config = getenv(envname)) == NULL
+ || (kdc_config[0] == '\0'))
kdc_config = fname;
if (kdc_config == NULL)
kdc_config_len = 0;
@@ -494,7 +495,8 @@
!krb5_aprof_get_string(aprofile, hierarchy, TRUE, &svalue)) {
params.mask |= KADM5_CONFIG_ADMIN_KEYTAB;
params.admin_keytab = svalue;
- } else if ((params.admin_keytab = (char *) getenv("KRB5_KTNAME"))) {
+ } else if ((params.admin_keytab = (char *) getenv("KRB5_KTNAME")) &&
+ (params.admin_keytab[0] != '\0')) {
params.admin_keytab = strdup(params.admin_keytab);
if (params.admin_keytab)
params.mask |= KADM5_CONFIG_ADMIN_KEYTAB;
diff -ur krb5-1.6.1/src/lib/krb4/g_cnffile.c krb5-1.6.1/src/lib/krb4/g_cnffile.c
--- krb5-1.6.1/src/lib/krb4/g_cnffile.c 2003-06-06 10:44:33.000000000 -0400
+++ krb5-1.6.1/src/lib/krb4/g_cnffile.c 2007-05-18 19:57:48.000000000 -0400
@@ -89,7 +89,7 @@
/* standard V4 override first */
s = getenv("KRB_CONF");
- if (s) cnffile = fopen(s,"r");
+ if (s && s[0]) cnffile = fopen(s,"r");
/* if that's wrong, use V5 config */
if (!cnffile) cnffile = krb__v5_get_file("krb4_config");
/* and if V5 config doesn't have it, go to hard-coded values */
@@ -109,7 +109,7 @@
/* standard (not really) V4 override first */
s = getenv("KRB_REALMS");
- if (s) realmsfile = fopen(s,"r");
+ if (s && s[0]) realmsfile = fopen(s,"r");
if (!realmsfile) realmsfile = krb__v5_get_file("krb4_realms");
if (!realmsfile) realmsfile = fopen(KRB_RLM_TRANS, "r");
diff -ur krb5-1.6.1/src/lib/krb4/tkt_string.c krb5-1.6.1/src/lib/krb4/tkt_string.c
--- krb5-1.6.1/src/lib/krb4/tkt_string.c 2006-03-11 17:23:28.000000000 -0500
+++ krb5-1.6.1/src/lib/krb4/tkt_string.c 2007-05-18 19:57:57.000000000 -0400
@@ -67,7 +67,7 @@
if (!*krb_ticket_string) {
env = getenv("KRBTKFILE");
- if (env) {
+ if (env && env[0]) {
(void) strncpy(krb_ticket_string, env,
sizeof(krb_ticket_string)-1);
krb_ticket_string[sizeof(krb_ticket_string)-1] = '\0';
diff -ur krb5-1.6.1/src/lib/krb5/ccache/cccursor.c krb5-1.6.1/src/lib/krb5/ccache/cccursor.c
--- krb5-1.6.1/src/lib/krb5/ccache/cccursor.c 2006-11-07 15:18:31.000000000 -0500
+++ krb5-1.6.1/src/lib/krb5/ccache/cccursor.c 2007-05-18 19:19:11.000000000 -0400
@@ -136,7 +136,7 @@
/* fall through */
case CCCURSOR_ENV:
name = getenv(KRB5_ENV_CCNAME);
- if (name != NULL) {
+ if ((name != NULL) && (name[0] != '\0')) {
cursor->pos = CCCURSOR_OS;
ret = cccol_do_resolve(context, cursor, name, ccache);
if (ret)
diff -ur krb5-1.6.1/src/lib/krb5/os/ccdefname.c krb5-1.6.1/src/lib/krb5/os/ccdefname.c
--- krb5-1.6.1/src/lib/krb5/os/ccdefname.c 2007-03-29 20:36:20.000000000 -0400
+++ krb5-1.6.1/src/lib/krb5/os/ccdefname.c 2007-05-18 18:32:20.000000000 -0400
@@ -292,7 +292,7 @@
/* try the environment variable first */
new_ccname = getenv(KRB5_ENV_CCNAME);
- if (new_ccname == NULL) {
+ if ((new_ccname == NULL) || (new_ccname[0] == '\0')) {
/* fall back on the default ccache name for the OS */
new_ccname = new_ccbuf;
err = get_from_os (new_ccbuf, sizeof (new_ccbuf));
diff -ur krb5-1.6.1/src/lib/krb5/os/init_os_ctx.c krb5-1.6.1/src/lib/krb5/os/init_os_ctx.c
--- krb5-1.6.1/src/lib/krb5/os/init_os_ctx.c 2007-04-10 17:51:46.000000000 -0400
+++ krb5-1.6.1/src/lib/krb5/os/init_os_ctx.c 2007-05-18 18:32:20.000000000 -0400
@@ -196,7 +196,7 @@
if (!secure)
{
char *env = getenv("KRB5_CONFIG");
- if (env)
+ if (env && env[0])
{
name = malloc(strlen(env) + 1);
if (!name) return ENOMEM;
@@ -250,7 +250,7 @@
filepath = DEFAULT_SECURE_PROFILE_PATH;
} else {
filepath = getenv("KRB5_CONFIG");
- if (!filepath) filepath = DEFAULT_PROFILE_PATH;
+ if (!filepath || !(filepath[0])) filepath = DEFAULT_PROFILE_PATH;
}
/* count the distinct filename components */
@@ -297,7 +297,7 @@
profile_filespec_t *newfiles;
file = getenv(KDC_PROFILE_ENV);
- if (file == NULL)
+ if ((file == NULL) || (file[0] == '\0'))
file = DEFAULT_KDC_PROFILE;
for (count = 0; (*pfiles)[count]; count++)
diff -ur krb5-1.6.1/src/lib/krb5/os/ktdefname.c krb5-1.6.1/src/lib/krb5/os/ktdefname.c
--- krb5-1.6.1/src/lib/krb5/os/ktdefname.c 2002-09-03 15:29:37.000000000 -0400
+++ krb5-1.6.1/src/lib/krb5/os/ktdefname.c 2007-05-18 19:19:28.000000000 -0400
@@ -47,7 +47,7 @@
return KRB5_CONFIG_NOTENUFSPACE;
strcpy(name, krb5_overridekeyname);
} else if ((context->profile_secure == FALSE) &&
- (cp = getenv("KRB5_KTNAME"))) {
+ (cp = getenv("KRB5_KTNAME")) && (cp[0] != '\0')) {
if ((size_t) namesize < (strlen(cp)+1))
return KRB5_CONFIG_NOTENUFSPACE;
strcpy(name, cp);
diff -ur krb5-1.6.1/src/lib/krb5/rcache/rc_base.c krb5-1.6.1/src/lib/krb5/rcache/rc_base.c
--- krb5-1.6.1/src/lib/krb5/rcache/rc_base.c 2006-06-08 16:01:44.000000000 -0400
+++ krb5-1.6.1/src/lib/krb5/rcache/rc_base.c 2007-05-18 19:18:48.000000000 -0400
@@ -94,7 +94,7 @@
char * krb5_rc_default_type(krb5_context context)
{
char *s;
- if ((s = getenv("KRB5RCACHETYPE")))
+ if ((s = getenv("KRB5RCACHETYPE")) && (s[0] != '\0'))
return s;
else
return "dfl";
@@ -103,7 +103,7 @@
char * krb5_rc_default_name(krb5_context context)
{
char *s;
- if ((s = getenv("KRB5RCACHENAME")))
+ if ((s = getenv("KRB5RCACHENAME")) && (s[0] != '\0'))
return s;
else
return (char *) 0;
diff -ur krb5-1.6.1/src/lib/krb5/rcache/rc_io.c krb5-1.6.1/src/lib/krb5/rcache/rc_io.c
--- krb5-1.6.1/src/lib/krb5/rcache/rc_io.c 2006-12-18 18:11:28.000000000 -0500
+++ krb5-1.6.1/src/lib/krb5/rcache/rc_io.c 2007-05-18 18:32:20.000000000 -0400
@@ -47,7 +47,7 @@
{
char *dir;
- if (!(dir = getenv("KRB5RCACHEDIR"))) {
+ if (!(dir = getenv("KRB5RCACHEDIR")) || !dir[0]) {
#if defined(_WIN32)
if (!(dir = getenv("TEMP")))
if (!(dir = getenv("TMP")))