* c/ldap.c (scsh_ldap_get_set_option): allocate buffer for outvalues
* c/ldap.c (scsh_ldap_simple_bind_s): if user/password is false connect as "nobody"
This commit is contained in:
parent
1ba223f6cc
commit
092160e721
30
c/ldap.c
30
c/ldap.c
|
@ -47,6 +47,7 @@ s48_value scsh_ldap_init(s48_value host, s48_value port)
|
|||
S48_GC_PROTECT_2(host, port);
|
||||
ldap = ldap_init(s48_extract_string(host), s48_extract_integer(port));
|
||||
S48_GC_UNPROTECT();
|
||||
|
||||
if (ldap == NULL)
|
||||
s48_raise_os_error(errno);
|
||||
else
|
||||
|
@ -56,11 +57,13 @@ s48_value scsh_ldap_init(s48_value host, s48_value port)
|
|||
s48_value scsh_ldap_simple_bind_s(s48_value ldap, s48_value user, s48_value cred)
|
||||
{
|
||||
int r;
|
||||
LDAP *l;
|
||||
S48_DECLARE_GC_PROTECT(3);
|
||||
|
||||
S48_GC_PROTECT_3(ldap, user, cred);
|
||||
r = ldap_simple_bind_s(scsh_extract_ldap(ldap), s48_extract_string(user),
|
||||
s48_extract_string(cred));
|
||||
r = ldap_simple_bind_s(scsh_extract_ldap(ldap),
|
||||
S48_FALSE_P(user) ? NULL : s48_extract_string(user),
|
||||
S48_FALSE_P(cred) ? NULL : s48_extract_string(cred));
|
||||
S48_GC_UNPROTECT();
|
||||
return s48_enter_integer(r);
|
||||
}
|
||||
|
@ -521,6 +524,7 @@ s48_value scsh_ldap_abandon(s48_value ldap, s48_value msgid)
|
|||
return s48_enter_integer(r);
|
||||
}
|
||||
|
||||
/* FIXME: Options missing here! */
|
||||
s48_value scsh_ldap_get_set_option(s48_value ldap, s48_value option,
|
||||
s48_value set, s48_value inval)
|
||||
{
|
||||
|
@ -531,9 +535,9 @@ s48_value scsh_ldap_get_set_option(s48_value ldap, s48_value option,
|
|||
S48_DECLARE_GC_PROTECT(6);
|
||||
|
||||
S48_GC_PROTECT_6(ldap, option, set, inval, res, res_list);
|
||||
FFIT_CHECK_RECORD_TYPE(ldap, scsh_ldap_record_type);
|
||||
FFIT_CHECK_BOOLEAN(set);
|
||||
ld = scsh_extract_ldap(ldap);
|
||||
opt = s48_extract_integer(option);
|
||||
|
||||
res = S48_UNSPECIFIC;
|
||||
switch (opt) {
|
||||
|
@ -553,39 +557,41 @@ s48_value scsh_ldap_get_set_option(s48_value ldap, s48_value option,
|
|||
case LDAP_OPT_TIMELIMIT:
|
||||
{
|
||||
int l;
|
||||
int ov;
|
||||
if (S48_TRUE_P(set)) {
|
||||
FFIT_CHECK_INTEGER(inval);
|
||||
l = s48_extract_integer(inval);
|
||||
rc = ldap_set_option(ld, opt, &l);
|
||||
}
|
||||
else
|
||||
if ((rc = ldap_get_option(ld, opt, outvalue)) == LDAP_SUCCESS)
|
||||
res = s48_enter_integer(*((int*)outvalue));
|
||||
if ((rc = ldap_get_option(ld, opt, &ov)) == LDAP_SUCCESS)
|
||||
res = s48_enter_integer(ov);
|
||||
break;
|
||||
}
|
||||
case LDAP_OPT_REFERRALS:
|
||||
case LDAP_OPT_RESTART:
|
||||
{
|
||||
int ov;
|
||||
if (S48_TRUE_P(set)) {
|
||||
FFIT_CHECK_BOOLEAN(inval);
|
||||
rc = ldap_set_option(ld, opt, S48_TRUE_P(inval) ? LDAP_OPT_ON : LDAP_OPT_OFF);
|
||||
}
|
||||
else
|
||||
if ((rc = ldap_get_option(ld, opt, outvalue)) == LDAP_SUCCESS)
|
||||
res = outvalue == 0 ? S48_TRUE : S48_FALSE;
|
||||
if ((rc = ldap_get_option(ld, opt, &ov)) == LDAP_SUCCESS)
|
||||
res = ov == 0 ? S48_TRUE : S48_FALSE;
|
||||
break;
|
||||
}
|
||||
case LDAP_OPT_PROTOCOL_VERSION:
|
||||
{
|
||||
int v;
|
||||
int v, ov;
|
||||
if (S48_TRUE_P(set)) {
|
||||
FFIT_CHECK_INTEGER(inval);
|
||||
v = s48_extract_integer(inval);
|
||||
rc = ldap_set_option(ld, opt, &v);
|
||||
}
|
||||
else
|
||||
if ((rc = ldap_get_option(ld, opt, outvalue)) == LDAP_SUCCESS)
|
||||
res = s48_enter_integer(*(int *)outvalue);
|
||||
if ((rc = ldap_get_option(ld, opt, &ov)) == LDAP_SUCCESS)
|
||||
res = s48_enter_integer(ov);
|
||||
break;
|
||||
}
|
||||
case LDAP_OPT_SERVER_CONTROLS:
|
||||
|
@ -593,6 +599,10 @@ s48_value scsh_ldap_get_set_option(s48_value ldap, s48_value option,
|
|||
{
|
||||
raise_ldap_read_only_option();
|
||||
}
|
||||
default:
|
||||
{
|
||||
printf("Alles ficken!\n");
|
||||
}
|
||||
}
|
||||
|
||||
res_list =
|
||||
|
|
Loading…
Reference in New Issue