-include Makefile.inc
-VPATH=${top_srcdir}/src:${top_srcdir}/examples:${top_srcdir}/test:${top_srcdir}/project:${jpproject}
+VPATH=${top_srcdir}/src:${top_srcdir}/examples:${top_srcdir}/test:${top_srcdir}/project:${jpproject}:${stagedir}/interface
GLOBUS_LIBS:=-L${globus_prefix}/lib \
-lglobus_common_${nothrflavour} \
-lglobus_gssapi_gsi_${nothrflavour}
+GLOBUS_CFLAGS:=-I${globus_prefix}/include/${nothrflavour}
+
DEBUG:=-g -O0 -DDEBUG
-CFLAGS:=${DEBUG} -I. -I${gsoap_prefix}/include -I${stagedir}/include
+CFLAGS:=${DEBUG} -I. -I${top_srcdir}/interface -I${top_srcdir}/src -I${gsoap_prefix}/include -I${stagedir}/include ${GLOBUS_CFLAGS} -I${mysql_prefix}/include -I${mysql_prefix}/include/mysql
LDFLAGS:=-L${stagedir}/lib
LINK:=libtool --mode=link ${CC} ${LDFLAGS}
daemon:=glite-jp-indexd
-example:=jpis-test
soap_prefix:=jpis_
-SRCS:= simple_server.c soap_ops.c \
+SRCS:= conf.c bones_server.c soap_ops.c \
${soap_prefix}C.c \
- ${soap_prefix}Server.c
+ ${soap_prefix}ServerLib.c \
+ ${soap_prefix}ClientLib.c
-EXA_SRCS:=jpis-test.c ${soap_prefix}C.c ${soap_prefix}Client.c
+OBJS:=${SRCS:.c=.o}
-OBJS:=${SRCS:.c=.o} stdsoap2.o
-EXA_OBJS:=${EXA_SRCS:.c=.o} stdsoap2.o
COMMONLIB:=-lglite_jp_common
+BONESLIB:=-lglite_lb_server_bones
+GSOAPLIB:=-lglite_security_gsoap_plugin_${nothrflavour} -lglite_security_gss_${nothrflavour} \
+ -L${gsoap_prefix}/lib -lgsoap${GSOAP_DEBUG} -L${ares_prefix}/lib -lares
+TRIOLIB:=-lglite_lb_trio
+
+ifneq (${mysql_prefix},/usr)
+ ifeq ($(shell echo ${mysql_version} | cut -d. -f1,2),4.1)
+ MYSQLIB := -L${mysql_prefix}/lib/mysql -lmysqlclient
+ else
+ MYSQLIB := -L${mysql_prefix}/lib -lmysqlclient
+ endif
+else
+ MYSQLIB := -lmysqlclient
+endif
+
default all: compile
-compile: ${daemon} ${example}
+compile: ${daemon}
${daemon}: ${OBJS}
- ${LINK} -o $@ ${OBJS} ${COMMONLIB} ${GLOBUS_LIBS}
+ ${LINK} -o $@ -export-dynamic ${OBJS} ${BONESLIB} ${TRIOLIB} ${COMMONLIB} ${GSOAPLIB} ${GLOBUS_LIBS} ${MYSQLIB}
-${example}: ${EXA_OBJS}
- ${LINK} -o $@ ${EXA_OBJS}
JobProvenanceIS.xh: JobProvenanceIS.wsdl JobProvenanceTypes.wsdl typemap.dat
- cp ${jpproject}/JobProvenanceTypes.wsdl .
+ cp ${stagedir}/interface/JobProvenanceTypes.wsdl .
${gsoap_prefix}/bin/wsdl2h -t ${top_srcdir}/src/typemap.dat -c -o $@ $<
rm -f JobProvenanceTypes.wsdl
+${soap_prefix}ClientLib.c ${soap_prefix}Client.c \
+${soap_prefix}Server.c ${soap_prefix}ServerLib.c \
${soap_prefix}C.c ${soap_prefix}H.h: JobProvenanceIS.xh
- ${gsoap_prefix}/bin/soapcpp2 -w -c -p ${soap_prefix} JobProvenanceIS.xh
-
-#$(SOAP_PREFIX)H.h $(SOAP_PREFIX)C.c: LB.xh
-# $(GSOAP_BIN_PATH)/soapcpp2 -w -c -p $(SOAP_PREFIX) LB.xh
-#
-#LB.xh: LB.wsdl typemap.dat
-# $(GSOAP_BIN_PATH)/wsdl2h -c -o $@ LB.wsdl
-#
+ ${gsoap_prefix}/bin/soapcpp2 -n -w -c -p ${soap_prefix} JobProvenanceIS.xh
+#env_C.c env_Server.c:
+# touch env.xh
+# cp ${stagedir}/interface/JobProvenanceTypes.wsdl .
+# ${gsoap_prefix}/bin/wsdl2h -t ${top_srcdir}/src/typemap.dat -c -o env.xh JobProvenanceTypes.wsdl
+# rm -f JobProvenanceTypes.wsdl
+# ${gsoap_prefix}/bin/soapcpp2 -w -c -p env_ env.xh
check:
-echo nothing yet
$(MAKE) install PREFIX=`pwd`/tmpbuilddir${stagedir}
save_dir=`pwd`; cd tmpbuilddir${stagedir} && tar -czf $$save_dir/${top_srcdir}/${distdir}/${package}-${version}_bin.tar.gz *; cd $$save_dir
rm -rf tmpbuilddir
-
+
install:
-mkdir -p ${PREFIX}/bin ${PREFIX}/etc ${PREFIX}/etc/init.d
for p in bkserverd bkindex; do \
clean:
-soap_ops.o jpis-test.o simple_server.o: ${soap_prefix}H.h
+soap_ops.o bones_server.o simple_server.o: ${soap_prefix}H.h
# we have no real config.h but have to force gSoap not to use
# linux ftime with broken (aka obsolete) DST information
@echo 'The following warning "time_t (de)serialization is not MT safe on this platform" is harmless'
${CC} -o $@ -c -DHAVE_CONFIG_H ${CFLAGS} ${gsoap_prefix}/devel/stdsoap2.c
+soap_ops.o bones_server.o: soap_version.h
+
+soap_version.h:
+ ${gsoap_prefix}/bin/soapcpp2 /dev/null
+ perl -ne '$$. == 2 && /.*([0-9])\.([0-9])\.([0-9]).*/ && printf "#define GSOAP_VERSION %d%02d%02d\n",$$1,$$2,$$3' soapH.h >$@
+ -rm soapC.cpp soapH.h soapStub.h soapClient.cpp soapServer.cpp soapClientLib.cpp soapServerLib.cpp
+
--- /dev/null
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+#include "glite/jp/types.h"
+#include "glite/jp/context.h"
+
+#include "glite/lb/srvbones.h"
+#include "glite/security/glite_gss.h"
+
+#include <stdsoap2.h>
+#include "glite/security/glite_gsplugin.h"
+
+#include "conf.h"
+
+#include "soap_version.h"
+#include "jpis_H.h"
+
+#define CONN_QUEUE 20
+
+extern SOAP_NMAC struct Namespace jpis__namespaces[],jpps__namespaces[];
+extern SOAP_NMAC struct Namespace namespaces[] = { {NULL,NULL} };
+// namespaces[] not used here, but need to prevent linker to complain...
+
+static int newconn(int,struct timeval *,void *);
+static int request(int,struct timeval *,void *);
+static int reject(int);
+static int disconn(int,struct timeval *,void *);
+static int data_init(void **data);
+
+static struct glite_srvbones_service stab = {
+ "JP Index Server", -1, newconn, request, reject, disconn
+};
+
+static time_t cert_mtime;
+static char *server_cert, *server_key, *cadir;
+static gss_cred_id_t mycred = GSS_C_NO_CREDENTIAL;
+static char *mysubj;
+
+static char *port = "8902";
+static int debug = 1;
+
+static glite_jp_context_t ctx;
+
+//static int call_opts(glite_jp_context_t,char *,char *,int (*)(glite_jp_context_t,int,char **));
+
+char *glite_jp_default_namespace;
+
+
+
+int main(int argc, char *argv[])
+{
+ int one = 1,opt,i;
+ edg_wll_GssStatus gss_code;
+ struct sockaddr_in a;
+ glite_jp_is_conf conf;
+ char *config_file;
+
+
+ glite_jp_init_context(&ctx);
+
+ /* Read config options/file */
+ config_file = NULL;
+ glite_jp_get_conf(argc, argv, config_file, &conf);
+
+
+#if GSOAP_VERSION <= 20602
+ for (i=0; jpis__namespaces[i].id && strcmp(jpis__namespaces[i].id,"ns1"); i++);
+#else
+ for (i=0; jpis__namespaces[i].id && strcmp(jpis__namespaces[i].id,"jpsrv"); i++);
+#endif
+ assert(jpis__namespaces[i].id);
+ glite_jp_default_namespace = jpis__namespaces[i].ns;
+
+ stab.conn = socket(PF_INET, SOCK_STREAM, 0);
+ if (stab.conn < 0) {
+ perror("socket");
+ return 1;
+ }
+
+ setsockopt(stab.conn,SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
+
+ a.sin_family = AF_INET;
+ a.sin_addr.s_addr = INADDR_ANY;
+ a.sin_port = htons(atoi(port));
+ if (bind(stab.conn,(struct sockaddr *) &a, sizeof(a)) ) {
+ char buf[200];
+
+ snprintf(buf,sizeof(buf),"bind(%d)",atoi(port));
+ perror(buf);
+ return 1;
+ }
+
+ if (listen(stab.conn,CONN_QUEUE)) {
+ perror("listen()");
+ return 1;
+ }
+
+ if (!server_cert || !server_key)
+ fprintf(stderr, "%s: WARNING: key or certificate file not specified, "
+ "can't watch them for changes\n",
+ argv[0]);
+
+ if ( cadir ) setenv("X509_CERT_DIR", cadir, 1);
+ edg_wll_gss_watch_creds(server_cert, &cert_mtime);
+
+ if ( !edg_wll_gss_acquire_cred_gsi(server_cert, server_key, &mycred, &mysubj, &gss_code))
+ fprintf(stderr,"Server idenity: %s\n",mysubj);
+ else fputs("WARNING: Running unauthenticated\n",stderr);
+
+ /* XXX: daemonise */
+
+ glite_srvbones_set_param(GLITE_SBPARAM_SLAVES_COUNT,1);
+ glite_srvbones_run(data_init,&stab,1 /* XXX: entries in stab */,debug);
+
+ return 0;
+}
+
+static int data_init(void **data)
+{
+ *data = (void *) soap_new();
+
+ printf("[%d] slave started\n",getpid());
+
+ /* slave's init comes here */
+
+ return 0;
+}
+
+static int newconn(int conn,struct timeval *to,void *data)
+{
+ struct soap *soap = (struct soap *) data;
+ glite_gsplugin_Context plugin_ctx;
+
+ gss_cred_id_t newcred = GSS_C_NO_CREDENTIAL;
+ edg_wll_GssStatus gss_code;
+ gss_name_t client_name = GSS_C_NO_NAME;
+ gss_buffer_desc token = GSS_C_EMPTY_BUFFER;
+ OM_uint32 maj_stat,min_stat;
+ int ret = 0;
+
+
+ soap_init2(soap,SOAP_IO_KEEPALIVE,SOAP_IO_KEEPALIVE);
+ soap_set_namespaces(soap,jpis__namespaces);
+ soap->user = (void *) ctx; /* XXX: one instance per slave */
+
+/* not yet: client to JP Storage Server
+ * probably wil come to other place, just not forget it....
+ ctx->other_soap = soap_new();
+ soap_init(ctx->other_soap);
+ soap_set_namespaces(ctx->other_soap,jpps__namespaces);
+*/
+
+
+ glite_gsplugin_init_context(&plugin_ctx);
+ plugin_ctx->connection = calloc(1,sizeof *plugin_ctx->connection);
+ soap_register_plugin_arg(soap,glite_gsplugin,plugin_ctx);
+
+/* now we probably no not play AAA game, but useful in future */
+ switch (edg_wll_gss_watch_creds(server_cert,&cert_mtime)) {
+ case 0: break;
+ case 1: if (!edg_wll_gss_acquire_cred_gsi(server_cert,server_key,
+ &newcred,NULL,&gss_code))
+ {
+
+ printf("[%d] reloading credentials\n",getpid()); /* XXX: log */
+ gss_release_cred(&min_stat,&mycred);
+ mycred = newcred;
+ }
+ break;
+ case -1:
+ printf("[%d] edg_wll_gss_watch_creds failed\n", getpid()); /* XXX: log */
+ break;
+ }
+
+ /* TODO: DNS paranoia etc. */
+
+ if (edg_wll_gss_accept(mycred,conn,to,plugin_ctx->connection,&gss_code)) {
+ printf("[%d] GSS connection accept failed, closing.\n", getpid());
+ ret = 1;
+ goto cleanup;
+ }
+
+ maj_stat = gss_inquire_context(&min_stat,plugin_ctx->connection->context,
+ &client_name, NULL, NULL, NULL, NULL, NULL, NULL);
+
+ if (!GSS_ERROR(maj_stat))
+ maj_stat = gss_display_name(&min_stat,client_name,&token,NULL);
+
+ if (ctx->peer) free(ctx->peer);
+ if (!GSS_ERROR(maj_stat)) {
+ printf("[%d] client DN: %s\n",getpid(),(char *) token.value); /* XXX: log */
+
+ ctx->peer = strdup(token.value);
+ memset(&token, 0, sizeof(token));
+ }
+ else {
+ printf("[%d] annonymous client\n",getpid());
+ ctx->peer = NULL;
+ }
+
+ if (client_name != GSS_C_NO_NAME) gss_release_name(&min_stat, &client_name);
+ if (token.value) gss_release_buffer(&min_stat, &token);
+
+ return 0;
+
+cleanup:
+ glite_gsplugin_free_context(plugin_ctx);
+ soap_end(soap);
+
+ return ret;
+}
+
+static int request(int conn,struct timeval *to,void *data)
+{
+ struct soap *soap = data;
+ glite_jp_context_t ctx = soap->user;
+
+ glite_gsplugin_set_timeout(glite_gsplugin_get_context(soap),to);
+
+ soap->max_keep_alive = 1; /* XXX: prevent gsoap to close connection */
+ soap_begin(soap);
+ if (soap_begin_recv(soap)) {
+ if (soap->error < SOAP_STOP) {
+ soap_send_fault(soap);
+ return EIO;
+ }
+ return ENOTCONN;
+ }
+
+ soap->keep_alive = 1;
+ if (soap_envelope_begin_in(soap)
+ || soap_recv_header(soap)
+ || soap_body_begin_in(soap)
+ || jpis__serve_request(soap)
+#if GSOAP_VERSION >= 20700
+ || (soap->fserveloop && soap->fserveloop(soap))
+#endif
+ )
+ {
+ soap_send_fault(soap);
+ if (ctx->error) {
+ /* XXX: shall we die on some errors? */
+ int err = ctx->error->code;
+ glite_jp_clear_error(ctx);
+ return err;
+ }
+ return 0;
+ }
+
+ glite_jp_run_deferred(ctx);
+ return 0;
+}
+
+static int reject(int conn)
+{
+ int flags = fcntl(conn, F_GETFL, 0);
+
+ fcntl(conn,F_SETFL,flags | O_NONBLOCK);
+ edg_wll_gss_reject(conn);
+
+ return 0;
+}
+
+static int disconn(int conn,struct timeval *to,void *data)
+{
+ struct soap *soap = (struct soap *) data;
+ soap_end(soap); // clean up everything and close socket
+
+ return 0;
+}
#include "glite/jp/context.h"
#include "jpis_H.h"
-#include "JobProvenanceIS.nsmap"
+#include "jpis_.nsmap"
+#include "soap_version.h"
-static struct jptype__GenericJPFaultType *jp2s_error(struct soap *soap,
+
+static struct jptype__genericFault *jp2s_error(struct soap *soap,
const glite_jp_error_t *err)
{
- struct jptype__GenericJPFaultType *ret = NULL;
+ struct jptype__genericFault *ret = NULL;
if (err) {
ret = soap_malloc(soap,sizeof *ret);
memset(ret,0,sizeof *ret);
{
char *et;
struct SOAP_ENV__Detail *detail = soap_malloc(soap,sizeof *detail);
- struct _GenericJPFault *f = soap_malloc(soap,sizeof *f);
+ struct _genericFault *f = soap_malloc(soap,sizeof *f);
- f->jptype__GenericJPFault = jp2s_error(soap,ctx->error);
+ f->jpelem__genericFault = jp2s_error(soap,ctx->error);
- detail->__type = SOAP_TYPE__GenericJPFault;
+ detail->__type = SOAP_TYPE__genericFault;
+#if GSOAP_VERSION >= 20700
+ detail->fault = f;
+#else
detail->value = f;
+#endif
detail->__any = NULL;
soap_receiver_fault(soap,"Oh, shit!",NULL);
else soap->fault->detail = detail;
}
+/*
static void s2jp_tag(const struct jptype__TagValue *stag,glite_jp_tagval_t *jptag)
{
memset(jptag,0,sizeof *jptag);
jptag->value = (char *) stag->blobValue->__ptr;
}
}
+*/
#define CONTEXT_FROM_SOAP(soap,ctx) glite_jp_context_t ctx = (glite_jp_context_t) ((soap)->user)
-SOAP_FMAC5 int SOAP_FMAC6 jpsrv__UpdateJobs(
+SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__UpdateJobs(
struct soap *soap,
- char *feed_id,
- struct jptype__UpdateJobsData *jobs,
- enum xsd__boolean done
-)
+ struct _jpelem__UpdateJobs *jpelem__UpdateJobs,
+ struct _jpelem__UpdateJobsResponse *jpelem__UpdateJobsResponse)
{
- printf("%s items %d jobid %s\n",__FUNCTION__,jobs->__sizejob,
- jobs->job[0]->jobid);
+ puts(__FUNCTION__);
return SOAP_OK;
}
-SOAP_FMAC5 int SOAP_FMAC6 jpsrv__QueryJobs(
+
+SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__QueryJobs(
struct soap *soap,
- struct jptype__IndexQuery *query,
- struct jpsrv__QueryJobsResponse *resp
-)
+ struct _jpelem__QueryJobs *jpelem__QueryJobs,
+ struct _jpelem__QueryJobsResponse *jpelem__QueryJobsResponse)
{
puts(__FUNCTION__);
return SOAP_OK;