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)  

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