Began removing $Id$ tags. This will be an ongoing process.
[citadel.git] / citadel / control.c
1 /*
2  * This module handles states which are global to the entire server.
3  *
4  * Copyright (c) 1987-2010 by the citadel.org team
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 3 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "sysdep.h"
22 #include <stdlib.h>
23 #include <unistd.h>
24 #include <stdio.h>
25 #include <fcntl.h>
26 #include <signal.h>
27
28 #if TIME_WITH_SYS_TIME
29 # include <sys/time.h>
30 # include <time.h>
31 #else
32 # if HAVE_SYS_TIME_H
33 #  include <sys/time.h>
34 # else
35 #  include <time.h>
36 # endif
37 #endif
38
39 #include <ctype.h>
40 #include <string.h>
41 #include <errno.h>
42 #include <limits.h>
43 #include <sys/types.h>
44 #include <sys/file.h>
45 #include <sys/stat.h>
46 #include <libcitadel.h>
47 #include "citadel.h"
48 #include "server.h"
49 #include "control.h"
50 #include "sysdep_decls.h"
51 #include "support.h"
52 #include "config.h"
53 #include "msgbase.h"
54 #include "citserver.h"
55 #include "room_ops.h"
56 #include "user_ops.h"
57 #include "database.h"
58 #include "threads.h"
59
60 #ifndef HAVE_SNPRINTF
61 #include "snprintf.h"
62 #endif
63
64 #include "ctdl_module.h"
65
66 struct CitControl CitControl;
67 extern struct config config;
68 FILE *control_fp = NULL;
69 long control_highest_user = 0;
70
71
72 /*
73  * lock_control  -  acquire a lock on the control record file.
74  *                  This keeps multiple citservers from running concurrently.
75  */
76 void lock_control(void)
77 {
78 #if defined(LOCK_EX) && defined(LOCK_NB)
79         if (flock(fileno(control_fp), (LOCK_EX | LOCK_NB))) {
80                 CtdlLogPrintf(CTDL_EMERG, "citserver: unable to lock %s.\n", file_citadel_control);
81                 CtdlLogPrintf(CTDL_EMERG, "Is another citserver already running?\n");
82                 exit(CTDLEXIT_CONTROL);
83         }
84 #endif
85 }
86
87 /*
88  * callback to get highest room number when rebuilding control file
89  */
90 void control_find_highest(struct ctdlroom *qrbuf, void *data)
91 {
92         struct ctdlroom room;
93         struct cdbdata *cdbfr;
94         long *msglist;
95         int num_msgs=0;
96         int c;
97         int room_fixed = 0;
98         int message_fixed = 0;
99         
100         if (qrbuf->QRnumber > CitControl.MMnextroom)
101         {
102                 CitControl.MMnextroom = qrbuf->QRnumber;
103                 room_fixed = 1;
104         }
105                 
106         CtdlGetRoom (&room, qrbuf->QRname);
107         
108         /* Load the message list */
109         cdbfr = cdb_fetch(CDB_MSGLISTS, &room.QRnumber, sizeof(long));
110         if (cdbfr != NULL) {
111                 msglist = (long *) cdbfr->ptr;
112                 num_msgs = cdbfr->len / sizeof(long);
113         } else {
114                 return; /* No messages at all?  No further action. */
115         }
116
117         if (num_msgs>0)
118         {
119                 for (c=0; c<num_msgs; c++)
120                 {
121                         if (msglist[c] > CitControl.MMhighest)
122                         {
123                                 CitControl.MMhighest = msglist[c];
124                                 message_fixed = 1;
125                         }
126                 }
127         }
128         cdb_free(cdbfr);
129         if (room_fixed)
130                 CtdlLogPrintf(CTDL_INFO, "Control record checking....Fixed room counter\n");
131         if (message_fixed)
132                 CtdlLogPrintf(CTDL_INFO, "Control record checking....Fixed message count\n");
133         return;
134 }
135
136
137 /*
138  * Callback to get highest user number.
139  */
140  
141 void control_find_user (struct ctdluser *EachUser, void *out_data)
142 {
143         int user_fixed = 0;
144         
145         if (EachUser->usernum > CitControl.MMnextuser)
146         {
147                 CitControl.MMnextuser = EachUser->usernum;
148                 user_fixed = 1;
149         }
150         if(user_fixed)
151                 CtdlLogPrintf(CTDL_INFO, "Control record checking....Fixed user count\n");
152 }
153
154
155 /*
156  * get_control  -  read the control record into memory.
157  */
158 void get_control(void)
159 {
160         static int already_have_control = 0;
161         int rv = 0;
162
163         /*
164          * If we already have the control record in memory, there's no point
165          * in reading it from disk again.
166          */
167         if (already_have_control) return;
168
169         /* Zero it out.  If the control record on disk is missing or short,
170          * the system functions with all control record fields initialized
171          * to zero.
172          */
173         memset(&CitControl, 0, sizeof(struct CitControl));
174         if (control_fp == NULL) {
175                 control_fp = fopen(file_citadel_control, "rb+");
176                 if (control_fp != NULL) {
177                         lock_control();
178                         rv = fchown(fileno(control_fp), config.c_ctdluid, -1);
179                         rv = fchmod(fileno(control_fp), S_IRUSR|S_IWUSR);
180                 }
181         }
182         if (control_fp == NULL) {
183                 control_fp = fopen(file_citadel_control, "wb+");
184                 if (control_fp != NULL) {
185                         lock_control();
186                         rv = fchown(fileno(control_fp), config.c_ctdluid, -1);
187                         rv = fchmod(fileno(control_fp), S_IRUSR|S_IWUSR);
188                         memset(&CitControl, 0, sizeof(struct CitControl));
189                         rv = fwrite(&CitControl, sizeof(struct CitControl), 1, control_fp);
190                         rewind(control_fp);
191                 }
192         }
193         if (control_fp == NULL) {
194                 CtdlLogPrintf(CTDL_ALERT, "ERROR opening %s: %s\n", file_citadel_control, strerror(errno));
195                 return;
196         }
197
198         rewind(control_fp);
199         rv = fread(&CitControl, sizeof(struct CitControl), 1, control_fp);
200         already_have_control = 1;
201         rv = chown(file_citadel_control, config.c_ctdluid, (-1));
202         
203 }
204
205 /*
206  * put_control  -  write the control record to disk.
207  */
208 void put_control(void)
209 {
210         int rv = 0;
211
212         if (control_fp != NULL) {
213                 rewind(control_fp);
214                 rv = fwrite(&CitControl, sizeof(struct CitControl), 1, control_fp);
215                 fflush(control_fp);
216         }
217 }
218
219
220 /*
221  * check_control   -  check the control record has sensible values for message, user and room numbers
222  */
223 void check_control(void)
224 {
225         CtdlLogPrintf(CTDL_INFO, "Checking/re-building control record\n");
226         get_control();
227         // Find highest room number and message number.
228         CtdlForEachRoom(control_find_highest, NULL);
229         ForEachUser(control_find_user, NULL);
230         put_control();
231 }
232
233
234 /*
235  * release_control - close our fd on exit
236  */
237 void release_control(void)
238 {
239         if (control_fp != NULL) {
240                 fclose(control_fp);
241         }
242         control_fp = NULL;
243 }
244
245 /*
246  * get_new_message_number()  -  Obtain a new, unique ID to be used for a message.
247  */
248 long get_new_message_number(void)
249 {
250         long retval = 0L;
251         begin_critical_section(S_CONTROL);
252         get_control();
253         retval = ++CitControl.MMhighest;
254         put_control();
255         end_critical_section(S_CONTROL);
256         return(retval);
257 }
258
259
260 /*
261  * CtdlGetCurrentMessageNumber()  -  Obtain the current highest message number in the system
262  * This provides a quick way to initialise a variable that might be used to indicate
263  * messages that should not be processed. EG. a new Sieve script will use this
264  * to record determine that messages older than this should not be processed.
265  */
266 long CtdlGetCurrentMessageNumber(void)
267 {
268         long retval = 0L;
269         begin_critical_section(S_CONTROL);
270         get_control();
271         retval = CitControl.MMhighest;
272         end_critical_section(S_CONTROL);
273         return(retval);
274 }
275
276
277 /*
278  * get_new_user_number()  -  Obtain a new, unique ID to be used for a user.
279  */
280 long get_new_user_number(void)
281 {
282         long retval = 0L;
283         begin_critical_section(S_CONTROL);
284         get_control();
285         retval = ++CitControl.MMnextuser;
286         put_control();
287         end_critical_section(S_CONTROL);
288         return(retval);
289 }
290
291
292
293 /*
294  * get_new_room_number()  -  Obtain a new, unique ID to be used for a room.
295  */
296 long get_new_room_number(void)
297 {
298         long retval = 0L;
299         begin_critical_section(S_CONTROL);
300         get_control();
301         retval = ++CitControl.MMnextroom;
302         put_control();
303         end_critical_section(S_CONTROL);
304         return(retval);
305 }
306
307
308
309 /* 
310  * Get or set global configuration options
311  *
312  * IF YOU ADD OR CHANGE FIELDS HERE, YOU *MUST* DOCUMENT YOUR CHANGES AT:
313  * http://www.citadel.org/doku.php/documentation:appproto:system_config
314  *
315  */
316 void cmd_conf(char *argbuf)
317 {
318         char cmd[16];
319         char buf[256];
320         int a;
321         char *confptr;
322         char confname[128];
323
324         if (CtdlAccessCheck(ac_aide)) return;
325
326         extract_token(cmd, argbuf, 0, '|', sizeof cmd);
327         if (!strcasecmp(cmd, "GET")) {
328                 cprintf("%d Configuration...\n", LISTING_FOLLOWS);
329                 cprintf("%s\n", config.c_nodename);
330                 cprintf("%s\n", config.c_fqdn);
331                 cprintf("%s\n", config.c_humannode);
332                 cprintf("%s\n", config.c_phonenum);
333                 cprintf("%d\n", config.c_creataide);
334                 cprintf("%d\n", config.c_sleeping);
335                 cprintf("%d\n", config.c_initax);
336                 cprintf("%d\n", config.c_regiscall);
337                 cprintf("%d\n", config.c_twitdetect);
338                 cprintf("%s\n", config.c_twitroom);
339                 cprintf("%s\n", config.c_moreprompt);
340                 cprintf("%d\n", config.c_restrict);
341                 cprintf("%s\n", config.c_site_location);
342                 cprintf("%s\n", config.c_sysadm);
343                 cprintf("%d\n", config.c_maxsessions);
344                 cprintf("xxx\n"); /* placeholder -- field no longer in use */
345                 cprintf("%d\n", config.c_userpurge);
346                 cprintf("%d\n", config.c_roompurge);
347                 cprintf("%s\n", config.c_logpages);
348                 cprintf("%d\n", config.c_createax);
349                 cprintf("%ld\n", config.c_maxmsglen);
350                 cprintf("%d\n", config.c_min_workers);
351                 cprintf("%d\n", config.c_max_workers);
352                 cprintf("%d\n", config.c_pop3_port);
353                 cprintf("%d\n", config.c_smtp_port);
354                 cprintf("%d\n", config.c_rfc822_strict_from);
355                 cprintf("%d\n", config.c_aide_zap);
356                 cprintf("%d\n", config.c_imap_port);
357                 cprintf("%ld\n", config.c_net_freq);
358                 cprintf("%d\n", config.c_disable_newu);
359                 cprintf("1\n"); /* niu */
360                 cprintf("%d\n", config.c_purge_hour);
361 #ifdef HAVE_LDAP
362                 cprintf("%s\n", config.c_ldap_host);
363                 cprintf("%d\n", config.c_ldap_port);
364                 cprintf("%s\n", config.c_ldap_base_dn);
365                 cprintf("%s\n", config.c_ldap_bind_dn);
366                 cprintf("%s\n", config.c_ldap_bind_pw);
367 #else
368                 cprintf("\n");
369                 cprintf("0\n");
370                 cprintf("\n");
371                 cprintf("\n");
372                 cprintf("\n");
373 #endif
374                 cprintf("%s\n", config.c_ip_addr);
375                 cprintf("%d\n", config.c_msa_port);
376                 cprintf("%d\n", config.c_imaps_port);
377                 cprintf("%d\n", config.c_pop3s_port);
378                 cprintf("%d\n", config.c_smtps_port);
379                 cprintf("%d\n", config.c_enable_fulltext);
380                 cprintf("%d\n", config.c_auto_cull);
381                 cprintf("%d\n", config.c_instant_expunge);
382                 cprintf("%d\n", config.c_allow_spoofing);
383                 cprintf("%d\n", config.c_journal_email);
384                 cprintf("%d\n", config.c_journal_pubmsgs);
385                 cprintf("%s\n", config.c_journal_dest);
386                 cprintf("%s\n", config.c_default_cal_zone);
387                 cprintf("%d\n", config.c_pftcpdict_port);
388                 cprintf("%d\n", config.c_managesieve_port);
389                 cprintf("%d\n", config.c_auth_mode);
390                 cprintf("%s\n", config.c_funambol_host);
391                 cprintf("%d\n", config.c_funambol_port);
392                 cprintf("%s\n", config.c_funambol_source);
393                 cprintf("%s\n", config.c_funambol_auth);
394                 cprintf("%d\n", config.c_rbl_at_greeting);
395                 cprintf("%s\n", config.c_master_user);
396                 cprintf("%s\n", config.c_master_pass);
397                 cprintf("%s\n", config.c_pager_program);
398                 cprintf("%d\n", config.c_imap_keep_from);
399                 cprintf("%d\n", config.c_xmpp_c2s_port);
400                 cprintf("%d\n", config.c_xmpp_s2s_port);
401                 cprintf("%ld\n", config.c_pop3_fetch);
402                 cprintf("%ld\n", config.c_pop3_fastest);
403                 cprintf("%d\n", config.c_spam_flag_only);
404                 cprintf("%d\n", config.c_guest_logins);
405                 cprintf("000\n");
406         }
407
408         else if (!strcasecmp(cmd, "SET")) {
409                 unbuffer_output();
410                 cprintf("%d Send configuration...\n", SEND_LISTING);
411                 a = 0;
412                 while (client_getln(buf, sizeof buf) >= 0 && strcmp(buf, "000")) {
413                         switch (a) {
414                         case 0:
415                                 safestrncpy(config.c_nodename, buf,
416                                             sizeof config.c_nodename);
417                                 break;
418                         case 1:
419                                 safestrncpy(config.c_fqdn, buf,
420                                             sizeof config.c_fqdn);
421                                 break;
422                         case 2:
423                                 safestrncpy(config.c_humannode, buf,
424                                             sizeof config.c_humannode);
425                                 break;
426                         case 3:
427                                 safestrncpy(config.c_phonenum, buf,
428                                             sizeof config.c_phonenum);
429                                 break;
430                         case 4:
431                                 config.c_creataide = atoi(buf);
432                                 break;
433                         case 5:
434                                 config.c_sleeping = atoi(buf);
435                                 break;
436                         case 6:
437                                 config.c_initax = atoi(buf);
438                                 if (config.c_initax < 1)
439                                         config.c_initax = 1;
440                                 if (config.c_initax > 6)
441                                         config.c_initax = 6;
442                                 break;
443                         case 7:
444                                 config.c_regiscall = atoi(buf);
445                                 if (config.c_regiscall != 0)
446                                         config.c_regiscall = 1;
447                                 break;
448                         case 8:
449                                 config.c_twitdetect = atoi(buf);
450                                 if (config.c_twitdetect != 0)
451                                         config.c_twitdetect = 1;
452                                 break;
453                         case 9:
454                                 safestrncpy(config.c_twitroom, buf,
455                                             sizeof config.c_twitroom);
456                                 break;
457                         case 10:
458                                 safestrncpy(config.c_moreprompt, buf,
459                                             sizeof config.c_moreprompt);
460                                 break;
461                         case 11:
462                                 config.c_restrict = atoi(buf);
463                                 if (config.c_restrict != 0)
464                                         config.c_restrict = 1;
465                                 break;
466                         case 12:
467                                 safestrncpy(config.c_site_location, buf,
468                                             sizeof config.c_site_location);
469                                 break;
470                         case 13:
471                                 safestrncpy(config.c_sysadm, buf,
472                                             sizeof config.c_sysadm);
473                                 break;
474                         case 14:
475                                 config.c_maxsessions = atoi(buf);
476                                 if (config.c_maxsessions < 0)
477                                         config.c_maxsessions = 0;
478                                 break;
479                         case 15:
480                                 /* placeholder -- field no longer in use */
481                                 break;
482                         case 16:
483                                 config.c_userpurge = atoi(buf);
484                                 break;
485                         case 17:
486                                 config.c_roompurge = atoi(buf);
487                                 break;
488                         case 18:
489                                 safestrncpy(config.c_logpages, buf,
490                                             sizeof config.c_logpages);
491                                 break;
492                         case 19:
493                                 config.c_createax = atoi(buf);
494                                 if (config.c_createax < 1)
495                                         config.c_createax = 1;
496                                 if (config.c_createax > 6)
497                                         config.c_createax = 6;
498                                 break;
499                         case 20:
500                                 if (atoi(buf) >= 8192)
501                                         config.c_maxmsglen = atoi(buf);
502                                 break;
503                         case 21:
504                                 if (atoi(buf) >= 2)
505                                         config.c_min_workers = atoi(buf);
506                         case 22:
507                                 if (atoi(buf) >= config.c_min_workers)
508                                         config.c_max_workers = atoi(buf);
509                         case 23:
510                                 config.c_pop3_port = atoi(buf);
511                                 break;
512                         case 24:
513                                 config.c_smtp_port = atoi(buf);
514                                 break;
515                         case 25:
516                                 config.c_rfc822_strict_from = atoi(buf);
517                                 break;
518                         case 26:
519                                 config.c_aide_zap = atoi(buf);
520                                 if (config.c_aide_zap != 0)
521                                         config.c_aide_zap = 1;
522                                 break;
523                         case 27:
524                                 config.c_imap_port = atoi(buf);
525                                 break;
526                         case 28:
527                                 config.c_net_freq = atol(buf);
528                                 break;
529                         case 29:
530                                 config.c_disable_newu = atoi(buf);
531                                 if (config.c_disable_newu != 0)
532                                         config.c_disable_newu = 1;
533                                 break;
534                         case 30:
535                                 /* niu */
536                                 break;
537                         case 31:
538                                 if ((config.c_purge_hour >= 0)
539                                    && (config.c_purge_hour <= 23)) {
540                                         config.c_purge_hour = atoi(buf);
541                                 }
542                                 break;
543 #ifdef HAVE_LDAP
544                         case 32:
545                                 safestrncpy(config.c_ldap_host, buf,
546                                             sizeof config.c_ldap_host);
547                                 break;
548                         case 33:
549                                 config.c_ldap_port = atoi(buf);
550                                 break;
551                         case 34:
552                                 safestrncpy(config.c_ldap_base_dn, buf,
553                                             sizeof config.c_ldap_base_dn);
554                                 break;
555                         case 35:
556                                 safestrncpy(config.c_ldap_bind_dn, buf,
557                                             sizeof config.c_ldap_bind_dn);
558                                 break;
559                         case 36:
560                                 safestrncpy(config.c_ldap_bind_pw, buf,
561                                             sizeof config.c_ldap_bind_pw);
562                                 break;
563 #endif
564                         case 37:
565                                 safestrncpy(config.c_ip_addr, buf,
566                                                 sizeof config.c_ip_addr);
567                         case 38:
568                                 config.c_msa_port = atoi(buf);
569                                 break;
570                         case 39:
571                                 config.c_imaps_port = atoi(buf);
572                                 break;
573                         case 40:
574                                 config.c_pop3s_port = atoi(buf);
575                                 break;
576                         case 41:
577                                 config.c_smtps_port = atoi(buf);
578                                 break;
579                         case 42:
580                                 config.c_enable_fulltext = atoi(buf);
581                                 break;
582                         case 43:
583                                 config.c_auto_cull = atoi(buf);
584                                 break;
585                         case 44:
586                                 config.c_instant_expunge = atoi(buf);
587                                 break;
588                         case 45:
589                                 config.c_allow_spoofing = atoi(buf);
590                                 break;
591                         case 46:
592                                 config.c_journal_email = atoi(buf);
593                                 break;
594                         case 47:
595                                 config.c_journal_pubmsgs = atoi(buf);
596                                 break;
597                         case 48:
598                                 safestrncpy(config.c_journal_dest, buf,
599                                                 sizeof config.c_journal_dest);
600                         case 49:
601                                 safestrncpy(config.c_default_cal_zone, buf,
602                                                 sizeof config.c_default_cal_zone);
603                                 break;
604                         case 50:
605                                 config.c_pftcpdict_port = atoi(buf);
606                                 break;
607                         case 51:
608                                 config.c_managesieve_port = atoi(buf);
609                                 break;
610                         case 52:
611                                 config.c_auth_mode = atoi(buf);
612                         case 53:
613                                 safestrncpy(config.c_funambol_host, buf,
614                                         sizeof config.c_funambol_host);
615                                 break;
616                         case 54:
617                                 config.c_funambol_port = atoi(buf);
618                                 break;
619                         case 55:
620                                 safestrncpy(config.c_funambol_source,
621                                         buf, 
622                                         sizeof config.c_funambol_source);
623                                 break;
624                         case 56:
625                                 safestrncpy(config.c_funambol_auth,
626                                         buf,
627                                         sizeof config.c_funambol_auth);
628                                 break;
629                         case 57:
630                                 config.c_rbl_at_greeting = atoi(buf);
631                                 break;
632                         case 58:
633                                 safestrncpy(config.c_master_user, buf, sizeof config.c_master_user);
634                                 break;
635                         case 59:
636                                 safestrncpy(config.c_master_pass, buf, sizeof config.c_master_pass);
637                                 break;
638                         case 60:
639                                 safestrncpy(config.c_pager_program,
640                                         buf,
641                                         sizeof config.c_pager_program);
642                                 break;
643                         case 61:
644                                 config.c_imap_keep_from = atoi(buf);
645                                 break;
646                         case 62:
647                                 config.c_xmpp_c2s_port = atoi(buf);
648                                 break;
649                         case 63:
650                                 config.c_xmpp_s2s_port = atoi(buf);
651                                 break;
652                         case 64:
653                                 config.c_pop3_fetch = atol(buf);
654                                 break;
655                         case 65:
656                                 config.c_pop3_fastest = atol(buf);
657                                 break;
658                         case 66:
659                                 config.c_spam_flag_only = atoi(buf);
660                                 break;
661                         case 67:
662                                 config.c_guest_logins = atoi(buf);
663                                 break;
664                         }
665                         ++a;
666                 }
667                 put_config();
668                 snprintf(buf, sizeof buf,
669                          "The global system configuration has been edited by %s.\n",
670                          CC->curr_user);
671                 CtdlAideMessage(buf,"Citadel Configuration Manager Message");
672
673                 if (!IsEmptyStr(config.c_logpages))
674                         CtdlCreateRoom(config.c_logpages, 3, "", 0, 1, 1, VIEW_BBS);
675
676                 /* If full text indexing has been disabled, invalidate the
677                  * index so it doesn't try to use it later.
678                  */
679                 if (config.c_enable_fulltext == 0) {
680                         CitControl.fulltext_wordbreaker = 0;
681                         put_control();
682                 }
683         }
684
685         else if (!strcasecmp(cmd, "GETSYS")) {
686                 extract_token(confname, argbuf, 1, '|', sizeof confname);
687                 confptr = CtdlGetSysConfig(confname);
688                 if (confptr != NULL) {
689                         cprintf("%d %s\n", LISTING_FOLLOWS, confname);
690                         client_write(confptr, strlen(confptr));
691                         if (confptr[strlen(confptr) - 1] != 10)
692                                 client_write("\n", 1);
693                         cprintf("000\n");
694                         free(confptr);
695                 } else {
696                         cprintf("%d No such configuration.\n",
697                                 ERROR + ILLEGAL_VALUE);
698                 }
699         }
700
701         else if (!strcasecmp(cmd, "PUTSYS")) {
702                 extract_token(confname, argbuf, 1, '|', sizeof confname);
703                 unbuffer_output();
704                 cprintf("%d %s\n", SEND_LISTING, confname);
705                 confptr = CtdlReadMessageBody(HKEY("000"), config.c_maxmsglen, NULL, 0, 0);
706                 CtdlPutSysConfig(confname, confptr);
707                 free(confptr);
708         }
709
710         else {
711                 cprintf("%d Illegal option(s) specified.\n",
712                         ERROR + ILLEGAL_VALUE);
713         }
714 }
715
716
717 /*****************************************************************************/
718 /*                      MODULE INITIALIZATION STUFF                          */
719 /*****************************************************************************/
720
721
722 CTDL_MODULE_INIT(control)
723 {
724         if (!threading) {
725                 CtdlRegisterProtoHook(cmd_conf, "CONF", "get/set system configuration");
726         }
727         /* return our id for the Log */
728         return "control";
729 }