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_user.c
Go to the documentation of this file.
1/*
2 * Server functions which perform operations on user objects.
3 *
4 * Copyright (c) 1987-2020 by the citadel.org team
5 *
6 * This program is open source software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License, version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15
16#include "support.h"
17#include "control.h"
18#include "ctdl_module.h"
19#include "citserver.h"
20#include "config.h"
21#include "user_ops.h"
22#include "internet_addressing.h"
23
24
25/*
26 * USER cmd
27 */
28void cmd_user(char *cmdbuf)
29{
30 char username[256];
31 int a;
32
33 extract_token(username, cmdbuf, 0, '|', sizeof username);
34 striplt(username);
35 syslog(LOG_DEBUG, "user_ops: cmd_user(%s)", username);
36
37 a = CtdlLoginExistingUser(username);
38 switch (a) {
40 cprintf("%d Already logged in.\n", ERROR + ALREADY_LOGGED_IN);
41 return;
43 cprintf("%d %s: "
44 "Too many users are already online "
45 "(maximum is %d)\n",
47 CtdlGetConfigStr("c_nodename"), CtdlGetConfigInt("c_maxsessions"));
48 return;
49 case login_ok:
50 cprintf("%d Password required for %s\n",
51 MORE_DATA, CC->curr_user);
52 return;
53 case login_not_found:
54 cprintf("%d %s not found.\n", ERROR + NO_SUCH_USER, username);
55 return;
56 default:
57 cprintf("%d Internal error\n", ERROR + INTERNAL_ERROR);
58 }
59}
60
61
62void cmd_pass(char *buf)
63{
64 char password[SIZ];
65 int a;
66 long len;
67
68 memset(password, 0, sizeof(password));
69 len = extract_token(password, buf, 0, '|', sizeof password);
70 a = CtdlTryPassword(password, len);
71
72 switch (a) {
74 cprintf("%d Already logged in.\n", ERROR + ALREADY_LOGGED_IN);
75 return;
76 case pass_no_user:
77 cprintf("%d You must send a name with USER first.\n",
79 return;
81 cprintf("%d Wrong password.\n", ERROR + PASSWORD_REQUIRED);
82 return;
83 case pass_ok:
85 return;
86 }
87}
88
89
90/*
91 * cmd_newu() - create a new user account and log in as that user
92 */
93void cmd_newu(char *cmdbuf)
94{
95 int a;
96 char username[SIZ];
97
98 if (CtdlGetConfigInt("c_auth_mode") != AUTHMODE_NATIVE) {
99 cprintf("%d This system does not use native mode authentication.\n",
100 ERROR + NOT_HERE);
101 return;
102 }
103
104 if (CtdlGetConfigInt("c_disable_newu")) {
105 cprintf("%d Self-service user account creation "
106 "is disabled on this system.\n", ERROR + NOT_HERE);
107 return;
108 }
109
110 if (CC->logged_in) {
111 cprintf("%d Already logged in.\n", ERROR + ALREADY_LOGGED_IN);
112 return;
113 }
114 if (CC->nologin) {
115 cprintf("%d %s: Too many users are already online (maximum is %d)\n",
117 CtdlGetConfigStr("c_nodename"), CtdlGetConfigInt("c_maxsessions"));
118 return;
119 }
120 extract_token(username, cmdbuf, 0, '|', sizeof username);
121 strproc(username);
122
123 if (IsEmptyStr(username)) {
124 cprintf("%d You must supply a user name.\n", ERROR + USERNAME_REQUIRED);
125 return;
126 }
127
128 if ((!strcasecmp(username, "bbs")) ||
129 (!strcasecmp(username, "new")) ||
130 (!strcasecmp(username, "."))) {
131 cprintf("%d '%s' is an invalid login name.\n", ERROR + ILLEGAL_VALUE, username);
132 return;
133 }
134
136
137 if (a == 0) {
139 } else if (a == ERROR + ALREADY_EXISTS) {
140 cprintf("%d '%s' already exists.\n",
141 ERROR + ALREADY_EXISTS, username);
142 return;
143 } else if (a == ERROR + INTERNAL_ERROR) {
144 cprintf("%d Internal error - user record disappeared?\n",
146 return;
147 } else {
148 cprintf("%d unknown error\n", ERROR + INTERNAL_ERROR);
149 }
150}
151
152
153/*
154 * set password - citadel protocol implementation
155 */
156void cmd_setp(char *new_pw)
157{
159 return;
160 }
161 if ( (CC->user.uid != CTDLUID) && (CC->user.uid != (-1)) ) {
162 cprintf("%d Not allowed. Use the 'passwd' command.\n", ERROR + NOT_HERE);
163 return;
164 }
165
166 if (!strcasecmp(new_pw, "GENERATE_RANDOM_PASSWORD")) {
167 char random_password[17];
168 snprintf(random_password, sizeof random_password, "%08lx%08lx", random(), random());
169 CtdlSetPassword(random_password);
170 cprintf("%d %s\n", CIT_OK, random_password);
171 }
172 else {
173 strproc(new_pw);
174 if (IsEmptyStr(new_pw)) {
175 cprintf("%d Password unchanged.\n", CIT_OK);
176 return;
177 }
178 CtdlSetPassword(new_pw);
179 cprintf("%d Password changed.\n", CIT_OK);
180 }
181}
182
183
184/*
185 * cmd_creu() - administratively create a new user account (do not log in to it)
186 */
187void cmd_creu(char *cmdbuf)
188{
189 int a;
190 char username[SIZ];
191 char password[SIZ];
192 struct ctdluser tmp;
193
195 return;
196 }
197
198 extract_token(username, cmdbuf, 0, '|', sizeof username);
199 strproc(username);
201 if (IsEmptyStr(username)) {
202 cprintf("%d You must supply a user name.\n", ERROR + USERNAME_REQUIRED);
203 return;
204 }
205
206 extract_token(password, cmdbuf, 1, '|', sizeof password);
207
209
210 if (a == 0) {
211 if (!IsEmptyStr(password)) {
212 CtdlGetUserLock(&tmp, username);
213 safestrncpy(tmp.password, password, sizeof(tmp.password));
214 CtdlPutUserLock(&tmp);
215 }
216 cprintf("%d User '%s' created %s.\n", CIT_OK, username, (!IsEmptyStr(password)) ? "and password set" : "with no password");
217 return;
218 } else if (a == ERROR + ALREADY_EXISTS) {
219 cprintf("%d '%s' already exists.\n", ERROR + ALREADY_EXISTS, username);
220 return;
221 } else if ( (CtdlGetConfigInt("c_auth_mode") != AUTHMODE_NATIVE) && (a == ERROR + NO_SUCH_USER) ) {
222 cprintf("%d User accounts are not created within Citadel in host authentication mode.\n", ERROR + NO_SUCH_USER);
223 return;
224 } else {
225 cprintf("%d An error occurred creating the user account.\n", ERROR + INTERNAL_ERROR);
226 }
227}
228
229
230/*
231 * get user parameters
232 */
233void cmd_getu(char *cmdbuf)
234{
236 return;
237
238 CtdlGetUser(&CC->user, CC->curr_user);
239 cprintf("%d 80|24|%d|\n", CIT_OK, (CC->user.flags & US_USER_SET));
240}
241
242
243/*
244 * set user parameters
245 */
246void cmd_setu(char *new_parms)
247{
249 return;
250
251 if (num_parms(new_parms) < 3) {
252 cprintf("%d Usage error.\n", ERROR + ILLEGAL_VALUE);
253 return;
254 }
256 CC->user.flags = CC->user.flags & (~US_USER_SET);
257 CC->user.flags = CC->user.flags | (extract_int(new_parms, 2) & US_USER_SET);
259 cprintf("%d Ok\n", CIT_OK);
260}
261
262
263/*
264 * set last read pointer
265 */
266void cmd_slrp(char *new_ptr)
267{
268 long newlr;
269 visit vbuf;
270 visit original_vbuf;
271
273 return;
274 }
275
276 if (!strncasecmp(new_ptr, "highest", 7)) {
277 newlr = CC->room.QRhighest;
278 } else {
279 newlr = atol(new_ptr);
280 }
281
283
284 CtdlGetRelationship(&vbuf, &CC->user, &CC->room);
285 memcpy(&original_vbuf, &vbuf, sizeof(visit));
286 vbuf.v_lastseen = newlr;
287 snprintf(vbuf.v_seen, sizeof vbuf.v_seen, "*:%ld", newlr);
288
289 /* Only rewrite the record if it changed */
290 if ( (vbuf.v_lastseen != original_vbuf.v_lastseen)
291 || (strcmp(vbuf.v_seen, original_vbuf.v_seen)) ) {
292 CtdlSetRelationship(&vbuf, &CC->user, &CC->room);
293 }
294
296 cprintf("%d %ld\n", CIT_OK, newlr);
297}
298
299
300void cmd_seen(char *argbuf) {
301 long target_msgnum = 0L;
302 int target_setting = 0;
303
305 return;
306 }
307
308 if (num_parms(argbuf) != 2) {
309 cprintf("%d Invalid parameters\n", ERROR + ILLEGAL_VALUE);
310 return;
311 }
312
313 target_msgnum = extract_long(argbuf, 0);
314 target_setting = extract_int(argbuf, 1);
315
316 CtdlSetSeen(&target_msgnum, 1, target_setting,
317 ctdlsetseen_seen, NULL, NULL);
318 cprintf("%d OK\n", CIT_OK);
319}
320
321
322void cmd_gtsn(char *argbuf) {
323 visit vbuf;
324
326 return;
327 }
328
329 /* Learn about the user and room in question */
330 CtdlGetRelationship(&vbuf, &CC->user, &CC->room);
331
332 cprintf("%d ", CIT_OK);
334 client_write(HKEY("\n"));
335}
336
337
338/*
339 * INVT and KICK commands
340 */
341void cmd_invt_kick(char *iuser, int op) {
342
343 /*
344 * These commands are only allowed by admins, room admins,
345 * and room namespace owners
346 */
347 if (is_room_aide()) {
348 /* access granted */
349 } else if ( ((atol(CC->room.QRname) == CC->user.usernum) ) && (CC->user.usernum != 0) ) {
350 /* access granted */
351 } else {
352 /* access denied */
353 cprintf("%d Higher access or room ownership required.\n", ERROR + HIGHER_ACCESS_REQUIRED);
354 return;
355 }
356
357 if (!strncasecmp(CC->room.QRname, CtdlGetConfigStr("c_baseroom"),
358 ROOMNAMELEN)) {
359 cprintf("%d Can't add/remove users from this room.\n", ERROR + NOT_HERE);
360 return;
361 }
362
363 if (CtdlInvtKick(iuser, op) != 0) {
364 cprintf("%d No such user.\n", ERROR + NO_SUCH_USER);
365 return;
366 }
367
368 cprintf("%d %s %s %s.\n",
369 CIT_OK, iuser,
370 ((op == 1) ? "invited to" : "kicked out of"),
371 CC->room.QRname);
372 return;
373}
374
375
376void cmd_invt(char *iuser) {
377 cmd_invt_kick(iuser, 1);
378}
379
380
381void cmd_kick(char *iuser) {
382 cmd_invt_kick(iuser, 0);
383}
384
385
386/*
387 * forget (Zap) the current room
388 */
389void cmd_forg(char *argbuf)
390{
391
393 return;
394 }
395
396 if (CtdlForgetThisRoom() == 0) {
397 cprintf("%d Ok\n", CIT_OK);
398 }
399 else {
400 cprintf("%d You may not forget this room.\n", ERROR + NOT_HERE);
401 }
402}
403
404
405/*
406 * Get Next Unregistered User
407 */
408void cmd_gnur(char *argbuf)
409{
410 struct cdbdata *cdbus;
411 struct ctdluser usbuf;
412
414 return;
415 }
416
417 if ((CtdlGetConfigInt("MMflags") & MM_VALID) == 0) {
418 cprintf("%d There are no unvalidated users.\n", CIT_OK);
419 return;
420 }
421
422 /* There are unvalidated users. Traverse the user database,
423 * and return the first user we find that needs validation.
424 */
426 while (cdbus = cdb_next_item(CDB_USERS), cdbus != NULL) {
427 memset(&usbuf, 0, sizeof(struct ctdluser));
428 memcpy(&usbuf, cdbus->ptr, ((cdbus->len > sizeof(struct ctdluser)) ? sizeof(struct ctdluser) : cdbus->len));
429 cdb_free(cdbus);
430 if ((usbuf.flags & US_NEEDVALID) && (usbuf.axlevel > AxDeleted)) {
431 cprintf("%d %s\n", MORE_DATA, usbuf.fullname);
433 return;
434 }
435 }
436
437 /* If we get to this point, there are no more unvalidated users.
438 * Therefore we clear the "users need validation" flag.
439 */
440
442 int flags;
443 flags = CtdlGetConfigInt("MMflags");
444 flags = flags & (~MM_VALID);
445 CtdlSetConfigInt("MMflags", flags);
447 cprintf("%d *** End of registration.\n", CIT_OK);
448}
449
450
451/*
452 * validate a user
453 */
454void cmd_vali(char *v_args)
455{
456 char user[128];
457 int newax;
458 struct ctdluser userbuf;
459
460 extract_token(user, v_args, 0, '|', sizeof user);
461 newax = extract_int(v_args, 1);
462
463 if (CtdlAccessCheck(ac_aide) || (newax > AxAideU) || (newax < AxDeleted)) {
464 return;
465 }
466
467 if (CtdlGetUserLock(&userbuf, user) != 0) {
468 cprintf("%d '%s' not found.\n", ERROR + NO_SUCH_USER, user);
469 return;
470 }
471
472 userbuf.axlevel = newax;
473 userbuf.flags = (userbuf.flags & ~US_NEEDVALID);
474
475 CtdlPutUserLock(&userbuf);
476
477 /* If the access level was set to zero, delete the user */
478 if (newax == 0) {
479 if (purge_user(user) == 0) {
480 cprintf("%d %s Deleted.\n", CIT_OK, userbuf.fullname);
481 return;
482 }
483 }
484 cprintf("%d User '%s' validated.\n", CIT_OK, userbuf.fullname);
485}
486
487
488/*
489 * List one user (this works with cmd_list)
490 */
491void ListThisUser(char *username, void *data)
492{
493 char *searchstring;
494 struct ctdluser usbuf;
495
496 if (CtdlGetUser(&usbuf, username) != 0) {
497 return;
498 }
499
500 searchstring = (char *)data;
501 if (bmstrcasestr(usbuf.fullname, searchstring) == NULL) {
502 return;
503 }
504
505 if (usbuf.axlevel > AxDeleted) {
506 if ((CC->user.axlevel >= AxAideU)
507 || ((usbuf.flags & US_UNLISTED) == 0)
508 || ((CC->internal_pgm))) {
509 cprintf("%s|%d|%ld|%ld|%ld|%ld||\n",
513 (long)usbuf.lastcall,
515 usbuf.posted);
516 }
517 }
518}
519
520
521/*
522 * List users (searchstring may be empty to list all users)
523 */
524void cmd_list(char *cmdbuf)
525{
526 char searchstring[256];
527 extract_token(searchstring, cmdbuf, 0, '|', sizeof searchstring);
528 striplt(searchstring);
529 cprintf("%d \n", LISTING_FOLLOWS);
530 ForEachUser(ListThisUser, (void *)searchstring );
531 cprintf("000\n");
532}
533
534
535/*
536 * assorted info we need to check at login
537 */
538void cmd_chek(char *argbuf)
539{
540 int mail = 0;
541 int regis = 0;
542 int vali = 0;
543
545 return;
546 }
547
548 CtdlGetUser(&CC->user, CC->curr_user); // no lock is needed here
549 if ((REGISCALL != 0) && ((CC->user.flags & US_REGIS) == 0)) {
550 regis = 1;
551 }
552
553 if (CC->user.axlevel >= AxAideU) {
554 if (CtdlGetConfigInt("MMflags") & MM_VALID) {
555 vali = 1;
556 }
557 }
558
559 mail = InitialMailCheck(); // check for mail
560
561 cprintf("%d %d|%d|%d|%s|\n", CIT_OK, mail, regis, vali, CC->cs_inet_email);
562}
563
564
565/*
566 * check to see if a user exists
567 */
568void cmd_qusr(char *who)
569{
570 struct ctdluser usbuf;
571
572 if (CtdlGetUser(&usbuf, who) == 0) {
573 cprintf("%d %s\n", CIT_OK, usbuf.fullname);
574 } else {
575 cprintf("%d No such user.\n", ERROR + NO_SUCH_USER);
576 }
577}
578
579
580/*
581 * Administrative Get User Parameters
582 */
583void cmd_agup(char *cmdbuf)
584{
585 struct ctdluser usbuf;
586 char requested_user[128];
587
589 return;
590 }
591
592 extract_token(requested_user, cmdbuf, 0, '|', sizeof requested_user);
593 if (CtdlGetUser(&usbuf, requested_user) != 0) {
594 cprintf("%d No such user.\n", ERROR + NO_SUCH_USER);
595 return;
596 }
597 cprintf("%d %s|%s|%u|%ld|%ld|%d|%ld|%ld|%d\n",
598 CIT_OK,
601 usbuf.flags,
604 (int) usbuf.axlevel,
606 (long)usbuf.lastcall,
608}
609
610
611/*
612 * Administrative Set User Parameters
613 */
614void cmd_asup(char *cmdbuf)
615{
616 struct ctdluser usbuf;
617 char requested_user[128];
618 char notify[SIZ];
619 int np;
620 int newax;
621 int deleted = 0;
622
624 return;
625
626 extract_token(requested_user, cmdbuf, 0, '|', sizeof requested_user);
627 if (CtdlGetUserLock(&usbuf, requested_user) != 0) {
628 cprintf("%d No such user.\n", ERROR + NO_SUCH_USER);
629 return;
630 }
631 np = num_parms(cmdbuf);
632 if (np > 1)
633 extract_token(usbuf.password, cmdbuf, 1, '|', sizeof usbuf.password);
634 if (np > 2)
635 usbuf.flags = extract_int(cmdbuf, 2);
636 if (np > 3)
637 usbuf.timescalled = extract_int(cmdbuf, 3);
638 if (np > 4)
639 usbuf.posted = extract_int(cmdbuf, 4);
640 if (np > 5) {
641 newax = extract_int(cmdbuf, 5);
642 if ((newax >= AxDeleted) && (newax <= AxAideU)) {
643 usbuf.axlevel = newax;
644 }
645 }
646 if (np > 7) {
647 usbuf.lastcall = extract_long(cmdbuf, 7);
648 }
649 if (np > 8) {
650 usbuf.USuserpurge = extract_int(cmdbuf, 8);
651 }
653 if (usbuf.axlevel == AxDeleted) {
654 if (purge_user(requested_user) == 0) {
655 deleted = 1;
656 }
657 }
658
659 if (deleted) {
660 snprintf(notify, SIZ,
661 "User \"%s\" has been deleted by %s.\n",
662 usbuf.fullname, (CC->logged_in ? CC->user.fullname : "an administrator")
663 );
664 CtdlAideMessage(notify, "User Deletion Message");
665 }
666
667 cprintf("%d Ok", CIT_OK);
668 if (deleted) {
669 cprintf(" (%s deleted)", requested_user);
670 }
671 cprintf("\n");
672}
673
674
675/*
676 * Citadel protocol command to do the same
677 */
678void cmd_isme(char *argbuf) {
679 char addr[256];
680
681 if (CtdlAccessCheck(ac_logged_in)) return;
682 extract_token(addr, argbuf, 0, '|', sizeof addr);
683
684 if (CtdlIsMe(addr, sizeof addr)) {
685 cprintf("%d %s\n", CIT_OK, addr);
686 }
687 else {
688 cprintf("%d Not you.\n", ERROR + ILLEGAL_VALUE);
689 }
690
691}
692
693
694/*
695 * Administrative Get Email Addresses
696 */
697void cmd_agea(char *cmdbuf)
698{
699 struct ctdluser usbuf;
700 char requested_user[128];
701 int i, num_e;
702 char e[512];
703
705 return;
706 }
707
708 extract_token(requested_user, cmdbuf, 0, '|', sizeof requested_user);
709 if (CtdlGetUser(&usbuf, requested_user) != 0) {
710 cprintf("%d No such user.\n", ERROR + NO_SUCH_USER);
711 return;
712 }
713 cprintf("%d internet email addresses for %s\n", LISTING_FOLLOWS, usbuf.fullname);
714 num_e = num_tokens(usbuf.emailaddrs, '|');
715 for (i=0; i<num_e; ++i) {
716 extract_token(e, usbuf.emailaddrs, i, '|', sizeof e);
717 cprintf("%s\n", e);
718 }
719 cprintf("000\n");
720}
721
722
723/*
724 * Administrative Set Email Addresses
725 */
726void cmd_asea(char *cmdbuf)
727{
728 struct ctdluser usbuf;
729 char requested_user[128];
730 char buf[SIZ];
731 char whodat[64];
732 char new_emailaddrs[512] = { 0 } ;
733
734 if (CtdlAccessCheck(ac_aide)) return;
735
736 extract_token(requested_user, cmdbuf, 0, '|', sizeof requested_user);
737 if (CtdlGetUser(&usbuf, requested_user) != 0) {
738 cprintf("%d No such user.\n", ERROR + NO_SUCH_USER);
739 return;
740 }
741
742 cprintf("%d Ok\n", SEND_LISTING);
743 while (client_getln(buf, sizeof buf) >= 0 && strcmp(buf, "000")) {
744 if (IsEmptyStr(buf)) {
745 syslog(LOG_ERR, "user_ops: address <%s> is empty - not using", buf);
746 }
747 else if ((strlen(new_emailaddrs) + strlen(buf) + 2) > sizeof(new_emailaddrs)) {
748 syslog(LOG_ERR, "user_ops: address <%s> does not fit in buffer - not using", buf);
749 }
750 else if (!IsDirectory(buf, 0)) {
751 syslog(LOG_ERR, "user_ops: address <%s> is not in one of our domains - not using", buf);
752 }
753 else if ( (CtdlDirectoryLookup(whodat, buf, sizeof whodat) == 0) && (CtdlUserCmp(whodat, requested_user)) ) {
754 syslog(LOG_ERR, "user_ops: address <%s> already belongs to <%s> - not using", buf, whodat);
755 }
756 else {
757 syslog(LOG_DEBUG, "user_ops: address <%s> validated", buf);
758 if (!IsEmptyStr(new_emailaddrs)) {
759 strcat(new_emailaddrs, "|");
760 }
761 strcat(new_emailaddrs, buf);
762 }
763 }
764
765 CtdlSetEmailAddressesForUser(requested_user, new_emailaddrs);
766}
767
768
769/*
770 * Set the preferred view for the current user/room combination
771 */
772void cmd_view(char *cmdbuf) {
773 int requested_view;
774 visit vbuf;
775
777 return;
778 }
779
780 requested_view = extract_int(cmdbuf, 0);
781
782 CtdlGetRelationship(&vbuf, &CC->user, &CC->room);
783 vbuf.v_view = requested_view;
784 CtdlSetRelationship(&vbuf, &CC->user, &CC->room);
785
786 cprintf("%d ok\n", CIT_OK);
787}
788
789
790/*
791 * Rename a user
792 */
793void cmd_renu(char *cmdbuf)
794{
795 int retcode;
796 char oldname[USERNAME_SIZE];
797 char newname[USERNAME_SIZE];
798
800 return;
801 }
802
803 extract_token(oldname, cmdbuf, 0, '|', sizeof oldname);
804 extract_token(newname, cmdbuf, 1, '|', sizeof newname);
805
806 retcode = rename_user(oldname, newname);
807 switch(retcode) {
808 case RENAMEUSER_OK:
809 cprintf("%d '%s' has been renamed to '%s'.\n", CIT_OK, oldname, newname);
810 return;
812 cprintf("%d '%s' is currently logged in and cannot be renamed.\n",
813 ERROR + ALREADY_LOGGED_IN , oldname
814 );
815 return;
817 cprintf("%d '%s' does not exist.\n", ERROR + NO_SUCH_USER, oldname);
818 return;
820 cprintf("%d A user named '%s' already exists.\n", ERROR + ALREADY_EXISTS, newname);
821 return;
822 }
823
824 cprintf("%d An unknown error occurred.\n", ERROR);
825}
826
827
828void cmd_quit(char *argbuf)
829{
830 cprintf("%d Goodbye.\n", CIT_OK);
831 CC->kill_me = KILLME_CLIENT_LOGGED_OUT;
832}
833
834
835void cmd_lout(char *argbuf)
836{
837 if (CC->logged_in)
839 cprintf("%d logged out.\n", CIT_OK);
840}
841
842
843/*****************************************************************************/
844/* MODULE INITIALIZATION STUFF */
845/*****************************************************************************/
846
847
849{
850 if (!threading) {
851 CtdlRegisterProtoHook(cmd_user, "USER", "Submit username for login");
852 CtdlRegisterProtoHook(cmd_pass, "PASS", "Complete login by submitting a password");
853 CtdlRegisterProtoHook(cmd_quit, "QUIT", "log out and disconnect from server");
854 CtdlRegisterProtoHook(cmd_lout, "LOUT", "log out but do not disconnect from server");
855 CtdlRegisterProtoHook(cmd_creu, "CREU", "Create User");
856 CtdlRegisterProtoHook(cmd_setp, "SETP", "Set the password for an account");
857 CtdlRegisterProtoHook(cmd_getu, "GETU", "Get User parameters");
858 CtdlRegisterProtoHook(cmd_setu, "SETU", "Set User parameters");
859 CtdlRegisterProtoHook(cmd_slrp, "SLRP", "Set Last Read Pointer");
860 CtdlRegisterProtoHook(cmd_invt, "INVT", "Invite a user to a room");
861 CtdlRegisterProtoHook(cmd_kick, "KICK", "Kick a user out of a room");
862 CtdlRegisterProtoHook(cmd_forg, "FORG", "Forget a room");
863 CtdlRegisterProtoHook(cmd_gnur, "GNUR", "Get Next Unregistered User");
864 CtdlRegisterProtoHook(cmd_vali, "VALI", "Validate new users");
865 CtdlRegisterProtoHook(cmd_list, "LIST", "List users");
866 CtdlRegisterProtoHook(cmd_chek, "CHEK", "assorted info we need to check at login");
867 CtdlRegisterProtoHook(cmd_qusr, "QUSR", "check to see if a user exists");
868 CtdlRegisterProtoHook(cmd_agup, "AGUP", "Administratively Get User Parameters");
869 CtdlRegisterProtoHook(cmd_asup, "ASUP", "Administratively Set User Parameters");
870 CtdlRegisterProtoHook(cmd_agea, "AGEA", "Administratively Get Email Addresses");
871 CtdlRegisterProtoHook(cmd_asea, "ASEA", "Administratively Set Email Addresses");
872 CtdlRegisterProtoHook(cmd_seen, "SEEN", "Manipulate seen/unread message flags");
873 CtdlRegisterProtoHook(cmd_gtsn, "GTSN", "Fetch seen/unread message flags");
874 CtdlRegisterProtoHook(cmd_view, "VIEW", "Set preferred view for user/room combination");
875 CtdlRegisterProtoHook(cmd_renu, "RENU", "Rename a user");
876 CtdlRegisterProtoHook(cmd_newu, "NEWU", "Log in as a new user");
877 CtdlRegisterProtoHook(cmd_isme, "ISME", "Determine whether an email address belongs to a user");
878 }
879 /* return our Subversion id for the Log */
880 return "user";
881}
#define ROOMNAMELEN
Definition: citadel.h:56
#define MM_VALID
Definition: citadel.h:101
#define AUTHMODE_NATIVE
Definition: citadel.h:173
#define USERNAME_SIZE
Definition: citadel.h:57
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
int CtdlLockGetCurrentUser(void)
Definition: user_ops.c:103
#define REGISCALL
Definition: ctdl_module.h:261
void CtdlPutCurrentUserLock(void)
Definition: user_ops.c:138
#define CtdlAideMessage(TEXT, SUBJECT)
Definition: ctdl_module.h:58
void CtdlUserLogout(void)
Definition: user_ops.c:750
int CtdlGetUserLock(struct ctdluser *usbuf, char *name)
Definition: user_ops.c:113
@ pass_ok
Definition: ctdl_module.h:290
@ pass_no_user
Definition: ctdl_module.h:292
@ pass_already_logged_in
Definition: ctdl_module.h:291
@ pass_wrong_password
Definition: ctdl_module.h:294
int CtdlTryPassword(const char *password, long len)
Definition: user_ops.c:870
void CtdlPutUserLock(struct ctdluser *usbuf)
Definition: user_ops.c:147
@ login_too_many_users
Definition: ctdl_module.h:304
@ login_not_found
Definition: ctdl_module.h:305
@ login_ok
Definition: ctdl_module.h:302
@ login_already_logged_in
Definition: ctdl_module.h:303
void CtdlSetRelationship(visit *newvisit, struct ctdluser *rel_user, struct ctdlroom *rel_room)
Definition: user_ops.c:306
int CtdlLoginExistingUser(const char *username)
Definition: user_ops.c:535
#define CTDLUID
Definition: ctdl_module.h:259
@ ac_aide
Definition: ctdl_module.h:246
@ ac_logged_in
Definition: ctdl_module.h:244
int CtdlGetUser(struct ctdluser *usbuf, char *name)
Definition: user_ops.c:77
void CtdlRegisterProtoHook(void(*handler)(char *), char *cmd, char *desc)
#define CTDL_MODULE_INIT(module_name)
Definition: ctdl_module.h:50
void cdb_close_cursor(int cdb)
Definition: database.c:617
void cdb_free(struct cdbdata *cdb)
Definition: database.c:609
struct cdbdata * cdb_next_item(int cdb)
Definition: database.c:655
void cdb_rewind(int cdb)
Definition: database.c:631
int CtdlIsMe(char *addr, int addr_buf_len)
int IsDirectory(char *addr, int allow_masq_domains)
void CtdlSetEmailAddressesForUser(char *requested_user, char *new_emailaddrs)
int CtdlDirectoryLookup(char *target, char *internet_addr, size_t targbuflen)
#define US_UNLISTED
Definition: ipcdef.h:66
#define CIT_OK
Definition: ipcdef.h:6
#define ILLEGAL_VALUE
Definition: ipcdef.h:16
#define US_REGIS
Definition: ipcdef.h:70
#define INTERNAL_ERROR
Definition: ipcdef.h:14
#define LISTING_FOLLOWS
Definition: ipcdef.h:5
#define HIGHER_ACCESS_REQUIRED
Definition: ipcdef.h:23
#define ALREADY_LOGGED_IN
Definition: ipcdef.h:21
#define US_USER_SET
Definition: ipcdef.h:75
#define MORE_DATA
Definition: ipcdef.h:7
#define ERROR
Definition: ipcdef.h:9
#define SEND_LISTING
Definition: ipcdef.h:8
#define MAX_SESSIONS_EXCEEDED
Definition: ipcdef.h:24
#define ALREADY_EXISTS
Definition: ipcdef.h:33
#define USERNAME_REQUIRED
Definition: ipcdef.h:22
#define PASSWORD_REQUIRED
Definition: ipcdef.h:20
#define US_NEEDVALID
Definition: ipcdef.h:61
#define NO_SUCH_USER
Definition: ipcdef.h:29
#define NOT_HERE
Definition: ipcdef.h:27
void CtdlSetSeen(long *target_msgnums, int num_target_msgnums, int target_setting, int which_set, struct ctdluser *which_user, struct ctdlroom *which_room)
Definition: msgbase.c:409
@ ctdlsetseen_seen
Definition: msgbase.h:176
visit vbuf
Definition: serv_migrate.c:503
struct ctdluser usbuf
Definition: serv_migrate.c:496
void cmd_asea(char *cmdbuf)
Definition: serv_user.c:726
void cmd_kick(char *iuser)
Definition: serv_user.c:381
void cmd_pass(char *buf)
Definition: serv_user.c:62
void cmd_list(char *cmdbuf)
Definition: serv_user.c:524
void cmd_getu(char *cmdbuf)
Definition: serv_user.c:233
void cmd_slrp(char *new_ptr)
Definition: serv_user.c:266
void cmd_gtsn(char *argbuf)
Definition: serv_user.c:322
void cmd_forg(char *argbuf)
Definition: serv_user.c:389
void cmd_asup(char *cmdbuf)
Definition: serv_user.c:614
void cmd_seen(char *argbuf)
Definition: serv_user.c:300
void cmd_view(char *cmdbuf)
Definition: serv_user.c:772
void cmd_creu(char *cmdbuf)
Definition: serv_user.c:187
void cmd_lout(char *argbuf)
Definition: serv_user.c:835
void cmd_invt(char *iuser)
Definition: serv_user.c:376
void cmd_chek(char *argbuf)
Definition: serv_user.c:538
void cmd_qusr(char *who)
Definition: serv_user.c:568
void cmd_gnur(char *argbuf)
Definition: serv_user.c:408
void cmd_agea(char *cmdbuf)
Definition: serv_user.c:697
void cmd_setu(char *new_parms)
Definition: serv_user.c:246
void cmd_agup(char *cmdbuf)
Definition: serv_user.c:583
void cmd_renu(char *cmdbuf)
Definition: serv_user.c:793
void cmd_quit(char *argbuf)
Definition: serv_user.c:828
void cmd_vali(char *v_args)
Definition: serv_user.c:454
void cmd_invt_kick(char *iuser, int op)
Definition: serv_user.c:341
void cmd_user(char *cmdbuf)
Definition: serv_user.c:28
void ListThisUser(char *username, void *data)
Definition: serv_user.c:491
void cmd_newu(char *cmdbuf)
Definition: serv_user.c:93
void cmd_isme(char *argbuf)
Definition: serv_user.c:678
void cmd_setp(char *new_pw)
Definition: serv_user.c:156
@ KILLME_CLIENT_LOGGED_OUT
Definition: server.h:88
@ CDB_USERS
Definition: server.h:186
@ S_CONTROL
Definition: server.h:140
int snprintf(char *buf, size_t max, const char *fmt,...)
Definition: snprintf.c:69
long v_lastseen
Definition: server.h:249
char v_seen[4096]
Definition: server.h:251
int v_view
Definition: server.h:253
size_t len
Definition: server.h:203
char * ptr
Definition: server.h:204
long posted
Definition: citadel.h:85
unsigned flags
Definition: citadel.h:83
cit_uint8_t axlevel
Definition: citadel.h:86
char fullname[64]
Definition: citadel.h:90
time_t lastcall
Definition: citadel.h:88
long timescalled
Definition: citadel.h:84
long usernum
Definition: citadel.h:87
char password[32]
Definition: citadel.h:82
int USuserpurge
Definition: citadel.h:89
char emailaddrs[512]
Definition: citadel.h:93
void strproc(char *string)
Definition: support.c:17
#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
int client_write(const char *buf, int nbytes)
Definition: sysdep.c:307
void begin_critical_section(int which_one)
Definition: threads.c:67
void end_critical_section(int which_one)
Definition: threads.c:85
void ForEachUser(void(*CallBack)(char *, void *out_data), void *in_data)
Definition: user_ops.c:1206
void CtdlSetPassword(char *new_pw)
Definition: user_ops.c:1126
int CtdlUserCmp(char *s1, char *s2)
Definition: user_ops.c:63
int purge_user(char pname[])
Definition: user_ops.c:972
int create_user(char *username, int become_user, uid_t uid)
Definition: user_ops.c:1065
int CtdlForgetThisRoom(void)
Definition: user_ops.c:1178
int is_room_aide(void)
Definition: user_ops.c:441
int CtdlInvtKick(char *iuser, int op)
Definition: user_ops.c:1142
int rename_user(char *oldname, char *newname)
Definition: user_ops.c:160
void logged_in_response(void)
Definition: user_ops.c:739
int InitialMailCheck()
Definition: user_ops.c:1266
#define RENAMEUSER_NOT_FOUND
Definition: user_ops.h:66
#define RENAMEUSER_OK
Definition: user_ops.h:64
@ CREATE_USER_BECOME_USER
Definition: user_ops.h:34
@ CREATE_USER_DO_NOT_BECOME_USER
Definition: user_ops.h:33
#define RENAMEUSER_LOGGED_IN
Definition: user_ops.h:65
#define RENAMEUSER_ALREADY_EXISTS
Definition: user_ops.h:67
#define NATIVE_AUTH_UID
Definition: user_ops.h:36