[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Wed Jun 1 18:52:01 MDT 2011


The branch, master has been updated
       via  e98fb2f Remove another PATH_MAX.
       via  388bba0 Remove a PATH_MAX.
      from  c06a31d Fix const warnings.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit e98fb2f2b9542de97dee3f1a3e077d5306ec27b1
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Jun 1 16:40:05 2011 -0700

    Remove another PATH_MAX.
    
    Autobuild-User: Jeremy Allison <jra at samba.org>
    Autobuild-Date: Thu Jun  2 02:51:06 CEST 2011 on sn-devel-104

commit 388bba05cf2bf3674831409d781a65c1f90292fa
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Jun 1 16:07:24 2011 -0700

    Remove a PATH_MAX.

-----------------------------------------------------------------------

Summary of changes:
 nsswitch/pam_winbind.c    |    5 +++--
 source3/libads/kerberos.c |   39 +++++++++++++++++++++++++++------------
 2 files changed, 30 insertions(+), 14 deletions(-)


Changeset truncated at 500 lines:

diff --git a/nsswitch/pam_winbind.c b/nsswitch/pam_winbind.c
index f7637e7..7d5b70e 100644
--- a/nsswitch/pam_winbind.c
+++ b/nsswitch/pam_winbind.c
@@ -1212,7 +1212,7 @@ out:
 static void _pam_setup_krb5_env(struct pwb_context *ctx,
 				struct wbcLogonUserInfo *info)
 {
-	char var[PATH_MAX];
+	char *var = NULL;
 	int ret;
 	uint32_t i;
 	const char *krb5ccname = NULL;
@@ -1239,7 +1239,7 @@ static void _pam_setup_krb5_env(struct pwb_context *ctx,
 	_pam_log_debug(ctx, LOG_DEBUG,
 		       "request returned KRB5CCNAME: %s", krb5ccname);
 
-	if (snprintf(var, sizeof(var), "KRB5CCNAME=%s", krb5ccname) == -1) {
+	if (asprintf(&var, "KRB5CCNAME=%s", krb5ccname) == -1) {
 		return;
 	}
 
@@ -1249,6 +1249,7 @@ static void _pam_setup_krb5_env(struct pwb_context *ctx,
 			 "failed to set KRB5CCNAME to %s: %s",
 			 var, pam_strerror(ctx->pamh, ret));
 	}
+	free(var);
 }
 
 /**
diff --git a/source3/libads/kerberos.c b/source3/libads/kerberos.c
index 0b62ebf..48a832e 100644
--- a/source3/libads/kerberos.c
+++ b/source3/libads/kerberos.c
@@ -958,22 +958,37 @@ bool create_local_private_krb5_conf_for_domain(const char *realm,
 	/* Insanity, sheer insanity..... */
 
 	if (strequal(realm, lp_realm())) {
-		char linkpath[PATH_MAX+1];
-		int lret;
-
-		lret = readlink(SYSTEM_KRB5_CONF_PATH, linkpath, sizeof(linkpath)-1);
-		if (lret != -1) {
-			linkpath[lret] = '\0';
-		}
-
-		if (lret != -1 || strcmp(linkpath, fname) == 0) {
-			/* Symlink already exists. */
-			goto done;
+		SMB_STRUCT_STAT sbuf;
+
+		if (sys_lstat(SYSTEM_KRB5_CONF_PATH, &sbuf, false) == 0) {
+			if (S_ISLNK(sbuf.st_ex_mode) && sbuf.st_ex_size) {
+				int lret;
+				size_t alloc_size = sbuf.st_ex_size + 1;
+				char *linkpath = TALLOC_ARRAY(talloc_tos(), char,
+						alloc_size);
+				if (!linkpath) {
+					goto done;
+				}
+				lret = readlink(SYSTEM_KRB5_CONF_PATH, linkpath,
+						alloc_size - 1);
+				if (lret == -1) {
+					TALLOC_FREE(linkpath);
+					goto done;
+				}
+				linkpath[lret] = '\0';
+
+				if (strcmp(linkpath, fname) == 0) {
+					/* Symlink already exists. */
+					TALLOC_FREE(linkpath);
+					goto done;
+				}
+				TALLOC_FREE(linkpath);
+			}
 		}
 
 		/* Try and replace with a symlink. */
 		if (symlink(fname, SYSTEM_KRB5_CONF_PATH) == -1) {
-			const char *newpath = SYSTEM_KRB5_CONF_PATH ## ".saved";
+			const char *newpath = SYSTEM_KRB5_CONF_PATH ".saved";
 			if (errno != EEXIST) {
 				DEBUG(0,("create_local_private_krb5_conf_for_domain: symlink "
 					"of %s to %s failed. Errno %s\n",


-- 
Samba Shared Repository


More information about the samba-cvs mailing list