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