Commit 1094e9c9f0ac0894bb241fcc5da0e9d201f51866

Authored by Georg Hopp
1 parent a8cf525e

make sessions start on any request and clean them when they have timed out.

... ... @@ -27,8 +27,11 @@
27 27 #include "class.h"
28 28
29 29 #include "session.h"
30   -#include "hash.h"
  30 +#include "queue.h"
31 31 #include "auth/credential.h"
  32 +#include "storage.h"
  33 +#include "session.h"
  34 +
32 35
33 36 struct randval {
34 37 time_t timestamp;
... ... @@ -36,18 +39,24 @@ struct randval {
36 39 };
37 40
38 41 CLASS(Application) {
39   - Hash active_sessions;
40   - void * auth;
41   - struct randval * val;
  42 + // should be a list and not a queue but currently queue is
  43 + // the closest I have.
  44 + Queue active_sessions;
  45 +
  46 + void ** auth;
  47 + size_t nauth;
  48 + struct randval * val;
  49 +
  50 + Storage users;
42 51 };
43 52
44   -// this should return a user account....now it only return success or failure.
45   -int applicationLogin(Application, Credential);
46   -unsigned long applicationSessionStart(Application, const char *, size_t);
47   -void applicationSessionStop(Application, unsigned long);
48   -void applicationSessionUpdate(
49   - Application, unsigned long, const char *, size_t);
50   -Session applicationSessionGet(Application, unsigned long);
  53 +int applicationLogin(Application, Credential, Session);
  54 +
  55 +Session applicationSessionStart(Application);
  56 +Session applicationSessionGet(Application, const char *);
  57 +void applicationSessionStop(Application, const char *);
  58 +void applicationSessionUpdate(
  59 + Application, const char *, const char *, size_t);
51 60
52 61 #endif // __HTTP_HEADER_H__
53 62
... ...
... ... @@ -36,6 +36,7 @@
36 36
37 37 #include "http/request.h"
38 38 #include "http/response.h"
  39 +#include "queue.h"
39 40 #include "commons.h"
40 41
41 42
... ... @@ -50,6 +51,8 @@ CLASS(HttpWorker) {
50 51 HttpRequest current_request;
51 52 HttpMessage current_response;
52 53
  54 + Queue additional_headers;
  55 +
53 56 HttpParser parser;
54 57 HttpWriter writer;
55 58 };
... ...
... ... @@ -25,17 +25,20 @@
25 25
26 26 #include <time.h>
27 27 #include <sys/types.h>
  28 +#include <user.h>
28 29
29 30 #include "class.h"
30 31
31   -#define SESSION_LIVETIME 30
  32 +// livetime of a session in seconds
  33 +#define SESSION_LIVETIME 300 // 5 minutes
32 34
33 35
34 36 CLASS(Session) {
35   - unsigned long id;
  37 + char id[37];
  38 + unsigned long hash;
36 39 time_t livetime;
37 40
38   - char * username;
  41 + User user;
39 42 };
40 43
41 44 #endif // __SESSION_H__
... ...
... ... @@ -34,7 +34,7 @@ bin_PROGRAMS = taskrambler
34 34
35 35 taskrambler_SOURCES = taskrambler.c $(IFACE) $(UTILS)
36 36 taskrambler_CFLAGS = $(CFLAGS) -Wall -DPWD=\"$(PWD)\" -I ../include/# $(COVERAGE_CFLAGS)
37   -taskrambler_LDADD = $(LIBS) -lrt -lssl -lldap -lgdbm
  37 +taskrambler_LDADD = $(LIBS) -lrt -lssl -lldap -lgdbm -luuid
38 38 #taskrambler_LDFLAGS = $(COVERAGE_LDFLAGS)
39 39
40 40 SUBDIRS = asset auth cbuf class hash queue http \
... ...
... ... @@ -39,26 +39,92 @@
39 39 #include "utils/memory.h"
40 40
41 41
42   -#define NO_SESSION_SID 0
  42 +#define NO_SESSION_SID NULL
  43 +#define SESS_HEADER "{\"id\":\"%s\",\"timeout\":%d,\"timeleft\":%ld}"
43 44
44 45
45 46 static
46 47 inline
47   -unsigned long
  48 +char *
48 49 getSessionId(Hash cookies)
49 50 {
50 51 HashValue sidstr = hashGet(cookies, CSTRA("sid"));
51 52
52 53 if (NULL != sidstr) {
53   - return strtoul((char*)(sidstr->value), NULL, 10);
  54 + return (char*)sidstr->value;
54 55 }
55 56
56 57 return NO_SESSION_SID;
57 58 }
58 59
59 60 static
  61 +Session
  62 +getSession(Queue sess_queue, const char * sid)
  63 +{
  64 + Session sess = NULL;
  65 + time_t now = time(NULL);
  66 +
  67 + /**
  68 + * session start or update
  69 + *
  70 + * @TODO
  71 + * I need to walk through the whole hash at this point to find
  72 + * expired sessions and remove them....this is not good and
  73 + * probably I need another(faster) way to identify expired
  74 + * sessions....
  75 + *
  76 + * @TODO
  77 + * Build a way to cleanup the hash by a filter...currently
  78 + * there is nothing I could use for this.
  79 + * Well this is practically impossible in reasonable time
  80 + * because every time I remove one element the tree has to
  81 + * be rebalanced....
  82 + *
  83 + * I have to store all nodes in a different structure that
  84 + * gives me the possibility to find fast expired objects.
  85 + * These can then be removed from both structures....
  86 + *
  87 + * Anyway this is the pure horror...because I have to compute
  88 + * the condition for every stored session....and I really have to
  89 + * do this...else the tree would grow and grow all the time...
  90 + *
  91 + * I think the best I can do at this point is, at least for the moment,
  92 + * to store the sessions in a list and not in a stack.
  93 + * Each request will than have to walk through that list,
  94 + * remove expired sessions and pick out its own....
  95 + * this is O(n), but currently I gave no better idea at all.
  96 + */
  97 + while (NULL != sess_queue->next) {
  98 + Session session = (Session)sess_queue->next->msg;
  99 +
  100 + if (now >= session->livetime) {
  101 + Queue to_delete = sess_queue->next;
  102 + sess_queue->next = sess_queue->next->next;
  103 + delete(session);
  104 + delete(to_delete);
  105 + continue;
  106 + }
  107 +
  108 + if (NULL != sid && 0 == memcmp(session->id, sid, 36)) {
  109 + session->livetime = time(NULL) + SESSION_LIVETIME;
  110 + sess = session;
  111 + }
  112 +
  113 + sess_queue = sess_queue->next;
  114 + }
  115 +
  116 + if (NULL == sess) {
  117 + sess = new(Session);
  118 + queuePut(sess_queue, sess);
  119 + }
  120 +
  121 + return sess;
  122 +}
  123 +
  124 +
  125 +static
60 126 void
61   -loginAdapter(Application application, HttpWorker worker, unsigned long sid)
  127 +loginAdapter(Application application, HttpWorker worker, Session session)
62 128 {
63 129 HashValue username;
64 130 HashValue password;
... ... @@ -82,34 +148,7 @@ loginAdapter(Application application, HttpWorker worker, unsigned long sid)
82 148 (char *)(username->value), username->nvalue,
83 149 (char *)(password->value), password->nvalue);
84 150
85   - if (applicationLogin(application, credential)) {
86   - char buffer[200];
87   - size_t nbuf;
88   -
89   - if (NO_SESSION_SID == sid
90   - || NULL == applicationSessionGet(application, sid)) {
91   - sid = applicationSessionStart(
92   - application,
93   - (char *)(username->value),
94   - username->nvalue);
95   - } else {
96   - applicationSessionUpdate(
97   - application,
98   - sid,
99   - username->value,
100   - username->nvalue);
101   - }
102   -
103   - nbuf = sprintf(buffer, "sid=%lu;Path=/", sid);
104   -
105   - worker->current_response =
106   - (HttpMessage)httpResponseSession(
107   - applicationSessionGet(application, sid));
108   -
109   - hashAdd(
110   - worker->current_response->header,
111   - new(HttpHeader, CSTRA("Set-Cookie"), buffer, nbuf));
112   - } else {
  151 + if (! applicationLogin(application, credential, session)) {
113 152 worker->current_response =
114 153 new(HttpResponse, "HTTP/1.1", 403, "Forbidden");
115 154 }
... ... @@ -117,53 +156,42 @@ loginAdapter(Application application, HttpWorker worker, unsigned long sid)
117 156 delete(credential);
118 157 }
119 158
120   -
121 159 void
122 160 applicationAdapterHttpUpdate(void * _this, void * subject)
123 161 {
124 162 ApplicationAdapterHttp this = _this;
125   - HttpWorker worker = (HttpWorker)subject;
126   - unsigned long sid = getSessionId(worker->current_request->cookies);
127   - Session session = applicationSessionGet(this->application, sid);
128   -
129   - if (NULL != session) {
130   - if (time(NULL) < session->livetime) {
131   - session->livetime = time(NULL) + SESSION_LIVETIME;
132   - } else {
133   - applicationSessionStop(this->application, sid);
134   - }
135   -
136   - }
  163 + HttpWorker worker = (HttpWorker)subject;
  164 + char * sid;
  165 + Session session;
  166 + char buf[200];
  167 + size_t nbuf;
  168 +
  169 + sid = getSessionId(worker->current_request->cookies);
  170 + session = getSession(this->application->active_sessions, sid);
  171 +
  172 + nbuf = sprintf(buf, SESS_HEADER,
  173 + session->id,
  174 + SESSION_LIVETIME,
  175 + session->livetime - time(NULL));
  176 + queuePut(
  177 + worker->additional_headers,
  178 + new(HttpHeader, CSTRA("X-TaskramblerSession"), buf, nbuf));
  179 +
  180 + nbuf = sprintf(buf, "sid=%s;Path=/", session->id);
  181 + queuePut(
  182 + worker->additional_headers,
  183 + new(HttpHeader, CSTRA("Set-Cookie"), buf, nbuf));
137 184
138 185 if (0 == strcmp("POST", worker->current_request->method)) {
139 186 if (0 == strcmp("/login/", worker->current_request->path)) {
140   - loginAdapter(this->application, worker, sid);
  187 + loginAdapter(this->application, worker, session);
141 188 return;
142 189 }
143 190 }
144 191
145 192 if (0 == strcmp("GET", worker->current_request->method)) {
146   - if (0 == strcmp("/sessinfo/", worker->current_request->path)) {
147   - worker->current_response =
148   - (HttpMessage)httpResponseSession(
149   - applicationSessionGet(this->application, sid));
150   - return;
151   - }
152   -
153   - if (0 == strcmp("/sess/", worker->current_request->path)) {
154   - if (NO_SESSION_SID == sid
155   - || NULL == applicationSessionGet(this->application, sid)) {
156   - sid = applicationSessionStart(this->application, NULL, 0);
157   - }
158   -
159   - worker->current_response =
160   - (HttpMessage)httpResponseSession(
161   - applicationSessionGet(this->application, sid));
162   - return;
163   - }
164   -
165 193 if (0 == strcmp("/randval/", worker->current_request->path)) {
166   - if (NO_SESSION_SID != sid) {
  194 + if (NO_SESSION_SID != session->id) {
167 195 worker->current_response =
168 196 (HttpMessage)httpResponseRandval(
169 197 this->application->val->timestamp,
... ...
... ... @@ -25,8 +25,9 @@
25 25 #include <stdarg.h>
26 26
27 27 #include "class.h"
28   -#include "hash.h"
  28 +#include "queue.h"
29 29 #include "application/application.h"
  30 +#include "storage.h"
30 31
31 32 #include "utils/memory.h"
32 33
... ... @@ -35,11 +36,20 @@ int
35 36 applicationCtor(void * _this, va_list * params)
36 37 {
37 38 Application this = _this;
  39 + size_t i;
38 40
39   - this->val = va_arg(*params, struct randval *);
40   - this->auth = va_arg(*params, void *);
  41 + this->val = va_arg(*params, struct randval *);
41 42
42   - this->active_sessions = new(Hash);
  43 + // initialize authenticators to use.
  44 + this->nauth = va_arg(*params, size_t);
  45 + this->auth = memMalloc(this->nauth * sizeof(void*));
  46 + for (i=0; i<this->nauth; i++) {
  47 + this->auth[i] = va_arg(*params, void *);
  48 + }
  49 +
  50 + this->active_sessions = new(Queue);
  51 +
  52 + this->users = new(Storage, "./run/users.db");
43 53
44 54 return 0;
45 55 }
... ... @@ -49,8 +59,15 @@ void
49 59 applicationDtor(void * _this)
50 60 {
51 61 Application this = _this;
  62 + size_t i;
52 63
53 64 delete(this->active_sessions);
  65 +
  66 + for (i=0; i<this->nauth; i++) {
  67 + delete(this->auth[i]);
  68 + }
  69 +
  70 + MEM_FREE(this->auth);
54 71 }
55 72
56 73
... ...
... ... @@ -34,9 +34,38 @@
34 34
35 35
36 36 int
37   -applicationLogin(Application this, Credential credential)
  37 +applicationLogin(
  38 + Application this,
  39 + Credential credential,
  40 + Session session)
38 41 {
39   - return authenticate(this->auth, credential);
  42 + size_t i;
  43 +
  44 + for (i=0; i<this->nauth; i++) {
  45 + if (authenticate(this->auth, credential)) {
  46 + session->user = new(User, NULL);
  47 +
  48 + switch (credential->type) {
  49 + case CRED_PASSWORD:
  50 + session->user->email = CRED_PWD(credential).user;
  51 + session->user->nemail = &CRED_PWD(credential).nuser;
  52 +
  53 + if (NULL == userLoad(session->user, this->users)) {
  54 + session->user->email = NULL;
  55 + session->user->nemail = NULL;
  56 + }
  57 +
  58 + break;
  59 +
  60 + default:
  61 + break;
  62 + }
  63 +
  64 + return 1;
  65 + }
  66 + }
  67 +
  68 + return 0;
40 69 }
41 70
42 71 // vim: set ts=4 sw=4:
... ...
... ... @@ -33,9 +33,10 @@
33 33
34 34
35 35 Session
36   -applicationSessionGet(Application this, unsigned long sid)
  36 +applicationSessionGet(Application this, const char * sid)
37 37 {
38   - return hashGetByVal(this->active_sessions, sid);
  38 +// return hashGet(this->active_sessions, sid, 36);
  39 + return NULL;
39 40 }
40 41
41 42 // vim: set ts=4 sw=4:
... ...
... ... @@ -26,20 +26,20 @@
26 26
27 27 #include "class.h"
28 28 #include "session.h"
29   -#include "hash.h"
  29 +#include "queue.h"
30 30 #include "application/application.h"
31 31
32 32 #include "utils/memory.h"
33 33
34 34
35   -unsigned long
36   -applicationSessionStart(Application this, const char * name, size_t nname)
  35 +Session
  36 +applicationSessionStart(Application this)
37 37 {
38   - Session session = new(Session, name, nname);
  38 + Session session = new(Session);
39 39
40   - hashAdd(this->active_sessions, session);
  40 + queuePut(this->active_sessions, session);
41 41
42   - return session->id;
  42 + return session;
43 43 }
44 44
45 45 // vim: set ts=4 sw=4:
... ...
... ... @@ -33,10 +33,10 @@
33 33
34 34
35 35 void
36   -applicationSessionStop(Application this, unsigned long sid)
  36 +applicationSessionStop(Application this, const char * sid)
37 37 {
38   - Session session = hashDeleteByVal(this->active_sessions, sid);
39   - delete(session);
  38 + //Session session = hashDelete(this->active_sessions, sid, 36);
  39 + //delete(session);
40 40 }
41 41
42 42 // vim: set ts=4 sw=4:
... ...
... ... @@ -36,19 +36,19 @@
36 36 void
37 37 applicationSessionUpdate(
38 38 Application this,
39   - unsigned long sid,
  39 + const char * sid,
40 40 const char * name,
41 41 size_t nname)
42 42 {
43   - Session session = hashGetByVal(this->active_sessions, sid);
44   -
45   - if (NULL != session) {
46   - MEM_FREE(session->username);
47   -
48   - session->username = memMalloc(nname + 1);
49   - session->username[nname] = 0;
50   - memcpy(session->username, name, nname);
51   - }
  43 +// Session session = hashGet(this->active_sessions, sid, 36);
  44 +//
  45 +// if (NULL != session) {
  46 +// MEM_FREE(session->username);
  47 +//
  48 +// session->username = memMalloc(nname + 1);
  49 +// session->username[nname] = 0;
  50 +// memcpy(session->username, name, nname);
  51 +// }
52 52 }
53 53
54 54 // vim: set ts=4 sw=4:
... ...
... ... @@ -31,7 +31,8 @@ WORKER = worker.c \
31 31 worker/process.c \
32 32 worker/answer.c \
33 33 worker/get_asset.c \
34   - worker/add_common_header.c
  34 + worker/add_common_header.c \
  35 + worker/add_computed_header.c
35 36 HEADER = header.c \
36 37 header/to_string.c
37 38
... ...
... ... @@ -36,7 +36,7 @@
36 36 #include "utils/memory.h"
37 37 #include "hash.h"
38 38
39   -#define RESP_DATA "{\"id\":\"%lu\",\"timeout\":%d,\"timeleft\":%ld,\"username\":\"%s\"}"
  39 +#define RESP_DATA "{\"id\":\"%s\",\"timeout\":%d,\"timeleft\":%ld}"
40 40
41 41 HttpResponse
42 42 httpResponseSession(Session session)
... ... @@ -53,10 +53,9 @@ httpResponseSession(Session session)
53 53 new(HttpHeader, CSTRA("Content-Type"), CSTRA("application/json")));
54 54
55 55 nbuf = sprintf(buffer, RESP_DATA,
56   - (NULL != session)? session->id : 0,
  56 + (NULL != session)? session->id : "",
57 57 (NULL != session)? SESSION_LIVETIME : 0,
58   - (NULL != session)? session->livetime - time(NULL) : 0,
59   - (NULL != session)? session->username : "");
  58 + (NULL != session)? session->livetime - time(NULL) : 0);
60 59
61 60 message->nbody = nbuf;
62 61 message->body = memMalloc(nbuf);
... ...
... ... @@ -33,6 +33,7 @@
33 33 #include "class.h"
34 34 #include "stream.h"
35 35 #include "hash.h"
  36 +#include "queue.h"
36 37 #include "http/worker.h"
37 38 #include "http/parser.h"
38 39 #include "http/writer.h"
... ... @@ -57,6 +58,8 @@ httpWorkerCtor(void * _this, va_list * params)
57 58 sprintf(cbuf_id, "%s_%s", "parser", id);
58 59 this->pbuf = new(Cbuf, cbuf_id, PARSER_MAX_BUF);
59 60
  61 + this->additional_headers = new(Queue);
  62 +
60 63 this->parser = new(HttpParser, this->pbuf);
61 64 this->writer = new(HttpWriter);
62 65
... ... @@ -71,6 +74,8 @@ httpWorkerDtor(void * _this)
71 74
72 75 MEM_FREE(this->id);
73 76
  77 + delete(this->additional_headers);
  78 +
74 79 delete(this->parser);
75 80 delete(this->writer);
76 81
... ... @@ -90,6 +95,8 @@ httpWorkerClone(void * _this, void * _base)
90 95 this->asset_pool = base->asset_pool;
91 96 this->application_adapter = base->application_adapter;
92 97
  98 + this->additional_headers = new(Queue);
  99 +
93 100 this->parser = new(HttpParser, base->pbuf);
94 101 /*
95 102 * I am pretty sure that it is not neccessary to have a
... ...
  1 +/**
  2 + * \file
  3 + *
  4 + * \author Georg Hopp
  5 + *
  6 + * \copyright
  7 + * Copyright © 2012 Georg Hopp
  8 + *
  9 + * This program is free software: you can redistribute it and/or modify
  10 + * it under the terms of the GNU General Public License as published by
  11 + * the Free Software Foundation, either version 3 of the License, or
  12 + * (at your option) any later version.
  13 + *
  14 + * This program is distributed in the hope that it will be useful,
  15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17 + * GNU General Public License for more details.
  18 + *
  19 + * You should have received a copy of the GNU General Public License
  20 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21 + */
  22 +
  23 +#include <sys/types.h>
  24 +
  25 +#include "class.h"
  26 +
  27 +#include "http/message.h"
  28 +#include "http/header.h"
  29 +#include "http/worker.h"
  30 +
  31 +#include "queue.h"
  32 +
  33 +#include "utils/memory.h"
  34 +
  35 +
  36 +void
  37 +httpWorkerAddComputedHeader(HttpWorker this)
  38 +{
  39 + HttpHeader header = (HttpHeader)queueGet(this->additional_headers);
  40 +
  41 + while(NULL != header) {
  42 + hashAdd(this->current_response->header, header);
  43 + header = (HttpHeader)queueGet(this->additional_headers);
  44 + }
  45 +}
  46 +
  47 +// vim: set ts=4 sw=4:
... ...
... ... @@ -50,6 +50,7 @@
50 50
51 51 HttpMessage httpWorkerGetAsset(HttpWorker, const char *);
52 52 void httpWorkerAddCommonHeader(HttpWorker);
  53 +void httpWorkerAddComputedHeader(HttpWorker);
53 54
54 55
55 56 ssize_t
... ... @@ -117,6 +118,7 @@ httpWorkerProcess(HttpWorker this, Stream st)
117 118 }
118 119
119 120 httpWorkerAddCommonHeader(this);
  121 + httpWorkerAddComputedHeader(this);
120 122 delete(this->current_request);
121 123 queuePut(this->writer->queue, this->current_response);
122 124 this->current_response = NULL;
... ...
... ... @@ -26,6 +26,7 @@
26 26 #include <string.h>
27 27 #include <stdio.h>
28 28 #include <sys/types.h>
  29 +#include <uuid/uuid.h>
29 30
30 31 #include "session.h"
31 32 #include "hash.h"
... ... @@ -40,15 +41,13 @@ int
40 41 sessionCtor(void * _this, va_list * params)
41 42 {
42 43 Session this = _this;
43   - char * uname = va_arg(* params, char *);
44   - size_t nuname = va_arg(* params, size_t);
  44 + uuid_t uuid;
45 45
46 46 this->livetime = time(NULL) + SESSION_LIVETIME;
47   - this->id = sdbm((unsigned char *)uname, nuname) ^ this->livetime;
  47 + uuid_generate(uuid);
  48 + uuid_unparse(uuid, this->id);
48 49
49   - this->username = memMalloc(nuname + 1);
50   - this->username[nuname] = 0;
51   - memcpy(this->username, uname, nuname);
  50 + this->hash = sdbm((unsigned char *)this->id, 36);
52 51
53 52 return 0;
54 53 }
... ... @@ -57,18 +56,15 @@ static
57 56 void
58 57 sessionDtor(void * _this)
59 58 {
60   - Session this = _this;
61   -
62   - MEM_FREE(this->username);
63 59 }
64 60
65 61 static
66 62 unsigned long
67   -sessionGetId(void * _this)
  63 +sessionGetHash(void * _this)
68 64 {
69 65 Session this = _this;
70 66
71   - return this->id;
  67 + return this->hash;
72 68 }
73 69
74 70 static
... ... @@ -78,7 +74,7 @@ sessionHandleDouble(void * _this, void * _doub)
78 74 }
79 75
80 76 INIT_IFACE(Class, sessionCtor, sessionDtor, NULL);
81   -INIT_IFACE(Hashable, sessionGetId, sessionHandleDouble);
  77 +INIT_IFACE(Hashable, sessionGetHash, sessionHandleDouble);
82 78 CREATE_CLASS(Session, NULL, IFACE(Class), IFACE(Hashable));
83 79
84 80 // vim: set ts=4 sw=4:
... ...
... ... @@ -55,6 +55,9 @@
55 55 //#define DEFAULT_SECS 1
56 56 #define DEFAULT_USECS 0
57 57
  58 +#define LDAP_BASE "ou=user,dc=yabrog,dc=weird-web-workers,dc=org"
  59 +
  60 +
58 61 void nullhandler() {}
59 62
60 63 void daemonize(void);
... ... @@ -137,7 +140,7 @@ main()
137 140
138 141 default:
139 142 {
140   - AuthLdap auth;
  143 + AuthLdap ldap;
141 144 Application application;
142 145 ApplicationAdapterHttp adapterHttp;
143 146 HttpWorker worker;
... ... @@ -150,11 +153,12 @@ main()
150 153 close(shm);
151 154
152 155 logger = new(LoggerSyslog, LOGGER_DEBUG);
153   - auth = new(AuthLdap,
154   - "ldap://hosted/",
155   - CSTRA("ou=user,dc=yabrog,dc=weird-web-workers,dc=org"));
  156 +
156 157 worker = new(HttpWorker, "testserver");
157   - application = new(Application, value, auth);
  158 + ldap = new(
  159 + AuthLdap, "ldap://hosted/", CSTRA(LDAP_BASE));
  160 + application = new(Application, value, 1, ldap);
  161 +
158 162 adapterHttp = new(ApplicationAdapterHttp, application);
159 163 subjectAttach(worker, adapterHttp);
160 164
... ... @@ -206,7 +210,6 @@ main()
206 210 delete(worker);
207 211 delete(adapterHttp);
208 212 delete(application);
209   - delete(auth);
210 213 delete(logger);
211 214
212 215 clearMimeTypes();
... ...
  1 +#include <uuid/uuid.h>
  2 +#include <stdio.h>
  3 +
  4 +int
  5 +main(int argc, char * argv[])
  6 +{
  7 + uuid_t uuid;
  8 + char uuid_str[37];
  9 +
  10 + uuid_generate(uuid);
  11 + uuid_unparse(uuid, uuid_str);
  12 +
  13 + printf("%s\n", uuid_str);
  14 +
  15 + return 0;
  16 +}
  17 +
  18 +// vim: set ts=4 sw=4:
... ...
Please register or login to post a comment