initial import of the rpclist API;

v0.5.xx
Alexander Vdolainen 10 years ago
parent a6bf3006e7
commit f32b2ed49b

@ -137,7 +137,8 @@ typedef struct __connection_rpc_list_type {
} cx_rpc_list_t;
typedef struct __connections_subsys_type {
int ex_ssldata_index; /** < index used to work with additional data provided to the special call during SSL handshake */
int ex_ssldata_index; /** < index used to work with additional data
* provided to the special call during SSL handshake */
usrtc_t *connections;
pth_queue_t *ioq; /** < general messages queue */
pth_queue_t *ioqueue; /** < system messages queue */
@ -149,9 +150,11 @@ typedef struct __connections_subsys_type {
cx_rpc_list_t *system_rpc;
/* special functions pointers */
int (*validate_sslpem)(conn_t *); /** < this function used to validate SSL certificate while SSL handshake */
int (*secure_check)(conn_t *); /** < this function authorize user to login, and also should check SSL cert and user, and already made sessions */
int (*secure_check)(conn_t *); /** < this function authorize user to login,
* and also should check SSL cert and user, and already made sessions */
usrtc_t* (*get_rpc_typed_list_tree)(conn_t *); /** < this function is used to set RPC list of the functions */
int (*set_typed_list_callback)(conn_t *, int, char *); /** < this function is a callback during setting up a typed channel */
int (*set_typed_list_callback)(conn_t *, int, char *); /** < this function is a callback
* during setting up a typed channel */
void *priv;
} conn_sys_t;

@ -14,7 +14,7 @@ lib_LTLIBRARIES = libsntl.la
libsntl_la_SOURCES = \
queue.c connection.c
queue.c rpclist.c connection.c
libsntl_la_LDFLAGS =

@ -1,5 +1,5 @@
/*
* zMaster daemon: a server for a zOffice verification.
* Secure Network Transport Layer Library implementation.
* This is a proprietary software. See COPYING for further details.
*
* (c) 2013-2014 Copyright Askele, inc. <http://askele.com>
@ -172,14 +172,14 @@ static void __destroy_rpc_list_tree(usrtc_t *tree)
{
usrtc_node_t *node;
cx_rpc_t *ent;
for(node = usrtc_first(tree); node != NULL; node = usrtc_first(tree)) {
ent = (cx_rpc_t *)usrtc_node_getdata(node);
usrtc_delete(tree, node);
free(ent->name);
free(ent);
}
return;
}
@ -187,18 +187,18 @@ static int __insert_rpc_function(usrtc_t *tree, const char *name, int (*rpcf)(vo
{
cx_rpc_t *ent = malloc(sizeof(cx_rpc_t));
usrtc_node_t *node;
if(!ent) return ENOMEM;
else node = &ent->node;
if(!(ent->name = strdup(name))) {
free(ent);
return ENOMEM;
} else ent->rpcf = rpcf;
usrtc_node_init(node, ent);
usrtc_insert(tree, node, ent->name);
return 0;
}
@ -210,7 +210,7 @@ static int __default_auth_set_context(void *cctx, sexp_t *sx)
int llen, idx, err;
//co->pctx = malloc(sizeof(perm_ctx_t));
/* skip keyword itself */
lsx = sx->list->next;
/* now we expect a list of lists */
@ -228,14 +228,14 @@ static int __default_auth_set_context(void *cctx, sexp_t *sx)
if(!SEXP_IS_TYPE(sx_in, SEXP_BASIC)) {
return EINVAL; /* TODO: return correct error code, clean up*/
} else val = sx_in->val;
if(sexp_list_length(sx_iter) < 2) continue; /* we will ignore it */
sexp_list_cdr(sx_iter, &sx_in);
if(!SEXP_IS_TYPE(sx_in, SEXP_DQUOTE)) {
return EINVAL; /* TODO: return correct error code, clean up*/
} else var = sx_in->val;
/* ok, now we need to analyze parameters */
if(!strcmp(val, ":user")) {
co->pctx->login = strdup(var); /* FIXME: check */
@ -246,7 +246,7 @@ static int __default_auth_set_context(void *cctx, sexp_t *sx)
}
} else continue; /* ignore */
}
/* ok, now we need to fill security context */
tbuf = malloc(2048);
if(conn_sys->secure_check)
@ -260,12 +260,12 @@ static int __default_auth_set_context(void *cctx, sexp_t *sx)
if(err) {
snprintf(tbuf, 2048, "(auth-set-error (%d))", err);
} else {
snprintf(tbuf, 2048, "(auth-set-attr (:attr %d)(:uid %ld)(:gid %ld))",
snprintf(tbuf, 2048, "(auth-set-attr (:attr %d)(:uid %ld)(:gid %ld))",
co->pctx->p_attr, co->pctx->uid, co->pctx->gid);
}
/* we will send it */
SSL_write(co->ssl, tbuf, strlen(tbuf)+1); /* FIXME: check it */
free(tbuf);
return err;
}
@ -276,12 +276,12 @@ static int __default_auth_set_attr(void *cctx, sexp_t *sx)
char *val, *var;
sexp_t *lsx, *sx_iter, *sx_in;
int llen, idx;
/* skip keyword itself */
lsx = sx->list->next;
/* now we expect a list of lists */
if(lsx->ty != SEXP_LIST) {
printf("%s:%d\n", __FUNCTION__, __LINE__);
// printf("%s:%d\n", __FUNCTION__, __LINE__);
return EINVAL;
}
/* take length of the list */
@ -294,15 +294,15 @@ static int __default_auth_set_attr(void *cctx, sexp_t *sx)
if(!SEXP_IS_TYPE(sx_in, SEXP_BASIC)) {
return EINVAL; /* TODO: return correct error code, clean up*/
} else val = sx_in->val;
if(sexp_list_length(sx_iter) < 2) continue; /* we will ignore it */
sexp_list_cdr(sx_iter, &sx_in);
if(!SEXP_IS_TYPE(sx_in, SEXP_BASIC)) {
return EINVAL; /* TODO: return correct error code, clean up*/
} else var = sx_in->val;
/* ok, now we need to analyze parameters */
if(!strcmp(val, ":attr")) {
co->pctx->p_attr = atoi(var);
@ -315,7 +315,7 @@ static int __default_auth_set_attr(void *cctx, sexp_t *sx)
}
} else continue; /* ignore */
}
return 0;
}
@ -323,7 +323,7 @@ static int __default_auth_set_error(void *cctx, sexp_t *sx)
{
char *errstr = NULL;
int r;
/* skip keyword itself */
sx->list = sx->list->next;
/* be sure - this is a list */
@ -331,7 +331,7 @@ static int __default_auth_set_error(void *cctx, sexp_t *sx)
else sx = sx->list; /* get it */
errstr = sx->list->val;
r = atoi(errstr);
return r;
}
@ -342,7 +342,7 @@ static int __default_ch_get_types(void *cctx, sexp_t *sx)
rpc_typed_list_t *list_ent;
char *tbuf = malloc(4096), *tt;
int err = 0;
/* if we cannot allocate anything ... */
if(!tbuf) return ENOMEM;
/* ok here we go */
@ -362,23 +362,22 @@ static int __default_ch_get_types(void *cctx, sexp_t *sx)
}
snprintf(tt, 4096, "))");
}
/* reply to this rpc */
SSL_write(co->ssl, tbuf, strlen(tbuf)+sizeof(char)); /* FIXME: do checks */
free(tbuf);
return err;
}
static int __default_ch_set_types(void *cctx, sexp_t *sx)
{
conn_t *co = (conn_t *)cctx;
printf("setting types\n");
char buf[1024], *val, *var;
int r = 0, llen, typeid, idx;
sexp_t *lsx, *sx_iter, *sx_in;
/* skip keyword itself */
lsx = sx->list->next;
/* now we expect a list of lists */

@ -0,0 +1,44 @@
/*
* Secure Network Transport Layer Library implementation.
* This is a proprietary software. See COPYING for further details.
*
* (c) 2013-2014 Copyright Askele, inc. <http://askele.com>
* (c) 2013-2014 Copyright Askele Ingria, inc. <http://askele-ingria.com>
*/
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <pthread.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/select.h>
#include <unistd.h>
#include <fcntl.h>
#include <netdb.h>
#include <uuid/uuid.h>
#include <openssl/ssl.h>
#include <tdata/usrtc.h>
#include <sexpr/sexp.h>
#include <sntl/connection.h>
static long __cmp_int(const void *a, const void *b)
{
return *(int *)a - *(int *)b;
}
int sntl_rpclist_init(usrtc_t *tree)
{
usrtc_init(tree, USRTC_REDBLACK, MAX_RPC_LIST, __cmp_int);
return 0;
}
int sntl_rpclist_add(usrtc_t *tree, int type, const char *description)
{
return 0;
}
Loading…
Cancel
Save