citadel
About: Citadel is an advanced messaging and collaboration system for groupware and BBS applications (preferred OS: Linux).
  Fossies Dox: citadel.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

serv_vcard.c
Go to the documentation of this file.
1/*
2 * A server-side module for Citadel which supports address book information
3 * using the standard vCard format.
4 *
5 * Copyright (c) 1999-2020 by the citadel.org team
6 *
7 * This program is open source software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 3.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16/*
17 * Format of the "Exclusive ID" field of the message containing a user's
18 * vCard. Doesn't matter what it really looks like as long as it's both
19 * unique and consistent (because we use it for replication checking to
20 * delete the old vCard network-wide when the user enters a new one).
21 */
22#define VCARD_EXT_FORMAT "Citadel vCard: personal card for %s at %s"
23
24/*
25 * Citadel will accept either text/vcard or text/x-vcard as the MIME type
26 * for a vCard. The following definition determines which one it *generates*
27 * when serializing.
28 */
29#define VCARD_MIME_TYPE "text/x-vcard"
30
31#include "sysdep.h"
32#include <stdlib.h>
33#include <unistd.h>
34#include <stdio.h>
35#include <fcntl.h>
36#include <signal.h>
37#include <pwd.h>
38#include <errno.h>
39#include <ctype.h>
40#include <sys/types.h>
41#include <time.h>
42#include <sys/wait.h>
43#include <string.h>
44#include <limits.h>
45#include <libcitadel.h>
46#include "citadel.h"
47#include "server.h"
48#include "citserver.h"
49#include "support.h"
50#include "config.h"
51#include "control.h"
52#include "user_ops.h"
53#include "database.h"
54#include "msgbase.h"
55#include "room_ops.h"
56#include "internet_addressing.h"
57#include "serv_vcard.h"
58#include "citadel_ldap.h"
59#include "ctdl_module.h"
60
61/*
62 * set global flag calling for an aide to validate new users
63 */
64void set_mm_valid(void) {
65 int flags = 0;
66
68 flags = CtdlGetConfigInt("MMflags");
69 flags = flags | MM_VALID ;
70 CtdlSetConfigInt("MMflags", flags);
72}
73
74
75///TODO: gettext!
76#define _(a) a
77
78/*
79 * See if there is a valid Internet address in a vCard to use for outbound
80 * Internet messages. If there is, stick it in the buffer.
81 */
82void extract_inet_email_addrs(char *emailaddrbuf, size_t emailaddrbuf_len,
83 char *secemailaddrbuf, size_t secemailaddrbuf_len,
84 struct vCard *v,
85 int local_addrs_only
86) {
87 char *s, *k, *addr;
88 int instance = 0;
89 int IsDirectoryAddress;
90 int saved_instance = 0;
91
92 /* Go through the vCard searching for *all* Internet email addresses
93 */
94 while (s = vcard_get_prop(v, "email", 1, instance, 0), s != NULL) {
95 k = vcard_get_prop(v, "email", 1, instance, 1);
96 if ( (s != NULL) && (k != NULL) && (bmstrcasestr(k, "internet")) ) {
97 addr = strdup(s);
98 striplt(addr);
99 if (!IsEmptyStr(addr)) {
100 IsDirectoryAddress = IsDirectory(addr, 1);
101
102 syslog(LOG_DEBUG, "EVQ: addr=<%s> IsDirectoryAddress=<%d> local_addrs_only=<%d>", addr, IsDirectoryAddress, local_addrs_only);
103
104 if ( IsDirectoryAddress || !local_addrs_only)
105 {
106 ++saved_instance;
107 if ((saved_instance == 1) && (emailaddrbuf != NULL)) {
108 safestrncpy(emailaddrbuf, addr, emailaddrbuf_len);
109 }
110 else if ((saved_instance == 2) && (secemailaddrbuf != NULL)) {
111 safestrncpy(secemailaddrbuf, addr, secemailaddrbuf_len);
112 }
113 else if ((saved_instance > 2) && (secemailaddrbuf != NULL)) {
114 if ( (strlen(addr) + strlen(secemailaddrbuf) + 2)
115 < secemailaddrbuf_len ) {
116 strcat(secemailaddrbuf, "|");
117 strcat(secemailaddrbuf, addr);
118 }
119 }
120 }
121 if (!IsDirectoryAddress && local_addrs_only)
122 {
123 StrBufAppendPrintf(CC->StatusMessage, "\n%d|", ERROR+ ILLEGAL_VALUE);
124 StrBufAppendBufPlain(CC->StatusMessage, addr, -1, 0);
125 StrBufAppendBufPlain(CC->StatusMessage, HKEY("|"), 0);
126 StrBufAppendBufPlain(CC->StatusMessage, _("unable to add this emailaddress; its not matching our domain."), -1, 0);
127 }
128 }
129 free(addr);
130 }
131 ++instance;
132 }
133}
134
135
136/*
137 * See if there is a name / screen name / friendly name in a vCard to use for outbound
138 * Internet messages. If there is, stick it in the buffer.
139 */
140void extract_friendly_name(char *namebuf, size_t namebuf_len, struct vCard *v)
141{
142 char *s;
143
144 s = vcard_get_prop(v, "fn", 1, 0, 0);
145 if (s == NULL) {
146 s = vcard_get_prop(v, "n", 1, 0, 0);
147 }
148
149 if (s != NULL) {
150 safestrncpy(namebuf, s, namebuf_len);
151 }
152}
153
154
155/*
156 * Callback function for vcard_upload_beforesave() hunts for the real vcard in the MIME structure
157 */
158void vcard_extract_vcard(char *name, char *filename, char *partnum, char *disp,
159 void *content, char *cbtype, char *cbcharset, size_t length,
160 char *encoding, char *cbid, void *cbuserdata)
161{
162 struct vCard **v = (struct vCard **) cbuserdata;
163
164 if ( (!strcasecmp(cbtype, "text/x-vcard"))
165 || (!strcasecmp(cbtype, "text/vcard")) ) {
166
167 syslog(LOG_DEBUG, "vcard: part %s contains a vCard! Loading...", partnum);
168 if (*v != NULL) {
169 vcard_free(*v);
170 }
171 *v = vcard_load(content);
172 }
173}
174
175
176/*
177 * This handler detects whether the user is attempting to save a new
178 * vCard as part of his/her personal configuration, and handles the replace
179 * function accordingly (delete the user's existing vCard in the config room
180 * and in the global address book).
181 */
182int vcard_upload_beforesave(struct CtdlMessage *msg, struct recptypes *recp) {
183 char *s;
184 char buf[SIZ];
185 struct ctdluser usbuf;
186 long what_user;
187 struct vCard *v = NULL;
188 char *ser = NULL;
189 int i = 0;
190 int yes_my_citadel_config = 0;
191 int yes_any_vcard_room = 0;
192
193 if ((!CC->logged_in) && (CC->vcard_updated_by_ldap==0)) return(0); /* Only do this if logged in, or if ldap changed the vcard. */
194
195 /* Is this some user's "My Citadel Config" room? */
196 if (((CC->room.QRflags & QR_MAILBOX) != 0) &&
197 (!strcasecmp(&CC->room.QRname[11], USERCONFIGROOM)) ) {
198 /* Yes, we want to do this */
199 yes_my_citadel_config = 1;
200#ifdef VCARD_SAVES_BY_AIDES_ONLY
201 /* Prevent non-aides from performing registration changes, but ldap is ok. */
202 if ((CC->user.axlevel < AxAideU) && (CC->vcard_updated_by_ldap==0)) {
203 return(1);
204 }
205#endif
206
207 }
208
209 /* Is this a room with an address book in it? */
210 if (CC->room.QRdefaultview == VIEW_ADDRESSBOOK) {
211 yes_any_vcard_room = 1;
212 }
213
214 /* If neither condition exists, don't run this hook. */
215 if ( (!yes_my_citadel_config) && (!yes_any_vcard_room) ) {
216 return(0);
217 }
218
219 /* If this isn't a MIME message, don't bother. */
220 if (msg->cm_format_type != 4) return(0);
221
222 /* Ok, if we got this far, look into the situation further... */
223
224 if (CM_IsEmpty(msg, eMesageText)) return(0);
225
226 mime_parser(CM_RANGE(msg, eMesageText),
228 NULL, NULL,
229 &v, /* user data ptr - put the vcard here */
230 0
231 );
232
233 if (v == NULL) return(0); /* no vCards were found in this message */
234
235 /* If users cannot create their own accounts, they cannot re-register either. */
236 if ( (yes_my_citadel_config) &&
237 (CtdlGetConfigInt("c_disable_newu")) &&
238 (CC->user.axlevel < AxAideU) &&
239 (CC->vcard_updated_by_ldap==0) )
240 {
241 return(1);
242 }
243
244 vcard_get_prop(v, "fn", 1, 0, 0);
245
246
247 if (yes_my_citadel_config) {
248 /* Bingo! The user is uploading a new vCard, so
249 * delete the old one. First, figure out which user
250 * is being re-registered...
251 */
252 what_user = atol(CC->room.QRname);
253
254 if (what_user == CC->user.usernum) {
255 /* It's the logged in user. That was easy. */
256 memcpy(&usbuf, &CC->user, sizeof(struct ctdluser));
257 }
258
259 else if (CtdlGetUserByNumber(&usbuf, what_user) == 0) {
260 /* We fetched a valid user record */
261 }
262
263 else {
264 /* somebody set up us the bomb! */
265 yes_my_citadel_config = 0;
266 }
267 }
268
269 if (yes_my_citadel_config) {
270 /* Delete the user's old vCard. This would probably
271 * get taken care of by the replication check, but we
272 * want to make sure there is absolutely only one
273 * vCard in the user's config room at all times.
274 *
275 */
276 CtdlDeleteMessages(CC->room.QRname, NULL, 0, "[Tt][Ee][Xx][Tt]/.*[Vv][Cc][Aa][Rr][Dd]$");
277
278 /* Make the author of the message the name of the user. */
279 if (!IsEmptyStr(usbuf.fullname)) {
281 }
282 }
283
284 /* Insert or replace RFC2739-compliant free/busy URL */
285 if (yes_my_citadel_config) {
286 sprintf(buf, "http://%s/%s.vfb",
287 CtdlGetConfigStr("c_fqdn"),
289 for (i=0; buf[i]; ++i) {
290 if (buf[i] == ' ') buf[i] = '_';
291 }
292 vcard_set_prop(v, "FBURL;PREF", buf, 0);
293 }
294
295
296 s = vcard_get_prop(v, "UID", 1, 0, 0);
297 if (s == NULL) { /* Note LDAP auth sets UID from the LDAP UUID, use that if it exists. */
298 /* Enforce local UID policy if applicable */
299 if (yes_my_citadel_config) {
300 snprintf(buf, sizeof buf, VCARD_EXT_FORMAT, msg->cm_fields[eAuthor], NODENAME);
301 } else {
302 /* If the vCard has no UID, then give it one. */
303 generate_uuid(buf);
304 }
305 vcard_set_prop(v, "UID", buf, 0);
306 }
307
308
309 /*
310 * Set the EUID of the message to the UID of the vCard.
311 */
313
314 s = vcard_get_prop(v, "UID", 1, 0, 0);
315 if (!IsEmptyStr(s)) {
316 CM_SetField(msg, eExclusiveID, s, strlen(s));
317 if (CM_IsEmpty(msg, eMsgSubject)) {
319 }
320 }
321
322 /*
323 * Set the Subject to the name in the vCard.
324 */
325 s = vcard_get_prop(v, "FN", 1, 0, 0);
326 if (s == NULL) {
327 s = vcard_get_prop(v, "N", 1, 0, 0);
328 }
329 if (!IsEmptyStr(s)) {
330 CM_SetField(msg, eMsgSubject, s, strlen(s));
331 }
332
333 /* Re-serialize it back into the msg body */
334 ser = vcard_serialize(v);
335 if (!IsEmptyStr(ser)) {
336 StrBuf *buf;
337 long serlen;
338
339 serlen = strlen(ser);
340 buf = NewStrBufPlain(NULL, serlen + 1024);
341
342 StrBufAppendBufPlain(buf, HKEY("Content-type: " VCARD_MIME_TYPE "\r\n\r\n"), 0);
343 StrBufAppendBufPlain(buf, ser, serlen, 0);
344 StrBufAppendBufPlain(buf, HKEY("\r\n"), 0);
345 CM_SetAsFieldSB(msg, eMesageText, &buf);
346 free(ser);
347 }
348
349 /* Now allow the save to complete. */
350 vcard_free(v);
351 return(0);
352}
353
354
355/*
356 * This handler detects whether the user is attempting to save a new
357 * vCard as part of his/her personal configuration, and handles the replace
358 * function accordingly (copy the vCard from the config room to the global
359 * address book).
360 */
361int vcard_upload_aftersave(struct CtdlMessage *msg, struct recptypes *recp) {
362 char *ptr;
363 int linelen;
364 long I;
365 struct vCard *v;
366 int is_UserConf=0;
367 int is_MY_UserConf=0;
368 int is_GAB=0;
369 char roomname[ROOMNAMELEN];
370
371 if (msg->cm_format_type != 4) return(0);
372 if ((!CC->logged_in) && (CC->vcard_updated_by_ldap==0)) return(0); /* Only do this if logged in, or if ldap changed the vcard. */
373
374 /* We're interested in user config rooms only. */
375
376 if ( !IsEmptyStr(CC->room.QRname) &&
377 (strlen(CC->room.QRname) >= 12) &&
378 (!strcasecmp(&CC->room.QRname[11], USERCONFIGROOM)) ) {
379 is_UserConf = 1; /* It's someone's config room */
380 }
381 CtdlMailboxName(roomname, sizeof roomname, &CC->user, USERCONFIGROOM);
382 if (!strcasecmp(CC->room.QRname, roomname)) {
383 is_UserConf = 1;
384 is_MY_UserConf = 1; /* It's MY config room */
385 }
386 if (!strcasecmp(CC->room.QRname, ADDRESS_BOOK_ROOM)) {
387 is_GAB = 1; /* It's the Global Address Book */
388 }
389
390 if (!is_UserConf && !is_GAB) return(0);
391
392 if (CM_IsEmpty(msg, eMesageText))
393 return 0;
394
395 ptr = msg->cm_fields[eMesageText];
396
397 CC->vcard_updated_by_ldap=0; /* As this will write LDAP's previous changes, disallow LDAP change auth until next LDAP change. */
398
399 NewStrBufDupAppendFlush(&CC->StatusMessage, NULL, NULL, 0);
400
401 StrBufPrintf(CC->StatusMessage, "%d\n", LISTING_FOLLOWS);
402
403 while (ptr != NULL) {
404
405 linelen = strcspn(ptr, "\n");
406 if (linelen == 0) return(0); /* end of headers */
407
408 if ( (!strncasecmp(ptr, "Content-type: text/x-vcard", 26))
409 || (!strncasecmp(ptr, "Content-type: text/vcard", 24)) ) {
410 /*
411 * Bingo! The user is uploading a new vCard, so
412 * copy it to the Global Address Book room.
413 */
414
415 I = atol(msg->cm_fields[eVltMsgNum]);
416 if (I <= 0L) return(0);
417
418 /* Store our friendly/display name in memory */
419 if (is_MY_UserConf) {
420 v = vcard_load(msg->cm_fields[eMesageText]);
421 extract_friendly_name(CC->cs_inet_fn, sizeof CC->cs_inet_fn, v);
422 vcard_free(v);
423 }
424
425 if (!is_GAB)
426 { // This is not the GAB
427 /* Put it in the Global Address Book room... */
429 }
430
431 /* Some sites want an Aide to be notified when a
432 * user registers or re-registers
433 * But if the user was an Aide or was edited by an Aide then we can
434 * Assume they don't need validating.
435 */
436 if (CC->user.axlevel >= AxAideU) {
438 CC->user.flags |= US_REGIS;
440 return (0);
441 }
442
443 set_mm_valid();
444
445 /* ...which also means we need to flag the user */
447 CC->user.flags |= (US_REGIS|US_NEEDVALID);
449
450 return(0);
451 }
452
453 ptr = strchr((char *)ptr, '\n');
454 if (ptr != NULL) ++ptr;
455 }
456
457 return(0);
458}
459
460
461
462/*
463 * back end function used for callbacks
464 */
465void vcard_gu_backend(long supplied_msgnum, void *userdata) {
466 long *msgnum;
467
468 msgnum = (long *) userdata;
469 *msgnum = supplied_msgnum;
470}
471
472
473/*
474 * If this user has a vcard on disk, read it into memory, otherwise allocate
475 * and return an empty vCard.
476 */
477struct vCard *vcard_get_user(struct ctdluser *u) {
478 char hold_rm[ROOMNAMELEN];
479 char config_rm[ROOMNAMELEN];
480 struct CtdlMessage *msg = NULL;
481 struct vCard *v;
482 long VCmsgnum;
483
484 strcpy(hold_rm, CC->room.QRname); /* save current room */
485 CtdlMailboxName(config_rm, sizeof config_rm, u, USERCONFIGROOM);
486
487 if (CtdlGetRoom(&CC->room, config_rm) != 0) {
488 CtdlGetRoom(&CC->room, hold_rm);
489 return vcard_new();
490 }
491
492 /* We want the last (and probably only) vcard in this room */
493 VCmsgnum = (-1);
494 CtdlForEachMessage(MSGS_LAST, 1, NULL, "[Tt][Ee][Xx][Tt]/.*[Vv][Cc][Aa][Rr][Dd]$",
495 NULL, vcard_gu_backend, (void *)&VCmsgnum );
496 CtdlGetRoom(&CC->room, hold_rm); /* return to saved room */
497
498 if (VCmsgnum < 0L) return vcard_new();
499
500 msg = CtdlFetchMessage(VCmsgnum, 1);
501 if (msg == NULL) return vcard_new();
502
503 v = vcard_load(msg->cm_fields[eMesageText]);
504 CM_Free(msg);
505 return v;
506}
507
508
509/*
510 * Store this user's vCard in the appropriate place
511 */
512/*
513 * Write our config to disk
514 */
515void vcard_write_user(struct ctdluser *u, struct vCard *v) {
516 char *ser;
517
518 ser = vcard_serialize(v);
519 if (ser == NULL) {
520 ser = strdup("begin:vcard\r\nend:vcard\r\n");
521 }
522 if (ser == NULL) return;
523
524 /* This handy API function does all the work for us.
525 * NOTE: normally we would want to set that last argument to 1, to
526 * force the system to delete the user's old vCard. But it doesn't
527 * have to, because the vcard_upload_beforesave() hook above
528 * is going to notice what we're trying to do, and delete the old vCard.
529 */
530 CtdlWriteObject(USERCONFIGROOM, /* which room */
531 VCARD_MIME_TYPE, /* MIME type */
532 ser, /* data */
533 strlen(ser)+1, /* length */
534 u, /* which user */
535 0, /* not binary */
536 0); /* no flags */
537
538 free(ser);
539}
540
541
542
543/*
544 * Old style "enter registration info" command. This function simply honors
545 * the REGI protocol command, translates the entered parameters into a vCard,
546 * and enters the vCard into the user's configuration.
547 */
548void cmd_regi(char *argbuf) {
549 int a,b,c;
550 char buf[SIZ];
551 struct vCard *my_vcard;
552
553 char tmpaddr[SIZ];
554 char tmpcity[SIZ];
555 char tmpstate[SIZ];
556 char tmpzip[SIZ];
557 char tmpaddress[SIZ];
558 char tmpcountry[SIZ];
559
561
562 if (!(CC->logged_in)) {
563 cprintf("%d Not logged in.\n",ERROR + NOT_LOGGED_IN);
564 return;
565 }
566
567 /* If users cannot create their own accounts, they cannot re-register either. */
568 if ( (CtdlGetConfigInt("c_disable_newu")) && (CC->user.axlevel < AxAideU) ) {
569 cprintf("%d Self-service registration is not allowed here.\n",
571 }
572
573 my_vcard = vcard_get_user(&CC->user);
574 strcpy(tmpaddr, "");
575 strcpy(tmpcity, "");
576 strcpy(tmpstate, "");
577 strcpy(tmpzip, "");
578 strcpy(tmpcountry, "USA");
579
580 cprintf("%d Send registration...\n", SEND_LISTING);
581 a=0;
582 while (client_getln(buf, sizeof buf), strcmp(buf,"000")) {
583 if (a==0) vcard_set_prop(my_vcard, "n", buf, 0);
584 if (a==1) strcpy(tmpaddr, buf);
585 if (a==2) strcpy(tmpcity, buf);
586 if (a==3) strcpy(tmpstate, buf);
587 if (a==4) {
588 for (c=0; buf[c]; ++c) {
589 if ((buf[c]>='0') && (buf[c]<='9')) {
590 b = strlen(tmpzip);
591 tmpzip[b] = buf[c];
592 tmpzip[b+1] = 0;
593 }
594 }
595 }
596 if (a==5) vcard_set_prop(my_vcard, "tel", buf, 0);
597 if (a==6) vcard_set_prop(my_vcard, "email;internet", buf, 0);
598 if (a==7) strcpy(tmpcountry, buf);
599 ++a;
600 }
601
602 snprintf(tmpaddress, sizeof tmpaddress, ";;%s;%s;%s;%s;%s",
603 tmpaddr, tmpcity, tmpstate, tmpzip, tmpcountry);
604 vcard_set_prop(my_vcard, "adr", tmpaddress, 0);
605 vcard_write_user(&CC->user, my_vcard);
606 vcard_free(my_vcard);
607}
608
609
610/*
611 * Protocol command to fetch registration info for a user
612 */
613void cmd_greg(char *argbuf)
614{
615 struct ctdluser usbuf;
616 struct vCard *v;
617 char *s;
618 char who[USERNAME_SIZE];
619 char adr[256];
620 char buf[256];
621
622 extract_token(who, argbuf, 0, '|', sizeof who);
623
624 if (!(CC->logged_in)) {
625 cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
626 return;
627 }
628
629 if (!strcasecmp(who,"_SELF_")) strcpy(who,CC->curr_user);
630
631 if ((CC->user.axlevel < AxAideU) && (strcasecmp(who,CC->curr_user))) {
632 cprintf("%d Higher access required.\n", ERROR + HIGHER_ACCESS_REQUIRED);
633 return;
634 }
635
636 if (CtdlGetUser(&usbuf, who) != 0) {
637 cprintf("%d '%s' not found.\n", ERROR + NO_SUCH_USER, who);
638 return;
639 }
640
641 v = vcard_get_user(&usbuf);
642
644 cprintf("%ld\n", usbuf.usernum);
645 cprintf("%s\n", usbuf.password);
646 s = vcard_get_prop(v, "n", 1, 0, 0);
647 cprintf("%s\n", s ? s : " "); /* name */
648 s = vcard_get_prop(v, "adr", 1, 0, 0);
649 snprintf(adr, sizeof adr, "%s", s ? s : " "); /* address */
650 extract_token(buf, adr, 2, ';', sizeof buf);
651 cprintf("%s\n", buf); /* street */
652 extract_token(buf, adr, 3, ';', sizeof buf);
653 cprintf("%s\n", buf); /* city */
654 extract_token(buf, adr, 4, ';', sizeof buf);
655 cprintf("%s\n", buf); /* state */
656 extract_token(buf, adr, 5, ';', sizeof buf);
657 cprintf("%s\n", buf); /* zip */
658
659 s = vcard_get_prop(v, "tel", 1, 0, 0);
660 if (s == NULL) s = vcard_get_prop(v, "tel", 1, 0, 0);
661 if (s != NULL) {
662 cprintf("%s\n", s);
663 }
664 else {
665 cprintf(" \n");
666 }
667
668 cprintf("%d\n", usbuf.axlevel);
669
670 s = vcard_get_prop(v, "email;internet", 0, 0, 0);
671 cprintf("%s\n", s ? s : " ");
672 s = vcard_get_prop(v, "adr", 0, 0, 0);
673 snprintf(adr, sizeof adr, "%s", s ? s : " ");/* address... */
674
675 extract_token(buf, adr, 6, ';', sizeof buf);
676 cprintf("%s\n", buf); /* country */
677 cprintf("000\n");
678 vcard_free(v);
679}
680
681
682
683/*
684 * When a user is being created, create his/her vCard.
685 */
687 char vname[256];
688 char buf[256];
689 int i;
690 struct vCard *v;
691 int need_default_vcard;
692
693 need_default_vcard =1;
694 vcard_fn_to_n(vname, usbuf->fullname, sizeof vname);
695 syslog(LOG_DEBUG, "vcard: converted <%s> to <%s>", usbuf->fullname, vname);
696
697 /* Create and save the vCard */
698 v = vcard_new();
699 if (v == NULL) return;
700 vcard_add_prop(v, "fn", usbuf->fullname);
701 vcard_add_prop(v, "n", vname);
702 vcard_add_prop(v, "adr", "adr:;;_;_;_;00000;__");
703
704#ifdef HAVE_GETPWUID_R
705 /* If using host auth mode, we add an email address based on the login */
706 if (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_HOST) {
707 struct passwd pwd;
708 char pwd_buffer[SIZ];
709
710#ifdef SOLARIS_GETPWUID
711 if (getpwuid_r(usbuf->uid, &pwd, pwd_buffer, sizeof pwd_buffer) != NULL) {
712#else // SOLARIS_GETPWUID
713 struct passwd *result = NULL;
714 syslog(LOG_DEBUG, "vcard: searching for uid %d", usbuf->uid);
715 if (getpwuid_r(usbuf->uid, &pwd, pwd_buffer, sizeof pwd_buffer, &result) == 0) {
716#endif // HAVE_GETPWUID_R
717 snprintf(buf, sizeof buf, "%s@%s", pwd.pw_name, CtdlGetConfigStr("c_fqdn"));
718 vcard_add_prop(v, "email;internet", buf);
719 need_default_vcard = 0;
720 }
721 }
722#endif
723
724
725#ifdef HAVE_LDAP
726 /*
727 * Is this an LDAP session? If so, copy various LDAP attributes from the directory entry
728 * into the user's vCard.
729 */
730 if ((CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP) || (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP_AD)) {
731 //uid_t ldap_uid;
732 int found_user;
733 char ldap_cn[512];
734 char ldap_dn[512];
735
736syslog(LOG_DEBUG, "\033[31m FIXME BORK BORK BORK try lookup by uid , or maybe dn?\033[0m");
737
738 found_user = CtdlTryUserLDAP(usbuf->fullname, ldap_dn, sizeof ldap_dn, ldap_cn, sizeof ldap_cn, &usbuf->uid);
739 if (found_user == 0) {
740 if (Ctdl_LDAP_to_vCard(ldap_dn, v)) {
741 /* Allow global address book and internet directory update without login long enough to write this. */
742 CC->vcard_updated_by_ldap++; /* Otherwise we'll only update the user config. */
743 need_default_vcard = 0;
744 syslog(LOG_DEBUG, "vcard: LDAP Created Initial vCard for %s\n",usbuf->fullname);
745 }
746 }
747 }
748#endif
749 if (need_default_vcard!=0) {
750 /* Everyone gets an email address based on their display name */
751 snprintf(buf, sizeof buf, "%s@%s", usbuf->fullname, CtdlGetConfigStr("c_fqdn"));
752 for (i=0; buf[i]; ++i) {
753 if (buf[i] == ' ') buf[i] = '_';
754 }
755 vcard_add_prop(v, "email;internet", buf);
756 }
758 vcard_free(v);
759}
760
761
762/*
763 * Get Valid Screen Names
764 */
765void cmd_gvsn(char *argbuf)
766{
767 if (CtdlAccessCheck(ac_logged_in)) return;
768
769 cprintf("%d valid screen names:\n", LISTING_FOLLOWS);
770 cprintf("%s\n", CC->user.fullname);
771 if ( (!IsEmptyStr(CC->cs_inet_fn)) && (strcasecmp(CC->user.fullname, CC->cs_inet_fn)) ) {
772 cprintf("%s\n", CC->cs_inet_fn);
773 }
774 cprintf("000\n");
775}
776
777
778/*
779 * Get Valid Email Addresses
780 * FIXME this doesn't belong in serv_vcard.c anymore , maybe move it to internet_addressing.c
781 */
782void cmd_gvea(char *argbuf)
783{
784 int num_secondary_emails = 0;
785 int i;
786 char buf[256];
787
788 if (CtdlAccessCheck(ac_logged_in)) return;
789
790 cprintf("%d valid email addresses:\n", LISTING_FOLLOWS);
791 if (!IsEmptyStr(CC->cs_inet_email)) {
792 cprintf("%s\n", CC->cs_inet_email);
793 }
794 if (!IsEmptyStr(CC->cs_inet_other_emails)) {
795 num_secondary_emails = num_tokens(CC->cs_inet_other_emails, '|');
796 for (i=0; i<num_secondary_emails; ++i) {
797 extract_token(buf, CC->cs_inet_other_emails,i,'|',sizeof CC->cs_inet_other_emails);
798 cprintf("%s\n", buf);
799 }
800 }
801 cprintf("000\n");
802}
803
804
805/*
806 * Callback function for cmd_dvca() that hunts for vCard content types
807 * and outputs any email addresses found within.
808 */
809void dvca_mime_callback(char *name, char *filename, char *partnum, char *disp,
810 void *content, char *cbtype, char *cbcharset, size_t length, char *encoding,
811 char *cbid, void *cbuserdata) {
812
813 struct vCard *v;
814 char displayname[256] = "";
815 int displayname_len;
816 char emailaddr[256] = "";
817 int i;
818 int has_commas = 0;
819
820 if ( (strcasecmp(cbtype, "text/vcard")) && (strcasecmp(cbtype, "text/x-vcard")) ) {
821 return;
822 }
823
824 v = vcard_load(content);
825 if (v == NULL) return;
826
827 extract_friendly_name(displayname, sizeof displayname, v);
828 extract_inet_email_addrs(emailaddr, sizeof emailaddr, NULL, 0, v, 0);
829
830 displayname_len = strlen(displayname);
831 for (i=0; i<displayname_len; ++i) {
832 if (displayname[i] == '\"') displayname[i] = ' ';
833 if (displayname[i] == ';') displayname[i] = ',';
834 if (displayname[i] == ',') has_commas = 1;
835 }
836 striplt(displayname);
837
838 cprintf("%s%s%s <%s>\n",
839 (has_commas ? "\"" : ""),
840 displayname,
841 (has_commas ? "\"" : ""),
842 emailaddr
843 );
844
845 vcard_free(v);
846}
847
848
849/*
850 * Back end callback function for cmd_dvca()
851 *
852 * It's basically just passed a list of message numbers, which we're going
853 * to fetch off the disk and then pass along to the MIME parser via another
854 * layer of callback...
855 */
856void dvca_callback(long msgnum, void *userdata) {
857 struct CtdlMessage *msg = NULL;
858
859 msg = CtdlFetchMessage(msgnum, 1);
860 if (msg == NULL) return;
861 mime_parser(CM_RANGE(msg, eMesageText),
862 *dvca_mime_callback, /* callback function */
863 NULL, NULL,
864 NULL, /* user data */
865 0
866 );
867 CM_Free(msg);
868}
869
870
871/*
872 * Dump VCard Addresses
873 */
874void cmd_dvca(char *argbuf)
875{
876 if (CtdlAccessCheck(ac_logged_in)) return;
877
878 cprintf("%d addresses:\n", LISTING_FOLLOWS);
879 CtdlForEachMessage(MSGS_ALL, 0, NULL, NULL, NULL, dvca_callback, NULL);
880 cprintf("000\n");
881}
882
883
884/*
885 * Query Directory
886 */
887void cmd_qdir(char *argbuf) {
888 char citadel_addr[256];
889 char internet_addr[256];
890
891 if (CtdlAccessCheck(ac_logged_in)) return;
892
893 extract_token(internet_addr, argbuf, 0, '|', sizeof internet_addr);
894
895 if (CtdlDirectoryLookup(citadel_addr, internet_addr, sizeof citadel_addr) != 0) {
896 cprintf("%d %s was not found.\n",
897 ERROR + NO_SUCH_USER, internet_addr);
898 return;
899 }
900
901 cprintf("%d %s\n", CIT_OK, citadel_addr);
902}
903
904
905/*
906 * Query Directory, in fact an alias to match postfix tcp auth.
907 */
908void check_get(void) {
909 char internet_addr[256];
910
911 char cmdbuf[SIZ];
912
913 time(&CC->lastcmd);
914 memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
915 if (client_getln(cmdbuf, sizeof cmdbuf) < 1) {
916 syslog(LOG_ERR, "vcard: client disconnected: ending session.");
918 return;
919 }
920 syslog(LOG_INFO, ": %s", cmdbuf);
921 while (strlen(cmdbuf) < 3) strcat(cmdbuf, " ");
922 syslog(LOG_INFO, "[ %s]", cmdbuf);
923
924 if (strncasecmp(cmdbuf, "GET ", 4)==0)
925 {
926 struct recptypes *rcpt;
927 char *argbuf = &cmdbuf[4];
928
929 extract_token(internet_addr, argbuf, 0, '|', sizeof internet_addr);
930 rcpt = validate_recipients(internet_addr, NULL, CHECK_EXIST);
931 if ( (rcpt != NULL) &&
932 (
933 (*rcpt->recp_local != '\0') ||
934 (*rcpt->recp_room != '\0')
935 )
936 ) {
937 cprintf("200 OK %s\n", internet_addr);
938 syslog(LOG_INFO, "vcard: sending 200 OK for the room %s", rcpt->display_recp);
939 }
940 else
941 {
942 cprintf("500 REJECT no one here by that name.\n");
943
944 syslog(LOG_INFO, "vcard: sending 500 REJECT no one here by that name: %s", internet_addr);
945 }
946 if (rcpt != NULL)
947 free_recipients(rcpt);
948 }
949 else {
950 cprintf("500 REJECT invalid Query.\n");
951 syslog(LOG_INFO, "vcard: sending 500 REJECT invalid query: %s", internet_addr);
952 }
953}
954
955
957/* dummy function, we have no greeting in this very simple protocol. */
958}
959
960
961/*
962 * We don't know if the Contacts room exists so we just create it at login
963 */
965{
966 struct ctdlroom qr;
967 visit vbuf;
968
969 /* Create the calendar room if it doesn't already exist */
970 CtdlCreateRoom(USERCONTACTSROOM, 4, "", 0, 1, 0, VIEW_ADDRESSBOOK);
971
972 /* Set expiration policy to manual; otherwise objects will be lost! */
974 syslog(LOG_ERR, "vcard: couldn't get the user CONTACTS room!");
975 return;
976 }
978 qr.QRdefaultview = VIEW_ADDRESSBOOK; /* 2 = address book view */
979 CtdlPutRoomLock(&qr);
980
981 /* Set the view to a calendar view */
982 CtdlGetRelationship(&vbuf, &CC->user, &qr);
983 vbuf.v_view = 2; /* 2 = address book view */
984 CtdlSetRelationship(&vbuf, &CC->user, &qr);
985
986 return;
987}
988
989
990
991
992/*
993 * When a user logs in...
994 */
996 struct vCard *v = NULL;
997
998#ifdef HAVE_LDAP
999 /*
1000 * Is this an LDAP session? If so, copy various LDAP attributes from the directory entry
1001 * into the user's vCard.
1002 */
1003 if ((CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP) || (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP_AD)) {
1004 v = vcard_get_user(&CC->user);
1005 if (v) {
1006 if (Ctdl_LDAP_to_vCard(CC->ldap_dn, v)) {
1007 CC->vcard_updated_by_ldap++; /* Make sure changes make it to the global address book and internet directory, not just the user config. */
1008 syslog(LOG_DEBUG, "vcard: LDAP Detected vcard change");
1009 vcard_write_user(&CC->user, v);
1010 }
1011 }
1012 }
1013#endif
1014
1015 /*
1016 * Extract the user's friendly/screen name
1017 * These are inserted into the session data for various message entry commands to use.
1018 */
1019 v = vcard_get_user(&CC->user);
1020 if (v) {
1021 extract_friendly_name(CC->cs_inet_fn, sizeof CC->cs_inet_fn, v);
1022 vcard_free(v);
1023 }
1024
1025 /*
1026 * Create the user's 'Contacts' room (personal address book) if it doesn't already exist.
1027 */
1029}
1030
1031
1032/*
1033 * Turn an arbitrary RFC822 address into a struct vCard for possible
1034 * inclusion into an address book.
1035 */
1036struct vCard *vcard_new_from_rfc822_addr(char *addr) {
1037 struct vCard *v;
1038 char user[256], node[256], name[256], email[256], n[256], uid[256];
1039 int i;
1040
1041 v = vcard_new();
1042 if (v == NULL) return(NULL);
1043
1044 process_rfc822_addr(addr, user, node, name);
1045 vcard_set_prop(v, "fn", name, 0);
1046
1047 vcard_fn_to_n(n, name, sizeof n);
1048 vcard_set_prop(v, "n", n, 0);
1049
1050 snprintf(email, sizeof email, "%s@%s", user, node);
1051 vcard_set_prop(v, "email;internet", email, 0);
1052
1053 snprintf(uid, sizeof uid, "collected: %s %s@%s", name, user, node);
1054 for (i=0; uid[i]; ++i) {
1055 if (isspace(uid[i])) uid[i] = '_';
1056 uid[i] = tolower(uid[i]);
1057 }
1058 vcard_set_prop(v, "UID", uid, 0);
1059
1060 return(v);
1061}
1062
1063
1064/*
1065 * This is called by store_harvested_addresses() to remove from the
1066 * list any addresses we already have in our address book.
1067 */
1068void strip_addresses_already_have(long msgnum, void *userdata) {
1069 char *collected_addresses;
1070 struct CtdlMessage *msg = NULL;
1071 struct vCard *v;
1072 char *value = NULL;
1073 int i, j;
1074 char addr[256], user[256], node[256], name[256];
1075
1076 collected_addresses = (char *)userdata;
1077
1078 msg = CtdlFetchMessage(msgnum, 1);
1079 if (msg == NULL) return;
1080 v = vcard_load(msg->cm_fields[eMesageText]);
1081 CM_Free(msg);
1082
1083 i = 0;
1084 while (value = vcard_get_prop(v, "email", 1, i++, 0), value != NULL) {
1085
1086 for (j=0; j<num_tokens(collected_addresses, ','); ++j) {
1087 extract_token(addr, collected_addresses, j, ',', sizeof addr);
1088
1089 /* Remove the address if we already have it! */
1090 process_rfc822_addr(addr, user, node, name);
1091 snprintf(addr, sizeof addr, "%s@%s", user, node);
1092 if (!strcasecmp(value, addr)) {
1093 remove_token(collected_addresses, j, ',');
1094 }
1095 }
1096
1097 }
1098
1099 vcard_free(v);
1100}
1101
1102
1103
1104/*
1105 * Back end function for store_harvested_addresses()
1106 */
1108 struct CtdlMessage *vmsg = NULL;
1109 char *ser = NULL;
1110 struct vCard *v = NULL;
1111 char recipient[256];
1112 int i;
1113
1114 /* First remove any addresses we already have in the address book */
1115 CtdlUserGoto(aptr->roomname, 0, 0, NULL, NULL, NULL, NULL);
1116 CtdlForEachMessage(MSGS_ALL, 0, NULL, "[Tt][Ee][Xx][Tt]/.*[Vv][Cc][Aa][Rr][Dd]$", NULL,
1118
1119 if (!IsEmptyStr(aptr->collected_addresses))
1120 for (i=0; i<num_tokens(aptr->collected_addresses, ','); ++i) {
1121
1122 /* Make a vCard out of each address */
1123 extract_token(recipient, aptr->collected_addresses, i, ',', sizeof recipient);
1124 striplt(recipient);
1125 v = vcard_new_from_rfc822_addr(recipient);
1126 if (v != NULL) {
1127 const char *s;
1128 vmsg = malloc(sizeof(struct CtdlMessage));
1129 memset(vmsg, 0, sizeof(struct CtdlMessage));
1131 vmsg->cm_anon_type = MES_NORMAL;
1132 vmsg->cm_format_type = FMT_RFC822;
1133 CM_SetField(vmsg, eAuthor, HKEY("Citadel"));
1134 s = vcard_get_prop(v, "UID", 1, 0, 0);
1135 if (!IsEmptyStr(s)) {
1136 CM_SetField(vmsg, eExclusiveID, s, strlen(s));
1137 }
1138 ser = vcard_serialize(v);
1139 if (ser != NULL) {
1140 StrBuf *buf;
1141 long serlen;
1142
1143 serlen = strlen(ser);
1144 buf = NewStrBufPlain(NULL, serlen + 1024);
1145
1146 StrBufAppendBufPlain(buf, HKEY("Content-type: " VCARD_MIME_TYPE "\r\n\r\n"), 0);
1147 StrBufAppendBufPlain(buf, ser, serlen, 0);
1148 StrBufAppendBufPlain(buf, HKEY("\r\n"), 0);
1149 CM_SetAsFieldSB(vmsg, eMesageText, &buf);
1150 free(ser);
1151 }
1152 vcard_free(v);
1153
1154 syslog(LOG_DEBUG, "vcard: adding contact: %s", recipient);
1155 CtdlSubmitMsg(vmsg, NULL, aptr->roomname);
1156 CM_Free(vmsg);
1157 }
1158 }
1159
1160 free(aptr->roomname);
1162 free(aptr);
1163}
1164
1165
1166/*
1167 * When a user sends a message, we may harvest one or more email addresses
1168 * from the recipient list to be added to the user's address book. But we
1169 * want to do this asynchronously so it doesn't keep the user waiting.
1170 */
1172
1173 struct addresses_to_be_filed *aptr = NULL;
1174
1175 if (atbf == NULL) return;
1176
1178 while (atbf != NULL) {
1179 aptr = atbf;
1180 atbf = atbf->next;
1182 store_this_ha(aptr);
1184 }
1186}
1187
1188
1189/*
1190 * Function to output vCard data as plain text. Nobody uses MSG0 anymore, so
1191 * really this is just so we expose the vCard data to the full text indexer.
1192 */
1193void vcard_fixed_output(char *ptr, int len) {
1194 char *serialized_vcard;
1195 struct vCard *v;
1196 char *key, *value;
1197 int i = 0;
1198
1199 serialized_vcard = malloc(len + 1);
1200 safestrncpy(serialized_vcard, ptr, len+1);
1201 v = vcard_load(serialized_vcard);
1202 free(serialized_vcard);
1203
1204 i = 0;
1205 while (key = vcard_get_prop(v, "", 0, i, 1), key != NULL) {
1206 value = vcard_get_prop(v, "", 0, i++, 0);
1207 cprintf("%s\n", value);
1208 }
1209
1210 vcard_free(v);
1211}
1212
1213
1214const char *CitadelServiceDICT_TCP="DICT_TCP";
1215
1217{
1218 struct ctdlroom qr;
1219
1220 if (!threading)
1221 {
1225 CtdlRegisterProtoHook(cmd_regi, "REGI", "Enter registration info");
1226 CtdlRegisterProtoHook(cmd_greg, "GREG", "Get registration info");
1227 CtdlRegisterProtoHook(cmd_qdir, "QDIR", "Query Directory");
1228 CtdlRegisterProtoHook(cmd_gvsn, "GVSN", "Get Valid Screen Names");
1229 CtdlRegisterProtoHook(cmd_gvea, "GVEA", "Get Valid Email Addresses");
1230 CtdlRegisterProtoHook(cmd_dvca, "DVCA", "Dump VCard Addresses");
1235
1236 /* Create the Global Address Book room if necessary */
1237 CtdlCreateRoom(ADDRESS_BOOK_ROOM, 3, "", 0, 1, 0, VIEW_ADDRESSBOOK);
1238
1239 /* Set expiration policy to manual; otherwise objects will be lost! */
1242 qr.QRdefaultview = VIEW_ADDRESSBOOK; // 2 = address book view
1243 CtdlPutRoomLock(&qr);
1244 }
1245
1246 /* for postfix tcpdict */
1247 CtdlRegisterServiceHook(CtdlGetConfigInt("c_pftcpdict_port"), // Postfix
1248 NULL,
1250 check_get,
1251 NULL,
1253 );
1254 }
1255
1256 /* return our module name for the log */
1257 return "vcard";
1258}
#define ROOMNAMELEN
Definition: citadel.h:56
#define AUTHMODE_HOST
Definition: citadel.h:174
#define MES_NORMAL
Definition: citadel.h:135
#define AUTHMODE_LDAP
Definition: citadel.h:175
#define MM_VALID
Definition: citadel.h:101
#define EXPIRE_MANUAL
Definition: citadel.h:70
#define USERNAME_SIZE
Definition: citadel.h:57
#define AUTHMODE_LDAP_AD
Definition: citadel.h:176
int Ctdl_LDAP_to_vCard(char *ldap_dn, struct vCard *v)
int CtdlTryUserLDAP(char *username, char *found_dn, int found_dn_size, char *fullname, int fullname_size, uid_t *found_uid)
char * CtdlGetConfigStr(char *key)
Definition: config.c:393
int CtdlGetConfigInt(char *key)
Definition: config.c:426
void CtdlSetConfigInt(char *key, int value)
Definition: config.c:359
#define CC
Definition: context.h:140
int CtdlAccessCheck(int)
Definition: user_ops.c:389
void CtdlGetRelationship(visit *vbuf, struct ctdluser *rel_user, struct ctdlroom *rel_room)
Definition: user_ops.c:321
void CtdlMailboxName(char *buf, size_t n, const struct ctdluser *who, const char *prefix)
Definition: user_ops.c:351
int CtdlLockGetCurrentUser(void)
Definition: user_ops.c:103
int CtdlGetRoom(struct ctdlroom *qrbuf, const char *room_name)
Definition: room_ops.c:342
int CtdlGetUserByNumber(struct ctdluser *usbuf, long number)
Definition: user_ops.c:462
void CtdlRegisterServiceHook(int tcp_port, char *sockpath, void(*h_greeting_function)(void), void(*h_command_function)(void), void(*h_async_function)(void), const char *ServiceName)
void CtdlPutCurrentUserLock(void)
Definition: user_ops.c:138
void CtdlRegisterSessionHook(void(*fcn_ptr)(void), int EventType, int Priority)
void CtdlRegisterFixedOutputHook(char *content_type, void(*output_function)(char *supplied_data, int len))
void CtdlRegisterMessageHook(int(*handler)(struct CtdlMessage *, struct recptypes *), int EventType)
int CtdlGetRoomLock(struct ctdlroom *qrbuf, const char *room_name)
Definition: room_ops.c:387
#define PRIO_LOGIN
Definition: ctdl_module.h:83
#define NODENAME
Definition: ctdl_module.h:257
void CtdlSetRelationship(visit *newvisit, struct ctdluser *rel_user, struct ctdlroom *rel_room)
Definition: user_ops.c:306
#define PRIO_CLEANUP
Definition: ctdl_module.h:75
@ ac_logged_in
Definition: ctdl_module.h:244
unsigned CtdlCreateRoom(char *new_room_name, int new_room_type, char *new_room_pass, int new_room_floor, int really_create, int avoid_access, int new_room_view)
Definition: room_ops.c:1136
void CtdlUserGoto(char *where, int display_result, int transiently, int *msgs, int *new, long *oldest, long *newest)
Definition: room_ops.c:702
int CtdlGetUser(struct ctdluser *usbuf, char *name)
Definition: user_ops.c:77
void CtdlPutRoomLock(struct ctdlroom *qrbuf)
Definition: room_ops.c:444
void CtdlRegisterUserHook(void(*fcn_ptr)(struct ctdluser *), int EventType)
void CtdlRegisterProtoHook(void(*handler)(char *), char *cmd, char *desc)
#define CTDL_MODULE_INIT(module_name)
Definition: ctdl_module.h:50
struct recptypes * validate_recipients(char *supplied_recipients, const char *RemoteIdentifier, int Flags)
void free_recipients(struct recptypes *valid)
int IsDirectory(char *addr, int allow_masq_domains)
void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name)
int CtdlDirectoryLookup(char *target, char *internet_addr, size_t targbuflen)
#define CIT_OK
Definition: ipcdef.h:6
#define ILLEGAL_VALUE
Definition: ipcdef.h:16
#define US_REGIS
Definition: ipcdef.h:70
#define LISTING_FOLLOWS
Definition: ipcdef.h:5
#define HIGHER_ACCESS_REQUIRED
Definition: ipcdef.h:23
#define QR_MAILBOX
Definition: ipcdef.h:53
#define NOT_LOGGED_IN
Definition: ipcdef.h:17
#define ERROR
Definition: ipcdef.h:9
#define SEND_LISTING
Definition: ipcdef.h:8
#define US_NEEDVALID
Definition: ipcdef.h:61
#define NO_SUCH_USER
Definition: ipcdef.h:29
void CM_Free(struct CtdlMessage *msg)
Definition: msgbase.c:310
void CM_CopyField(struct CtdlMessage *Msg, eMsgField WhichToPutTo, eMsgField WhichtToCopy)
Definition: msgbase.c:197
int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int do_repl_check, struct CtdlMessage *supplied_msg)
Definition: msgbase.c:2399
void CM_FlushField(struct CtdlMessage *Msg, eMsgField which)
Definition: msgbase.c:176
int CtdlForEachMessage(int mode, long ref, char *search_string, char *content_type, struct CtdlMessage *compare, ForEachMsgCallback CallBack, void *userdata)
Definition: msgbase.c:626
struct CtdlMessage * CtdlFetchMessage(long msgnum, int with_body)
Definition: msgbase.c:1135
long CtdlWriteObject(char *req_room, char *content_type, char *raw_message, off_t raw_length, struct ctdluser *is_mailbox, int is_binary, unsigned int flags)
Definition: msgbase.c:3482
int CM_IsEmpty(struct CtdlMessage *Msg, eMsgField which)
Definition: msgbase.c:137
int CtdlDeleteMessages(const char *room_name, long *dmsgnums, int num_dmsgnums, char *content_type)
Definition: msgbase.c:3240
long CtdlSubmitMsg(struct CtdlMessage *msg, struct recptypes *recps, const char *force)
Definition: msgbase.c:2603
void CM_SetField(struct CtdlMessage *Msg, eMsgField which, const char *buf, long length)
Definition: msgbase.c:142
void CM_SetAsFieldSB(struct CtdlMessage *Msg, eMsgField which, StrBuf **buf)
Definition: msgbase.c:258
struct addresses_to_be_filed * atbf
Definition: msgbase.c:33
#define CM_RANGE(Message, Which)
Definition: msgbase.h:127
@ MSGS_ALL
Definition: msgbase.h:6
@ MSGS_LAST
Definition: msgbase.h:10
void * malloc(size_t)
void free(void *)
@ CHECK_EXIST
Definition: room_ops.h:15
visit vbuf
Definition: serv_migrate.c:503
struct ctdluser usbuf
Definition: serv_migrate.c:496
void cmd_gvea(char *argbuf)
Definition: serv_vcard.c:782
void cmd_gvsn(char *argbuf)
Definition: serv_vcard.c:765
void vcard_newuser(struct ctdluser *usbuf)
Definition: serv_vcard.c:686
#define VCARD_MIME_TYPE
Definition: serv_vcard.c:29
void vcard_CtdlCreateRoom(void)
Definition: serv_vcard.c:964
void vcard_write_user(struct ctdluser *u, struct vCard *v)
Definition: serv_vcard.c:515
void strip_addresses_already_have(long msgnum, void *userdata)
Definition: serv_vcard.c:1068
void check_get(void)
Definition: serv_vcard.c:908
void set_mm_valid(void)
Definition: serv_vcard.c:64
#define _(a)
TODO: gettext!
Definition: serv_vcard.c:76
void extract_friendly_name(char *namebuf, size_t namebuf_len, struct vCard *v)
Definition: serv_vcard.c:140
#define VCARD_EXT_FORMAT
Definition: serv_vcard.c:22
int vcard_upload_aftersave(struct CtdlMessage *msg, struct recptypes *recp)
Definition: serv_vcard.c:361
void store_this_ha(struct addresses_to_be_filed *aptr)
Definition: serv_vcard.c:1107
void cmd_qdir(char *argbuf)
Definition: serv_vcard.c:887
void vcard_extract_vcard(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, char *encoding, char *cbid, void *cbuserdata)
Definition: serv_vcard.c:158
void dvca_callback(long msgnum, void *userdata)
Definition: serv_vcard.c:856
void store_harvested_addresses(void)
Definition: serv_vcard.c:1171
void vcard_fixed_output(char *ptr, int len)
Definition: serv_vcard.c:1193
void vcard_session_login_hook(void)
Definition: serv_vcard.c:995
int vcard_upload_beforesave(struct CtdlMessage *msg, struct recptypes *recp)
Definition: serv_vcard.c:182
void cmd_greg(char *argbuf)
Definition: serv_vcard.c:613
struct vCard * vcard_get_user(struct ctdluser *u)
Definition: serv_vcard.c:477
void vcard_gu_backend(long supplied_msgnum, void *userdata)
Definition: serv_vcard.c:465
void dvca_mime_callback(char *name, char *filename, char *partnum, char *disp, void *content, char *cbtype, char *cbcharset, size_t length, char *encoding, char *cbid, void *cbuserdata)
Definition: serv_vcard.c:809
const char * CitadelServiceDICT_TCP
Definition: serv_vcard.c:1214
struct vCard * vcard_new_from_rfc822_addr(char *addr)
Definition: serv_vcard.c:1036
void cmd_regi(char *argbuf)
Definition: serv_vcard.c:548
void cmd_dvca(char *argbuf)
Definition: serv_vcard.c:874
void check_get_greeting(void)
Definition: serv_vcard.c:956
void extract_inet_email_addrs(char *emailaddrbuf, size_t emailaddrbuf_len, char *secemailaddrbuf, size_t secemailaddrbuf_len, struct vCard *v, int local_addrs_only)
Definition: serv_vcard.c:82
#define CTDLMESSAGE_MAGIC
Definition: server.h:42
@ eExclusiveID
Definition: server.h:309
@ eMesageText
Definition: server.h:315
@ eVltMsgNum
Definition: server.h:327
@ eAuthor
Definition: server.h:307
@ eMsgSubject
Definition: server.h:320
#define EVT_NEWUSER
Definition: server.h:229
#define EVT_AFTERSAVE
Definition: server.h:232
#define FMT_RFC822
Definition: server.h:178
#define EVT_LOGIN
Definition: server.h:214
@ KILLME_CLIENT_DISCONNECTED
Definition: server.h:90
#define EVT_TIMER
Definition: server.h:224
@ S_CONTROL
Definition: server.h:140
@ S_ATBF
Definition: server.h:148
#define EVT_BEFORESAVE
Definition: server.h:231
int snprintf(char *buf, size_t max, const char *fmt,...)
Definition: snprintf.c:69
int cm_magic
Definition: server.h:34
char cm_anon_type
Definition: server.h:35
char * cm_fields[256]
Definition: server.h:37
char cm_format_type
Definition: server.h:36
int expire_mode
Definition: citadel.h:65
int v_view
Definition: server.h:253
char * collected_addresses
Definition: msgbase.h:71
struct addresses_to_be_filed * next
Definition: msgbase.h:69
struct ExpirePolicy QRep
Definition: citadel.h:118
int QRdefaultview
Definition: citadel.h:122
cit_uint8_t axlevel
Definition: citadel.h:86
char fullname[64]
Definition: citadel.h:90
uid_t uid
Definition: citadel.h:81
long usernum
Definition: citadel.h:87
char password[32]
Definition: citadel.h:82
char * recp_room
Definition: server.h:57
char * display_recp
Definition: server.h:59
char * recp_local
Definition: server.h:55
#define USERCONFIGROOM
Definition: sysconfig.h:64
#define ADDRESS_BOOK_ROOM
Definition: sysconfig.h:74
#define USERCONTACTSROOM
Definition: sysconfig.h:67
#define SIZ
Definition: sysconfig.h:33
void cprintf(const char *format,...)
Definition: sysdep.c:381
int client_getln(char *buf, int bufsize)
Definition: sysdep.c:548
void unbuffer_output(void)
Definition: sysdep.c:276
void begin_critical_section(int which_one)
Definition: threads.c:67
void end_critical_section(int which_one)
Definition: threads.c:85