summaryrefslogtreecommitdiffstats
path: root/src/plugin.c
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin@localhost.localdomain>2008-04-01 22:22:01 -0400
committerNalin Dahyabhai <nalin@localhost.localdomain>2008-04-01 22:22:01 -0400
commit81b0da5fcc1e086c74076df86a8dbd28cf16a625 (patch)
tree1a6007fc33dd08a1530de6d7dd1180d387731796 /src/plugin.c
parent179d675259f4f8a04d19db49831f27099bcabc23 (diff)
downloadslapi-nis-81b0da5fcc1e086c74076df86a8dbd28cf16a625.tar.gz
slapi-nis-81b0da5fcc1e086c74076df86a8dbd28cf16a625.tar.xz
slapi-nis-81b0da5fcc1e086c74076df86a8dbd28cf16a625.zip
- finish getting the basic NIS server going again
Diffstat (limited to 'src/plugin.c')
-rw-r--r--src/plugin.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/plugin.c b/src/plugin.c
index ae57e5c..6315b68 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -48,7 +48,8 @@ plugin_startup(Slapi_PBlock *pb)
const char *pname;
int i, protocol;
slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &state);
- slapi_log_error(SLAPI_LOG_PLUGIN, "plugin_start", "plugin starting\n");
+ slapi_log_error(SLAPI_LOG_PLUGIN, plugin_description.spd_id,
+ "plugin starting\n");
/* Register the listener sockets with the portmapper. */
if (state->pmap_client_socket != -1) {
for (i = 0; i < state->n_listeners; i++) {
@@ -69,7 +70,8 @@ plugin_startup(Slapi_PBlock *pb)
if (protocol == IPPROTO_IP) {
continue;
}
- if (!portmap_register(state->pmap_client_socket,
+ if (!portmap_register(plugin_description.spd_id,
+ state->pmap_client_socket,
YPPROG, YPVERS, protocol,
state->listener[i].port)) {
slapi_log_error(SLAPI_LOG_PLUGIN,
@@ -100,7 +102,8 @@ plugin_shutdown(Slapi_PBlock *pb)
slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &state);
if (state->pmap_client_socket != -1) {
/* Clear our registration with the portmapper. */
- portmap_unregister(state->pmap_client_socket, YPPROG, YPVERS);
+ portmap_unregister(plugin_description.spd_id,
+ state->pmap_client_socket, YPPROG, YPVERS);
}
return 0;
}
@@ -126,6 +129,19 @@ plugin_state_init(struct plugin_state **lstate)
}
state->arena = arena;
+ /* Create a socket for use in communicating with the portmapper. */
+ sockfd = socket(PF_INET, SOCK_DGRAM, 0);
+ if (sockfd == -1) {
+ goto failed;
+ }
+ memset(&sin, 0, sizeof(sin));
+ sin.sin_family = AF_INET;
+ if (bindresvport(sockfd, &sin) != 0) {
+ close(sockfd);
+ goto failed;
+ }
+ state->pmap_client_socket = sockfd;
+
/* We need to bind on privileged ports for both datagram and connected
* listeners, over both IPv4 and IPv6. */
state->n_listeners = 0;
@@ -158,11 +174,12 @@ plugin_state_init(struct plugin_state **lstate)
continue;
}
/* Mark the socket as reusable. */
+ one = 1;
if (setsockopt(sockfd, IPPROTO_IP, SO_REUSEADDR,
&one, sizeof(one)) != 0) {
slapi_log_error(SLAPI_LOG_PLUGIN,
plugin_description.spd_id,
- "error marking %s socket for reuse, ",
+ "error marking %s socket for reuse, "
"continuing\n", sock_desc);
}
/* Bind to a reserved port. */
@@ -197,11 +214,6 @@ plugin_state_init(struct plugin_state **lstate)
continue;
}
}
- /* Save the first socket for reuse as the portmap client
- * socket. */
- if (i == 0) {
- state->pmap_client_socket = sockfd;
- }
/* Save the other info. */
state->listener[state->n_listeners].fd = sockfd;
state->listener[state->n_listeners].port = port;