summaryrefslogtreecommitdiff
path: root/source3/libads
diff options
context:
space:
mode:
Diffstat (limited to 'source3/libads')
-rw-r--r--source3/libads/kerberos.c18
-rw-r--r--source3/libads/ldap.c26
2 files changed, 22 insertions, 22 deletions
diff --git a/source3/libads/kerberos.c b/source3/libads/kerberos.c
index f259c21bdb..29e5661d3c 100644
--- a/source3/libads/kerberos.c
+++ b/source3/libads/kerberos.c
@@ -829,13 +829,15 @@ bool create_local_private_krb5_conf_for_domain(const char *realm,
/* Insanity, sheer insanity..... */
if (strequal(realm, lp_realm())) {
- pstring linkpath;
+ char linkpath[PATH_MAX+1];
int lret;
lret = readlink(SYSTEM_KRB5_CONF_PATH, linkpath, sizeof(linkpath)-1);
- linkpath[sizeof(pstring)-1] = '\0';
+ if (lret != -1) {
+ linkpath[lret] = '\0';
+ }
- if (lret == 0 || strcmp(linkpath, fname) == 0) {
+ if (lret != -1 || strcmp(linkpath, fname) == 0) {
/* Symlink already exists. */
TALLOC_FREE(dname);
return True;
@@ -843,6 +845,7 @@ bool create_local_private_krb5_conf_for_domain(const char *realm,
/* Try and replace with a symlink. */
if (symlink(fname, SYSTEM_KRB5_CONF_PATH) == -1) {
+ 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",
@@ -851,20 +854,17 @@ bool create_local_private_krb5_conf_for_domain(const char *realm,
return True; /* Not a fatal error. */
}
- pstrcpy(linkpath, SYSTEM_KRB5_CONF_PATH);
- pstrcat(linkpath, ".saved");
-
/* Yes, this is a race conditon... too bad. */
- if (rename(SYSTEM_KRB5_CONF_PATH, linkpath) == -1) {
+ if (rename(SYSTEM_KRB5_CONF_PATH, newpath) == -1) {
DEBUG(0,("create_local_private_krb5_conf_for_domain: rename "
"of %s to %s failed. Errno %s\n",
- SYSTEM_KRB5_CONF_PATH, linkpath,
+ SYSTEM_KRB5_CONF_PATH, newpath,
strerror(errno) ));
TALLOC_FREE(dname);
return True; /* Not a fatal error. */
}
- if (symlink(fname, "/etc/krb5.conf") == -1) {
+ if (symlink(fname, SYSTEM_KRB5_CONF_PATH) == -1) {
DEBUG(0,("create_local_private_krb5_conf_for_domain: "
"forced symlink of %s to /etc/krb5.conf failed. Errno %s\n",
fname, strerror(errno) ));
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index 0294c4a5b5..01f6b00c02 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -251,7 +251,7 @@ static NTSTATUS ads_find_dc(ADS_STRUCT *ads)
const char *c_realm;
int count, i=0;
struct ip_service *ip_list;
- pstring realm;
+ const char *realm;
bool got_realm = False;
bool use_own_domain = False;
char *sitename;
@@ -261,7 +261,7 @@ static NTSTATUS ads_find_dc(ADS_STRUCT *ads)
/* realm */
c_realm = ads->server.realm;
-
+
if ( !c_realm || !*c_realm ) {
/* special case where no realm and no workgroup means our own */
if ( !ads->server.workgroup || !*ads->server.workgroup ) {
@@ -269,33 +269,33 @@ static NTSTATUS ads_find_dc(ADS_STRUCT *ads)
c_realm = lp_realm();
}
}
-
- if (c_realm && *c_realm)
+
+ if (c_realm && *c_realm)
got_realm = True;
-
- /* we need to try once with the realm name and fallback to the
+
+ /* we need to try once with the realm name and fallback to the
netbios domain name if we fail (if netbios has not been disabled */
-
+
if ( !got_realm && !lp_disable_netbios() ) {
c_realm = ads->server.workgroup;
if (!c_realm || !*c_realm) {
if ( use_own_domain )
c_realm = lp_workgroup();
}
-
+
if ( !c_realm || !*c_realm ) {
DEBUG(0,("ads_find_dc: no realm or workgroup! Don't know what to do\n"));
return NT_STATUS_INVALID_PARAMETER; /* rather need MISSING_PARAMETER ... */
}
}
-
- pstrcpy( realm, c_realm );
+
+ realm = c_realm;
sitename = sitename_fetch(realm);
again:
- DEBUG(6,("ads_find_dc: looking for %s '%s'\n",
+ DEBUG(6,("ads_find_dc: looking for %s '%s'\n",
(got_realm ? "realm" : "domain"), realm));
status = get_sorted_dc_list(realm, sitename, &ip_list, &count, got_realm);
@@ -305,7 +305,7 @@ static NTSTATUS ads_find_dc(ADS_STRUCT *ads)
got_realm = False;
goto again;
}
-
+
SAFE_FREE(sitename);
return status;
}
@@ -338,7 +338,7 @@ static NTSTATUS ads_find_dc(ADS_STRUCT *ads)
continue;
}
}
-
+
if ( ads_try_connect(ads, server) ) {
SAFE_FREE(ip_list);
SAFE_FREE(sitename);