svn commit: samba r17995 - in branches/SAMBA_3_0/source/libads: .
jra at samba.org
jra at samba.org
Sat Sep 2 01:33:16 GMT 2006
Author: jra
Date: 2006-09-02 01:33:13 +0000 (Sat, 02 Sep 2006)
New Revision: 17995
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=17995
Log:
Ensure we create the domain-specific krb5 files in a
separate directory.
Jeremy.
Modified:
branches/SAMBA_3_0/source/libads/kerberos.c
Changeset:
Modified: branches/SAMBA_3_0/source/libads/kerberos.c
===================================================================
--- branches/SAMBA_3_0/source/libads/kerberos.c 2006-09-02 01:23:08 UTC (rev 17994)
+++ branches/SAMBA_3_0/source/libads/kerberos.c 2006-09-02 01:33:13 UTC (rev 17995)
@@ -474,13 +474,27 @@
BOOL create_local_private_krb5_conf_for_domain(const char *realm, const char *domain, struct in_addr ip)
{
XFILE *xfp = NULL;
- char *fname = talloc_asprintf(NULL, "%s/smb_krb5.conf.%s", lp_private_dir(), domain);
+ char *dname = talloc_asprintf(NULL, "%s/smb_krb5", lp_private_dir());
+ char *fname = NULL;
char *file_contents = NULL;
size_t flen = 0;
char *realm_upper = NULL;
int loopcount = 0;
+ if (!dname) {
+ return False;
+ }
+ if (mkdir(dname, 0700)==-1) {
+ DEBUG(0,("create_local_private_krb5_conf_for_domain: "
+ "failed to create directory %s. Error was %s\n",
+ dname, strerror(errno) ));
+ TALLOC_FREE(dname);
+ return False;
+ }
+
+ fname = talloc_asprintf(dname, "%s/krb5.conf.%s", dname, domain);
if (!fname) {
+ TALLOC_FREE(dname);
return False;
}
@@ -496,7 +510,7 @@
realm_upper, realm_upper, inet_ntoa(ip));
if (!file_contents) {
- TALLOC_FREE(fname);
+ TALLOC_FREE(dname);
return False;
}
@@ -507,14 +521,14 @@
xfp = x_fopen(fname, O_CREAT|O_WRONLY, 0600);
if (!xfp) {
- TALLOC_FREE(fname);
+ TALLOC_FREE(dname);
return False;
}
/* Lock the file. */
if (!fcntl_lock(xfp->fd, F_SETLKW, 0, 1, F_WRLCK)) {
unlink(fname);
x_fclose(xfp);
- TALLOC_FREE(fname);
+ TALLOC_FREE(dname);
return False;
}
@@ -528,7 +542,7 @@
}
unlink(fname);
x_fclose(xfp);
- TALLOC_FREE(fname);
+ TALLOC_FREE(dname);
return False;
}
break;
@@ -537,17 +551,17 @@
if (x_fwrite(file_contents, flen, 1, xfp) != flen) {
unlink(fname);
x_fclose(xfp);
- TALLOC_FREE(fname);
+ TALLOC_FREE(dname);
return False;
}
if (x_fclose(xfp)==-1) {
unlink(fname);
- TALLOC_FREE(fname);
+ TALLOC_FREE(dname);
return False;
}
/* Set the environment variable to this file. */
setenv("KRB5_CONFIG", fname, 1);
- TALLOC_FREE(fname);
+ TALLOC_FREE(dname);
DEBUG(5,("create_local_private_krb5_conf_for_domain: wrote "
"file %s with realm %s KDC = %s\n",
More information about the samba-cvs
mailing list