summaryrefslogtreecommitdiff
path: root/source3/libads
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2011-02-11 11:14:27 +0100
committerGünther Deschner <gd@samba.org>2011-02-11 12:22:41 +0100
commitf076c76260f24e15be11394ea0bb9456564dda49 (patch)
tree873de80db04f57d91065ac4fe74ad3515d178bcb /source3/libads
parent16229e4cefb01c3bdf1cb1cef81f0eab1f1cc0e6 (diff)
downloadsamba-f076c76260f24e15be11394ea0bb9456564dda49.tar.gz
samba-f076c76260f24e15be11394ea0bb9456564dda49.tar.bz2
samba-f076c76260f24e15be11394ea0bb9456564dda49.zip
s3-libads: make ads_guess_service_principal static.
Guenther
Diffstat (limited to 'source3/libads')
-rw-r--r--source3/libads/ads_proto.h2
-rw-r--r--source3/libads/sasl.c69
-rw-r--r--source3/libads/util.c69
3 files changed, 69 insertions, 71 deletions
diff --git a/source3/libads/ads_proto.h b/source3/libads/ads_proto.h
index 6fbd3aa13f..040825e674 100644
--- a/source3/libads/ads_proto.h
+++ b/source3/libads/ads_proto.h
@@ -152,5 +152,3 @@ ADS_STATUS ads_setup_sasl_wrapping(ADS_STRUCT *ads,
/* The following definitions come from libads/util.c */
ADS_STATUS ads_change_trust_account_password(ADS_STRUCT *ads, char *host_principal);
-ADS_STATUS ads_guess_service_principal(ADS_STRUCT *ads,
- char **returned_principal);
diff --git a/source3/libads/sasl.c b/source3/libads/sasl.c
index 2ba347486a..e7daa8aec6 100644
--- a/source3/libads/sasl.c
+++ b/source3/libads/sasl.c
@@ -644,6 +644,75 @@ static void ads_free_service_principal(struct ads_service_principal *p)
ZERO_STRUCTP(p);
}
+
+static ADS_STATUS ads_guess_service_principal(ADS_STRUCT *ads,
+ char **returned_principal)
+{
+ char *princ = NULL;
+
+ if (ads->server.realm && ads->server.ldap_server) {
+ char *server, *server_realm;
+
+ server = SMB_STRDUP(ads->server.ldap_server);
+ server_realm = SMB_STRDUP(ads->server.realm);
+
+ if (!server || !server_realm) {
+ SAFE_FREE(server);
+ SAFE_FREE(server_realm);
+ return ADS_ERROR(LDAP_NO_MEMORY);
+ }
+
+ strlower_m(server);
+ strupper_m(server_realm);
+ if (asprintf(&princ, "ldap/%s@%s", server, server_realm) == -1) {
+ SAFE_FREE(server);
+ SAFE_FREE(server_realm);
+ return ADS_ERROR(LDAP_NO_MEMORY);
+ }
+
+ SAFE_FREE(server);
+ SAFE_FREE(server_realm);
+
+ if (!princ) {
+ return ADS_ERROR(LDAP_NO_MEMORY);
+ }
+ } else if (ads->config.realm && ads->config.ldap_server_name) {
+ char *server, *server_realm;
+
+ server = SMB_STRDUP(ads->config.ldap_server_name);
+ server_realm = SMB_STRDUP(ads->config.realm);
+
+ if (!server || !server_realm) {
+ SAFE_FREE(server);
+ SAFE_FREE(server_realm);
+ return ADS_ERROR(LDAP_NO_MEMORY);
+ }
+
+ strlower_m(server);
+ strupper_m(server_realm);
+ if (asprintf(&princ, "ldap/%s@%s", server, server_realm) == -1) {
+ SAFE_FREE(server);
+ SAFE_FREE(server_realm);
+ return ADS_ERROR(LDAP_NO_MEMORY);
+ }
+
+ SAFE_FREE(server);
+ SAFE_FREE(server_realm);
+
+ if (!princ) {
+ return ADS_ERROR(LDAP_NO_MEMORY);
+ }
+ }
+
+ if (!princ) {
+ return ADS_ERROR(LDAP_PARAM_ERROR);
+ }
+
+ *returned_principal = princ;
+
+ return ADS_SUCCESS;
+}
+
static ADS_STATUS ads_generate_service_principal(ADS_STRUCT *ads,
const char *given_principal,
struct ads_service_principal *p)
diff --git a/source3/libads/util.c b/source3/libads/util.c
index 44b4c78038..6a6b42afc4 100644
--- a/source3/libads/util.c
+++ b/source3/libads/util.c
@@ -53,73 +53,4 @@ failed:
SAFE_FREE(password);
return ret;
}
-
-ADS_STATUS ads_guess_service_principal(ADS_STRUCT *ads,
- char **returned_principal)
-{
- char *princ = NULL;
-
- if (ads->server.realm && ads->server.ldap_server) {
- char *server, *server_realm;
-
- server = SMB_STRDUP(ads->server.ldap_server);
- server_realm = SMB_STRDUP(ads->server.realm);
-
- if (!server || !server_realm) {
- SAFE_FREE(server);
- SAFE_FREE(server_realm);
- return ADS_ERROR(LDAP_NO_MEMORY);
- }
-
- strlower_m(server);
- strupper_m(server_realm);
- if (asprintf(&princ, "ldap/%s@%s", server, server_realm) == -1) {
- SAFE_FREE(server);
- SAFE_FREE(server_realm);
- return ADS_ERROR(LDAP_NO_MEMORY);
- }
-
- SAFE_FREE(server);
- SAFE_FREE(server_realm);
-
- if (!princ) {
- return ADS_ERROR(LDAP_NO_MEMORY);
- }
- } else if (ads->config.realm && ads->config.ldap_server_name) {
- char *server, *server_realm;
-
- server = SMB_STRDUP(ads->config.ldap_server_name);
- server_realm = SMB_STRDUP(ads->config.realm);
-
- if (!server || !server_realm) {
- SAFE_FREE(server);
- SAFE_FREE(server_realm);
- return ADS_ERROR(LDAP_NO_MEMORY);
- }
-
- strlower_m(server);
- strupper_m(server_realm);
- if (asprintf(&princ, "ldap/%s@%s", server, server_realm) == -1) {
- SAFE_FREE(server);
- SAFE_FREE(server_realm);
- return ADS_ERROR(LDAP_NO_MEMORY);
- }
-
- SAFE_FREE(server);
- SAFE_FREE(server_realm);
-
- if (!princ) {
- return ADS_ERROR(LDAP_NO_MEMORY);
- }
- }
-
- if (!princ) {
- return ADS_ERROR(LDAP_PARAM_ERROR);
- }
-
- *returned_principal = princ;
-
- return ADS_SUCCESS;
-}
-
#endif