1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

s3-libads: make ads_guess_service_principal static.

Guenther
This commit is contained in:
Günther Deschner 2011-02-11 11:14:27 +01:00
parent 16229e4cef
commit f076c76260
3 changed files with 69 additions and 71 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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