Univention Bugzilla – Attachment 5963 Details for
Bug 35157
Add fallback to machine account in univention_license_ldap_init() - univention-licence
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
univention_ldap_set_machine_connection_fallback.patch
univention_ldap_set_machine_connection_fallback.patch (text/plain), 1.83 KB, created by
Felix Botner
on 2014-06-18 12:26:00 CEST
(
hide
)
Description:
univention_ldap_set_machine_connection_fallback.patch
Filename:
MIME Type:
Creator:
Felix Botner
Created:
2014-06-18 12:26:00 CEST
Size:
1.83 KB
patch
obsolete
>Index: lib/license_ldap.c >=================================================================== >--- lib/license_ldap.c (Revision 51172) >+++ lib/license_ldap.c (Arbeitskopie) >@@ -8,7 +8,58 @@ > > univention_ldap_parameters_t* lp = NULL; > >+#define _UNIVENTION_LDAP_MACHINE_SECRET_LEN_MAX 60 >+int univention_ldap_set_machine_connection( univention_ldap_parameters_t *lp ) >+{ >+ FILE *secret; >+ size_t len; > >+ asprintf(&lp->binddn, univention_config_get_string("ldap/hostdn")); >+ if (!lp->binddn) { >+ goto err; >+ } >+ >+ secret = fopen("/etc/machine.secret", "r" ); >+ if (!secret) >+ goto err1; >+ >+ lp->bindpw = calloc(_UNIVENTION_LDAP_MACHINE_SECRET_LEN_MAX, sizeof(char)); >+ if (!lp->bindpw) { >+ fclose(secret); >+ goto err1; >+ } >+ >+ len = fread(lp->bindpw, _UNIVENTION_LDAP_MACHINE_SECRET_LEN_MAX, sizeof(char), secret); >+ if (ferror(secret)) >+ len = -1; >+ fclose(secret); >+ >+ for (; len >= 0; len--) { >+ switch (lp->bindpw[len]) { >+ case '\r': >+ case '\n': >+ lp->bindpw[len] = '\0'; >+ case '\0': >+ continue; >+ default: >+ return 0; >+ } >+ } >+ >+ /* password already cleared memory. */ >+ if (lp->bindpw != NULL) { >+ free(lp->bindpw); >+ lp->bindpw = NULL; >+ } >+err1: >+ if (lp->binddn != NULL) { >+ free(lp->binddn); >+ lp->binddn = NULL; >+ } >+err: >+ return 1; >+} >+ > /******************************************************************************/ > /*! > @brief initialitze the ldap part of the lib, automatic called if need >@@ -20,7 +71,10 @@ > int univention_license_ldap_init(void) > { > lp = univention_ldap_new(); >- univention_ldap_set_admin_connection(lp); >+ if (univention_ldap_set_admin_connection(lp)) { >+ univention_debug(UV_DEBUG_LDAP, UV_DEBUG_INFO, "univention_ldap_set_admin_connection() failed, trying univention_ldap_set_machine_connection()."); >+ univention_ldap_set_machine_connection(lp); >+ } > univention_ldap_open(lp); > > return 1;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 35157
: 5963