[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Patch to provide peer name to shell backends
Hi,
We at http://www.gnomemeeting.org/ have been running an ILS server
for some time which is a perl server run via a shell backend from
openldap (due to the fact that it isn't quite LDAP compliant).
One requirement is that whoever registers an entry
can be the only one that modifies or deletes it, and we base that
on the IP address. Unfortunately, openldap doesn't propogate
the peer address to shell backends so I created a patch to do so.
This currently uses an environment variable but could easily
also use a command line argument if thought preferable. I attach
the current patch (tested against 2.1.12 and 2.1.17). Could
this be considered for inclusion, and if not, what would be
acceptable?
Thanks,
Paul
diff -urN openldap-2.1.12/servers/slapd/back-shell/abandon.c openldap-2.1.12-patched/servers/slapd/back-shell/abandon.c
--- openldap-2.1.12/servers/slapd/back-shell/abandon.c 2002-10-11 00:40:37.000000000 +0100
+++ openldap-2.1.12-patched/servers/slapd/back-shell/abandon.c 2003-04-10 13:25:59.000000000 +0100
@@ -46,6 +46,9 @@
return 0;
}
+ /* Make peer name accessible to handler */
+ if (conn->c_peer_name.bv_val)
+ (void)setenv("LDAP_PEER_NAME", conn->c_peer_name.bv_val, 1);
if ( forkandexec( si->si_abandon, &rfp, &wfp ) == -1 ) {
return 0;
}
diff -urN openldap-2.1.12/servers/slapd/back-shell/add.c openldap-2.1.12-patched/servers/slapd/back-shell/add.c
--- openldap-2.1.12/servers/slapd/back-shell/add.c 2002-10-11 00:40:37.000000000 +0100
+++ openldap-2.1.12-patched/servers/slapd/back-shell/add.c 2003-04-10 13:24:19.000000000 +0100
@@ -42,6 +42,9 @@
return -1;
}
+ /* Make peer name accessible to handler */
+ if (conn->c_peer_name.bv_val)
+ (void)setenv("LDAP_PEER_NAME", conn->c_peer_name.bv_val, 1);
if ( (op->o_private = (void *) forkandexec( si->si_add, &rfp, &wfp )) == (void *) -1 ) {
send_ldap_result( conn, op, LDAP_OTHER, NULL,
"could not fork/exec", NULL, NULL );
diff -urN openldap-2.1.12/servers/slapd/back-shell/bind.c openldap-2.1.12-patched/servers/slapd/back-shell/bind.c
--- openldap-2.1.12/servers/slapd/back-shell/bind.c 2002-10-11 00:40:37.000000000 +0100
+++ openldap-2.1.12-patched/servers/slapd/back-shell/bind.c 2003-04-10 13:23:40.000000000 +0100
@@ -56,6 +56,9 @@
return -1;
}
+ /* Make peer name accessible to handler */
+ if (conn->c_peer_name.bv_val)
+ (void)setenv("LDAP_PEER_NAME", conn->c_peer_name.bv_val, 1);
if ( (op->o_private = (void *) forkandexec( si->si_bind, &rfp, &wfp ))
== (void *) -1 ) {
send_ldap_result( conn, op, LDAP_OTHER, NULL,
diff -urN openldap-2.1.12/servers/slapd/back-shell/compare.c openldap-2.1.12-patched/servers/slapd/back-shell/compare.c
--- openldap-2.1.12/servers/slapd/back-shell/compare.c 2002-10-11 00:40:37.000000000 +0100
+++ openldap-2.1.12-patched/servers/slapd/back-shell/compare.c 2003-04-10 13:25:36.000000000 +0100
@@ -53,6 +53,9 @@
return -1;
}
+ /* Make peer name accessible to handler */
+ if (conn->c_peer_name.bv_val)
+ (void)setenv("LDAP_PEER_NAME", conn->c_peer_name.bv_val, 1);
if ( (op->o_private = (void *) forkandexec( si->si_compare, &rfp, &wfp ))
== (void *) -1 ) {
send_ldap_result( conn, op, LDAP_OTHER, NULL,
diff -urN openldap-2.1.12/servers/slapd/back-shell/delete.c openldap-2.1.12-patched/servers/slapd/back-shell/delete.c
--- openldap-2.1.12/servers/slapd/back-shell/delete.c 2002-10-11 00:40:37.000000000 +0100
+++ openldap-2.1.12-patched/servers/slapd/back-shell/delete.c 2003-04-10 13:24:36.000000000 +0100
@@ -52,6 +52,9 @@
return -1;
}
+ /* Make peer name accessible to handler */
+ if (conn->c_peer_name.bv_val)
+ (void)setenv("LDAP_PEER_NAME", conn->c_peer_name.bv_val, 1);
if ( (op->o_private = (void *) forkandexec( si->si_delete, &rfp, &wfp ))
== (void *) -1 ) {
send_ldap_result( conn, op, LDAP_OTHER, NULL,
diff -urN openldap-2.1.12/servers/slapd/back-shell/modify.c openldap-2.1.12-patched/servers/slapd/back-shell/modify.c
--- openldap-2.1.12/servers/slapd/back-shell/modify.c 2002-10-11 00:40:37.000000000 +0100
+++ openldap-2.1.12-patched/servers/slapd/back-shell/modify.c 2003-04-10 13:24:55.000000000 +0100
@@ -55,6 +55,9 @@
return -1;
}
+ /* Make peer name accessible to handler */
+ if (conn->c_peer_name.bv_val)
+ (void)setenv("LDAP_PEER_NAME", conn->c_peer_name.bv_val, 1);
if ( (op->o_private = (void *) forkandexec( si->si_modify, &rfp, &wfp ))
== (void *) -1 ) {
send_ldap_result( conn, op, LDAP_OTHER, NULL,
diff -urN openldap-2.1.12/servers/slapd/back-shell/modrdn.c openldap-2.1.12-patched/servers/slapd/back-shell/modrdn.c
--- openldap-2.1.12/servers/slapd/back-shell/modrdn.c 2002-10-11 00:40:37.000000000 +0100
+++ openldap-2.1.12-patched/servers/slapd/back-shell/modrdn.c 2003-04-10 13:25:13.000000000 +0100
@@ -70,6 +70,9 @@
return -1;
}
+ /* Make peer name accessible to handler */
+ if (conn->c_peer_name.bv_val)
+ (void)setenv("LDAP_PEER_NAME", conn->c_peer_name.bv_val, 1);
if ( (op->o_private = (void *) forkandexec( si->si_modrdn, &rfp, &wfp ))
== (void *) -1 ) {
send_ldap_result( conn, op, LDAP_OTHER, NULL,
diff -urN openldap-2.1.12/servers/slapd/back-shell/search.c openldap-2.1.12-patched/servers/slapd/back-shell/search.c
--- openldap-2.1.12/servers/slapd/back-shell/search.c 2002-10-11 00:40:37.000000000 +0100
+++ openldap-2.1.12-patched/servers/slapd/back-shell/search.c 2003-04-10 13:22:47.000000000 +0100
@@ -42,6 +42,9 @@
return( -1 );
}
+ /* Make peer name accessible to handler */
+ if ((conn->c_peer_name.bv_val))
+ (void)setenv("LDAP_PEER_NAME", conn->c_peer_name.bv_val, 1);
if ( (op->o_private = (void *) forkandexec( si->si_search, &rfp, &wfp ))
== (void *) -1 ) {
send_ldap_result( conn, op, LDAP_OTHER, NULL,
diff -urN openldap-2.1.12/servers/slapd/back-shell/unbind.c openldap-2.1.12-patched/servers/slapd/back-shell/unbind.c
--- openldap-2.1.12/servers/slapd/back-shell/unbind.c 2002-10-11 00:40:37.000000000 +0100
+++ openldap-2.1.12-patched/servers/slapd/back-shell/unbind.c 2003-04-10 13:24:02.000000000 +0100
@@ -29,6 +29,9 @@
return 0;
}
+ /* Make peer name accessible to handler */
+ if (conn->c_peer_name.bv_val)
+ (void)setenv("LDAP_PEER_NAME", conn->c_peer_name.bv_val, 1);
if ( (op->o_private = (void *) forkandexec( si->si_unbind, &rfp, &wfp ))
== (void *) -1 ) {
return 0;