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
user_ops.c
Go to the documentation of this file.
1// Server functions which perform operations on user objects.
2//
3// Copyright (c) 1987-2023 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#include <stdlib.h>
9#include <unistd.h>
10#include "sysdep.h"
11#include <stdio.h>
12#include <sys/stat.h>
13#include <libcitadel.h>
14#include "control.h"
15#include "support.h"
16#include "citserver.h"
17#include "config.h"
18#include "citadel_ldap.h"
19#include "ctdl_module.h"
20#include "user_ops.h"
21#include "room_ops.h"
22#include "makeuserkey.h"
23#include "internet_addressing.h"
24
25// These pipes are used to talk to the chkpwd daemon, which is forked during startup
28
29
30// Compare two usernames to see if they are the same user after being keyed for the database
31// Usage is identical to strcmp()
32int CtdlUserCmp(char *s1, char *s2) {
33 char k1[USERNAME_SIZE];
34 char k2[USERNAME_SIZE];
35
36 makeuserkey(k1, s1);
37 makeuserkey(k2, s2);
38 return(strcmp(k1,k2));
39}
40
41
42// CtdlGetUser() retrieve named user into supplied buffer.
43// returns 0 on success
44int CtdlGetUser(struct ctdluser *usbuf, char *name) {
45 char usernamekey[USERNAME_SIZE];
46 struct cdbdata cdbus;
47
48 if (usbuf != NULL) {
49 memset(usbuf, 0, sizeof(struct ctdluser));
50 }
51
52 makeuserkey(usernamekey, name);
53 if (IsEmptyStr(usernamekey)) {
54 return(1); // empty user name
55 }
56 cdbus = cdb_fetch(CDB_USERS, usernamekey, strlen(usernamekey));
57
58 if (cdbus.ptr == NULL) { // user not found
59 return(1);
60 }
61 if (usbuf != NULL) {
62 memcpy(usbuf, cdbus.ptr, ((cdbus.len > sizeof(struct ctdluser)) ? sizeof(struct ctdluser) : cdbus.len));
63 }
64 return(0);
65}
66
67
69 return CtdlGetUser(&CC->user, CC->curr_user);
70}
71
72
73// CtdlGetUserLock() - same as getuser() but locks the record
74int CtdlGetUserLock(struct ctdluser *usbuf, char *name) {
75 int retcode;
76
77 retcode = CtdlGetUser(usbuf, name);
78 if (retcode == 0) {
80 }
81 return(retcode);
82}
83
84
85// CtdlPutUser() - write user buffer into the correct place on disk
86void CtdlPutUser(struct ctdluser *usbuf) {
87 char usernamekey[USERNAME_SIZE];
88 makeuserkey(usernamekey, usbuf->fullname);
89 usbuf->version = REV_LEVEL;
90 cdb_store(CDB_USERS, usernamekey, strlen(usernamekey), usbuf, sizeof(struct ctdluser));
91}
92
93
95 CtdlPutUser(&CC->user);
96}
97
98
99// CtdlPutUserLock() - same as putuser() but locks the record
100void CtdlPutUserLock(struct ctdluser *usbuf) {
101 CtdlPutUser(usbuf);
103}
104
105
106// rename_user() - this is tricky because the user's display name is the database key
107// Returns 0 on success or nonzero if there was an error...
108int rename_user(char *oldname, char *newname) {
109 int retcode = RENAMEUSER_OK;
110 struct ctdluser usbuf;
111
112 char oldnamekey[USERNAME_SIZE];
113 char newnamekey[USERNAME_SIZE];
114
115 // Create the database keys...
116 makeuserkey(oldnamekey, oldname);
117 makeuserkey(newnamekey, newname);
118
119 // Lock up and get going
121
122 // We cannot rename a user who is currently logged in
123 if (CtdlIsUserLoggedIn(oldname)) {
126 }
127
128 if (CtdlGetUser(&usbuf, newname) == 0) {
130 }
131 else {
132
133 if (CtdlGetUser(&usbuf, oldname) != 0) {
134 retcode = RENAMEUSER_NOT_FOUND;
135 }
136 else { // Sanity checks succeeded. Now rename the user.
137 if (usbuf.usernum == 0) {
138 syslog(LOG_DEBUG, "user_ops: can not rename user \"Citadel\".");
139 retcode = RENAMEUSER_NOT_FOUND;
140 }
141 else {
142 syslog(LOG_DEBUG, "user_ops: renaming <%s> to <%s>", oldname, newname);
143 cdb_delete(CDB_USERS, oldnamekey, strlen(oldnamekey));
144 safestrncpy(usbuf.fullname, newname, sizeof usbuf.fullname);
145 CtdlPutUser(&usbuf);
146 cdb_store(CDB_USERSBYNUMBER, &usbuf.usernum, sizeof(long), usbuf.fullname, strlen(usbuf.fullname)+1 );
147 retcode = RENAMEUSER_OK;
148 }
149 }
150
151 }
152
154 return(retcode);
155}
156
157
158// Convert a username into the format used as a database key prior to version 928
159// This only gets called by reindex_user_928()
160void makeuserkey_pre928(char *key, const char *username) {
161 int i;
162
163 int len = strlen(username);
164
165 if (len >= USERNAME_SIZE) {
166 syslog(LOG_INFO, "Username too long: %s", username);
167 len = USERNAME_SIZE - 1;
168 }
169 for (i=0; i<=len; ++i) {
170 key[i] = tolower(username[i]);
171 }
172}
173
174
175// Read a user record using the pre-v928 index format, and write it back using the v928-and-higher index format.
176// This ONLY gets called during an upgrade from version <928 to version >=928.
177void reindex_user_928(char *username, void *out_data) {
178
179 char oldkey[USERNAME_SIZE];
180 char newkey[USERNAME_SIZE];
181 struct cdbdata cdbus;
182 struct ctdluser usbuf;
183
184 makeuserkey_pre928(oldkey, username);
185 makeuserkey(newkey, username);
186
187 syslog(LOG_DEBUG, "user_ops: reindex_user_928: %s <%s> --> <%s>", username, oldkey, newkey);
188
189 // Fetch the user record using the old index format
190 cdbus = cdb_fetch(CDB_USERS, oldkey, strlen(oldkey));
191 if (cdbus.ptr == NULL) {
192 syslog(LOG_INFO, "user_ops: <%s> not found, were they already reindexed?", username);
193 return;
194 }
195 memcpy(&usbuf, cdbus.ptr, ((cdbus.len > sizeof(struct ctdluser)) ? sizeof(struct ctdluser) : cdbus.len));
196
197 // delete the old record
198 cdb_delete(CDB_USERS, oldkey, strlen(oldkey));
199
200 // write the new record
201 cdb_store(CDB_USERS, newkey, strlen(newkey), &usbuf, sizeof(struct ctdluser));
202}
203
204
205// Index-generating function used by Ctdl[Get|Set]Relationship
206int GenerateRelationshipIndex(char *IndexBuf, long RoomID, long RoomGen, long UserID) {
207 struct visit_index TheIndex;
208 TheIndex.iRoomID = RoomID;
209 TheIndex.iRoomGen = RoomGen;
210 TheIndex.iUserID = UserID;
211
212 memcpy(IndexBuf, &TheIndex, sizeof(TheIndex));
213 return(sizeof(TheIndex));
214}
215
216// Back end for CtdlSetRelationship()
217void put_visit(struct visit *newvisit) {
218 cdb_store(CDB_VISIT, newvisit, (sizeof(long)*3), newvisit, sizeof(struct visit));
219}
220
221
222// Define a relationship between a user and a room
223void CtdlSetRelationship(struct visit *newvisit, struct ctdluser *rel_user, struct ctdlroom *rel_room) {
224 // We don't use these in Citadel because they're implicit by the
225 // index, but they must be present if the database is exported.
226 newvisit->v_roomnum = rel_room->QRnumber;
227 newvisit->v_roomgen = rel_room->QRgen;
228 newvisit->v_usernum = rel_user->usernum;
229
230 // Store the record
231 put_visit(newvisit);
232}
233
234
235// Locate a relationship between a user and a room
236void CtdlGetRelationship(struct visit *vbuf, struct ctdluser *rel_user, struct ctdlroom *rel_room) {
237 struct cdbdata cdbvisit;
238
239 // Clear out the buffer
240 memset(vbuf, 0, sizeof(struct visit));
241
242 // Fill out the first three fields; they are also the index
243 vbuf->v_roomnum = rel_room->QRnumber;
244 vbuf->v_roomgen = rel_room->QRgen;
245 vbuf->v_usernum = rel_user->usernum;
246
247 cdbvisit = cdb_fetch(CDB_VISIT, vbuf, (sizeof(long)*3));
248 if (cdbvisit.ptr != NULL) {
249 memcpy(vbuf, cdbvisit.ptr, ((cdbvisit.len > sizeof(struct visit)) ? sizeof(struct visit) : cdbvisit.len));
250 }
251 else {
252 // If this is the first time the user has seen this room, set the view to be the default for the room.
253 vbuf->v_view = rel_room->QRdefaultview;
254 }
255
256 // Set v_seen if necessary
257 if (vbuf->v_seen[0] == 0) {
258 snprintf(vbuf->v_seen, sizeof vbuf->v_seen, "*:%ld", vbuf->v_lastseen);
259 }
260}
261
262
263void CtdlMailboxName(char *buf, size_t n, const struct ctdluser *who, const char *prefix) {
264 snprintf(buf, n, "%010ld.%s", who->usernum, prefix);
265}
266
267
268// Check to see if the specified user has Internet mail permission
269// (returns nonzero if permission is granted)
271
272 // Do not allow twits to send Internet mail
273 if (who->axlevel <= AxProbU) return(0);
274
275 // Globally enabled?
276 if (CtdlGetConfigInt("c_restrict") == 0) return(1);
277
278 // User flagged ok?
279 if (who->flags & US_INTERNET) return(2);
280
281 // Admin level access?
282 if (who->axlevel >= AxAideU) return(3);
283
284 // No mail for you!
285 return(0);
286}
287
288
289// This is a convenience function which follows the Citadel protocol semantics for most commands.
290// If the current user does not have the requested access level, it outputs a protocol-friendly error message
291// and then returns (-1). This allows calling functions to complete an access level check in one line of code.
292int CtdlAccessCheck(int required_level) {
293 if (CC->internal_pgm) return(0);
294 if (required_level >= ac_internal) {
295 cprintf("%d This is not a user-level command.\n", ERROR + HIGHER_ACCESS_REQUIRED);
296 return(-1);
297 }
298
299 if ((required_level >= ac_logged_in_or_guest) && (CC->logged_in == 0) && (CtdlGetConfigInt("c_guest_logins") == 0)) {
300 cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
301 return(-1);
302 }
303
304 if ((required_level >= ac_logged_in) && (CC->logged_in == 0)) {
305 cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
306 return(-1);
307 }
308
309 if (CC->user.axlevel >= AxAideU) return(0);
310 if (required_level >= ac_aide) {
311 cprintf("%d This command requires Admin access.\n",
313 return(-1);
314 }
315
316 if (is_room_aide()) return(0);
317 if (required_level >= ac_room_aide) {
318 cprintf("%d This command requires Admin or Room Admin access.\n",
320 return(-1);
321 }
322
323 // Do not generate any output if we succeeded -- the calling function will handle that.
324 return(0);
325}
326
327
328// Is the user currently logged in an Admin?
329int is_aide(void) {
330 if (CC->user.axlevel >= AxAideU) {
331 return(1);
332 }
333 else {
334 return(0);
335 }
336}
337
338
339// Is the user currently logged in an Admin *or* the room Admin for this room?
340int is_room_aide(void) {
341 if (!CC->logged_in) {
342 return(0);
343 }
344
345 if ((CC->user.axlevel >= AxAideU) || (CC->room.QRroomaide == CC->user.usernum)) {
346 return(1);
347 }
348 else {
349 return(0);
350 }
351}
352
353
354// CtdlGetUserByNumber() - get user by number, returns 0 if user was found
355// Note: fetching a user this way requires one additional database operation.
356int CtdlGetUserByNumber(struct ctdluser *usbuf, long number) {
357 struct cdbdata cdbun;
358 int r;
359
360 cdbun = cdb_fetch(CDB_USERSBYNUMBER, &number, sizeof(long));
361 if (cdbun.ptr == NULL) {
362 syslog(LOG_INFO, "user_ops: %ld not found", number);
363 return(-1);
364 }
365
366 syslog(LOG_INFO, "user_ops: %ld maps to %s", number, cdbun.ptr);
367 r = CtdlGetUser(usbuf, cdbun.ptr);
368 return(r);
369}
370
371
372// Helper function for rebuild_usersbynumber()
373void rebuild_ubn_for_user(char *username, void *data) {
374 struct ctdluser u;
375
376 syslog(LOG_DEBUG, "user_ops: rebuilding usersbynumber index for %s", username);
377 if (CtdlGetUser(&u, username) == 0) {
378 cdb_store(CDB_USERSBYNUMBER, &(u.usernum), sizeof(long), u.fullname, strlen(u.fullname)+1);
379 }
380}
381
382
383// Rebuild the users-by-number index
385 cdb_trunc(CDB_USERSBYNUMBER); // delete the old indices
386 ForEachUser(rebuild_ubn_for_user, NULL); // enumerate the users
387}
388
389
390// getuserbyuid() Get user by system uid (for PAM mode authentication)
391// Returns 0 if user was found
392int getuserbyuid(struct ctdluser *usbuf, uid_t number) {
393
394 struct cdbkeyval cdbus;
395 struct ctdluser *usptr;
396 int return_value = (-1);
397
398 // Yes, we do this the long way. Someday we might want to try an index.
399 // No, we don't use CtdlForEachUser() because that requires multiple reads for each record
401 while (cdbus = cdb_next_item(CDB_USERS), cdbus.val.ptr!=NULL) { // always read through to the end
402 usptr = (struct ctdluser *) cdbus.val.ptr;
403
404 if (usptr->uid == number) {
405 syslog(LOG_DEBUG, "user_ops: found uid=%d username=%s", usptr->uid, usptr->fullname);
406 memcpy(usbuf, usptr, sizeof(struct ctdluser));
407 return_value = 0; // success
408 }
409 }
410
411 if (return_value != 0) {
412 syslog(LOG_DEBUG, "user_ops: no user found with uid=%d", number);
413 }
414 return(return_value);
415}
416
417
418// Back end for cmd_user() and its ilk
419int CtdlLoginExistingUser(const char *trythisname) {
420 char username[SIZ];
421 int found_user;
422
423 syslog(LOG_DEBUG, "user_ops: CtdlLoginExistingUser(%s)", trythisname);
424
425 if ((CC->logged_in)) {
427 }
428
429 if (trythisname == NULL) return login_not_found;
430
431 // We handle this a different way now (see below)
432 //if (!strncasecmp(trythisname, "SYS_", 4)) {
433 //syslog(LOG_DEBUG, "user_ops: system user \"%s\" is not allowed to log in.", trythisname);
434 //return login_not_found;
435 //}
436
437 // Continue attempting user validation...
438 safestrncpy(username, trythisname, sizeof (username));
439 string_trim(username);
440
441 if (IsEmptyStr(username)) {
442 return login_not_found;
443 }
444
445 // host auth mode...
446 if (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_HOST) {
447 struct passwd pd;
448 struct passwd *tempPwdPtr;
449 char pwdbuffer[256];
450
451 syslog(LOG_DEBUG, "user_ops: asking host about <%s>", username);
452#ifdef HAVE_GETPWNAM_R
453 syslog(LOG_DEBUG, "user_ops: calling getpwnam_r()");
454 getpwnam_r(username, &pd, pwdbuffer, sizeof pwdbuffer, &tempPwdPtr);
455#else // HAVE_GETPWNAM_R
456 syslog(LOG_DEBUG, "user_ops: SHOULD NEVER GET HERE!!!");
457 tempPwdPtr = NULL;
458#endif // HAVE_GETPWNAM_R
459 if (tempPwdPtr == NULL) {
460 syslog(LOG_DEBUG, "user_ops: no such user <%s>", username);
461 return login_not_found;
462 }
463
464 // Locate the associated Citadel account. If not found, make one attempt to create it.
465 found_user = getuserbyuid(&CC->user, pd.pw_uid);
466 if (found_user != 0) {
467 create_user(username, CREATE_USER_DO_NOT_BECOME_USER, pd.pw_uid);
468 found_user = getuserbyuid(&CC->user, pd.pw_uid);
469 }
470 syslog(LOG_DEBUG, "user_ops: found it: uid=%ld, gecos=%s here: %d", (long)pd.pw_uid, pd.pw_gecos, found_user);
471
472 }
473
474 // LDAP auth mode...
475 else if ((CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP) || (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP_AD)) {
476
477 uid_t ldap_uid;
478 char ldap_cn[256];
479 char ldap_dn[256];
480
481 found_user = CtdlTryUserLDAP(username, ldap_dn, sizeof ldap_dn, ldap_cn, sizeof ldap_cn, &ldap_uid);
482 if (found_user != 0) {
483 return login_not_found;
484 }
485
486 found_user = getuserbyuid(&CC->user, ldap_uid);
487 if (found_user != 0) {
489 found_user = getuserbyuid(&CC->user, ldap_uid);
490 }
491
492 if (found_user == 0) {
493 if (CC->ldap_dn != NULL) free(CC->ldap_dn);
494 CC->ldap_dn = strdup(ldap_dn);
495 }
496
497 }
498
499 // native auth mode...
500 else {
501 struct recptypes *valid = NULL;
502
503 // First, try to log in as if the supplied name is a display name
504 found_user = CtdlGetUser(&CC->user, username);
505
506 // If that didn't work, try to log in as if the supplied name * is an e-mail address
507 if (found_user != 0) {
508 valid = validate_recipients(username, NULL, 0);
509 if (valid != NULL) {
510 if (valid->num_local == 1) {
511 found_user = CtdlGetUser(&CC->user, valid->recp_local);
512 }
513 free_recipients(valid);
514 }
515 }
516 }
517
518 // User 0 is a system account and must not be used by a real user
519 if (CC->user.usernum <= 0) {
520 syslog(LOG_DEBUG, "user_ops: system account <%s> is not allowed to log in.", trythisname);
521 return login_not_found;
522 }
523
524 // Did we find something?
525 if (found_user == 0) {
526 if (((CC->nologin)) && (CC->user.axlevel < AxAideU)) {
528 }
529 else {
530 safestrncpy(CC->curr_user, CC->user.fullname, sizeof CC->curr_user);
531 return login_ok;
532 }
533 }
534 return login_not_found;
535}
536
537
538// session startup code which is common to both cmd_pass() and cmd_newu()
539void do_login(void) {
540 CC->logged_in = 1;
541 syslog(LOG_NOTICE, "user_ops: <%s> logged in", CC->curr_user);
542
543 CtdlGetUserLock(&CC->user, CC->curr_user);
544 CC->previous_login = CC->user.lastcall;
545 time(&CC->user.lastcall);
546
547 // If this user's name is the name of the system administrator
548 // (as specified in setup), automatically assign access level 6.
549 if ( (!IsEmptyStr(CtdlGetConfigStr("c_sysadm"))) && (!strcasecmp(CC->user.fullname, CtdlGetConfigStr("c_sysadm"))) ) {
550 CC->user.axlevel = AxAideU;
551 }
552
553 // If we're authenticating off the host system, automatically give root the highest level of access.
554 if (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_HOST) {
555 if (CC->user.uid == 0) {
556 CC->user.axlevel = AxAideU;
557 }
558 }
559 CtdlPutUserLock(&CC->user);
560
561 // If we are using LDAP authentication, extract the user's email addresses from the directory.
562 if ((CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP) || (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP_AD)) {
563 char new_emailaddrs[512];
564 if (CtdlGetConfigInt("c_ldap_sync_email_addrs") > 0) {
565 if (extract_email_addresses_from_ldap(CC->ldap_dn, new_emailaddrs) == 0) {
566 CtdlSetEmailAddressesForUser(CC->user.fullname, new_emailaddrs);
567 }
568 }
569 }
570
571 // If the user does not have any email addresses assigned, generate one.
572 if (IsEmptyStr(CC->user.emailaddrs)) {
574 }
575
576 // Populate the user principal identity, which is consistent and never aliased
577 strcpy(CC->cs_principal_id, "");
578 makeuserkey(CC->cs_principal_id, CC->user.fullname);
579 strcat(CC->cs_principal_id, "@");
580 strcat(CC->cs_principal_id, CtdlGetConfigStr("c_fqdn"));
581
582 // Populate cs_inet_email and cs_inet_other_emails with valid email addresses from the user record
583 strcpy(CC->cs_inet_email, CC->user.emailaddrs);
584 char *firstsep = strstr(CC->cs_inet_email, "|");
585 if (firstsep) {
586 strcpy(CC->cs_inet_other_emails, firstsep+1);
587 *firstsep = 0;
588 }
589 else {
590 CC->cs_inet_other_emails[0] = 0;
591 }
592
593 // Create any personal rooms required by the system.
594 // (Technically, MAILROOM should be there already, but just in case...)
595 CtdlCreateRoom(MAILROOM, 4, "", 0, 1, 0, VIEW_MAILBOX);
596 CtdlCreateRoom(SENTITEMS, 4, "", 0, 1, 0, VIEW_MAILBOX);
597 CtdlCreateRoom(USERTRASHROOM, 4, "", 0, 1, 0, VIEW_MAILBOX);
598 CtdlCreateRoom(USERDRAFTROOM, 4, "", 0, 1, 0, VIEW_MAILBOX);
599
600 // Run any startup routines registered by loadable modules
602
603 // Enter the lobby
604 CtdlUserGoto(CtdlGetConfigStr("c_baseroom"), 0, 0, NULL, NULL, NULL, NULL);
605}
606
607
609 cprintf("%d %s|%d|0|0|%u|%ld|%ld\n",
610 CIT_OK, CC->user.fullname, CC->user.axlevel,
611 CC->user.flags, CC->user.usernum,
612 CC->previous_login
613 );
614}
615
616
617void CtdlUserLogout(void) {
618
619 syslog(LOG_DEBUG, "user_ops: CtdlUserLogout() logging out <%s> from session %d", CC->curr_user, CC->cs_pid);
620
621 // Run any hooks registered by modules...
623
624 // Clear out some session data. Most likely, the CitContext for this
625 // session is about to get nuked when the session disconnects, but
626 // since it's possible to log in again without reconnecting, we cannot
627 // make that assumption.
628 CC->logged_in = 0;
629
630 // Check to see if the user was deleted while logged in and purge them if necessary
631 if ((CC->user.axlevel == AxDeleted) && (CC->user.usernum)) {
632 purge_user(CC->user.fullname);
633 }
634
635 // Clear out the user record in memory so we don't behave like a ghost
636 memset(&CC->user, 0, sizeof(struct ctdluser));
637 CC->curr_user[0] = 0;
638 CC->cs_inet_email[0] = 0;
639 CC->cs_inet_other_emails[0] = 0;
640 CC->cs_inet_fn[0] = 0;
641
642 // Free any output buffers
644}
645
646
647// Validate a password on the host unix system by talking to the chkpwd daemon
648static int validpw(uid_t uid, const char *pass) {
649 char buf[256];
650 int rv = 0;
651
652 if (IsEmptyStr(pass)) {
653 syslog(LOG_DEBUG, "user_ops: refusing to chkpwd for uid=%d with empty password", uid);
654 return 0;
655 }
656
657 syslog(LOG_DEBUG, "user_ops: validating password for uid=%d using chkpwd...", uid);
658
660 rv = write(chkpwd_write_pipe[1], &uid, sizeof(uid_t));
661 if (rv == -1) {
662 syslog(LOG_ERR, "user_ops: communication with chkpwd broken: %m");
664 return 0;
665 }
666 rv = write(chkpwd_write_pipe[1], pass, 256);
667 if (rv == -1) {
668 syslog(LOG_ERR, "user_ops: communication with chkpwd broken: %m");
670 return 0;
671 }
672 rv = read(chkpwd_read_pipe[0], buf, 4);
673 if (rv == -1) {
674 syslog(LOG_ERR, "user_ops: ommunication with chkpwd broken: %m");
676 return 0;
677 }
679
680 if (!strncmp(buf, "PASS", 4)) {
681 syslog(LOG_DEBUG, "user_ops: chkpwd pass");
682 return(1);
683 }
684
685 syslog(LOG_DEBUG, "user_ops: chkpwd fail");
686 return 0;
687}
688
689
690// Start up the chkpwd daemon so validpw() has something to talk to
692 pid_t chkpwd_pid;
693 struct stat filestats;
694 int i;
695
696 syslog(LOG_DEBUG, "user_ops: starting chkpwd daemon for host authentication mode");
697
698 if ((stat(file_chkpwd, &filestats)==-1) || (filestats.st_size==0)) {
699 syslog(LOG_ERR, "user_ops: %s: %m", file_chkpwd);
700 exit(CTDLEXIT_CHKPWD);
701 }
702 if (pipe(chkpwd_write_pipe) != 0) {
703 syslog(LOG_ERR, "user_ops: unable to create pipe for chkpwd daemon: %m");
704 exit(CTDLEXIT_CHKPWD);
705 }
706 if (pipe(chkpwd_read_pipe) != 0) {
707 syslog(LOG_ERR, "user_ops: unable to create pipe for chkpwd daemon: %m");
708 exit(CTDLEXIT_CHKPWD);
709 }
710
711 chkpwd_pid = fork();
712 if (chkpwd_pid < 0) {
713 syslog(LOG_ERR, "user_ops: unable to fork chkpwd daemon: %m");
714 exit(CTDLEXIT_CHKPWD);
715 }
716 if (chkpwd_pid == 0) {
717 dup2(chkpwd_write_pipe[0], 0);
718 dup2(chkpwd_read_pipe[1], 1);
719 for (i=2; i<256; ++i) close(i);
720 execl(file_chkpwd, file_chkpwd, NULL);
721 syslog(LOG_ERR, "user_ops: unable to exec chkpwd daemon: %m");
722 exit(errno);
723 }
724}
725
726
727int CtdlTryPassword(const char *password, long len) {
728 int code;
729
730 if ((CC->logged_in)) {
731 syslog(LOG_WARNING, "user_ops: CtdlTryPassword: already logged in");
733 }
734 if (!strcmp(CC->curr_user, NLI)) {
735 syslog(LOG_WARNING, "user_ops: CtdlTryPassword: no user selected");
736 return pass_no_user;
737 }
738 if (CtdlGetUser(&CC->user, CC->curr_user)) {
739 syslog(LOG_ERR, "user_ops: CtdlTryPassword: internal error");
740 return pass_internal_error;
741 }
742 if (password == NULL) {
743 syslog(LOG_INFO, "user_ops: CtdlTryPassword: NULL password string supplied");
744 return pass_wrong_password;
745 }
746
747 // host auth mode...
748 else if (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_HOST) {
749 if (validpw(CC->user.uid, password)) {
750 code = 0;
751
752 // sooper-seekrit hack: populate the password field in the
753 // citadel database with the password that the user typed,
754 // if it's correct. This allows most sites to convert from
755 // host auth to native auth if they want to. If you think
756 // this is a security hazard, comment it out.
757
758 CtdlGetUserLock(&CC->user, CC->curr_user);
759 safestrncpy(CC->user.password, password, sizeof CC->user.password);
760 CtdlPutUserLock(&CC->user);
761
762 // (sooper-seekrit hack ends here)
763 }
764 else {
765 code = (-1);
766 }
767 }
768
769 // LDAP auth mode...
770 else if ((CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP) || (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP_AD)) {
771
772 if ((CC->ldap_dn) && (!CtdlTryPasswordLDAP(CC->ldap_dn, password))) {
773 code = 0;
774 }
775 else {
776 code = (-1);
777 }
778 }
779
780 // native auth mode...
781 else {
782 char *pw;
783
784 pw = (char*) malloc(len + 1);
785 memcpy(pw, password, len + 1);
786 strproc(pw);
787 strproc(CC->user.password);
788 code = strcasecmp(CC->user.password, pw);
789 if (code != 0) {
790 strproc(pw);
791 strproc(CC->user.password);
792 code = strcasecmp(CC->user.password, pw);
793 }
794 free (pw);
795 }
796
797 if (!code) {
798 do_login();
799 return pass_ok;
800 }
801 else {
802 syslog(LOG_WARNING, "user_ops: bad password specified for <%s> Service <%s> Port <%ld> Remote <%s / %s>",
803 CC->curr_user,
804 CC->ServiceName,
805 CC->tcp_port,
806 CC->cs_host,
807 CC->cs_addr
808 );
809 return pass_wrong_password;
810 }
811}
812
813
814// Delete a user record *and* all of its related resources.
815int purge_user(char pname[]) {
816 struct ctdluser usbuf;
817 char usernamekey[USERNAME_SIZE];
818
819 makeuserkey(usernamekey, pname);
820
821 // If the name is empty we can't find them in the DB any way so just return
822 if (IsEmptyStr(pname)) {
823 return(ERROR + NO_SUCH_USER);
824 }
825
826 if (CtdlGetUser(&usbuf, pname) != 0) {
827 syslog(LOG_ERR, "user_ops: cannot purge user <%s> - not found", pname);
828 return(ERROR + NO_SUCH_USER);
829 }
830
831 // Don't delete a user who is currently logged in. Instead, just
832 // set the access level to 0, and let the account get swept up
833 // during the next purge.
834 if (CtdlIsUserLoggedInByNum(usbuf.usernum)) {
835 syslog(LOG_WARNING, "user_ops: <%s> is logged in; not deleting", pname);
836 usbuf.axlevel = AxDeleted;
837 CtdlPutUser(&usbuf);
838 return(1);
839 }
840
841 syslog(LOG_NOTICE, "user_ops: deleting <%s>", pname);
842
843 // Perform any purge functions registered by server extensions
845
846 // delete any existing user/room relationships
847 // Commenting out since it was assuming the user number was
848 // at the top of the index. Room number is actually first.
849 // Auto-Purge will clean up the records later, so not worth
850 // scanning all the records here.
851 //cdb_delete(CDB_VISIT, &usbuf.usernum, sizeof(long));
852
853 // delete the users-by-number index record
854 cdb_delete(CDB_USERSBYNUMBER, &usbuf.usernum, sizeof(long));
855
856 // delete the user entry
857 cdb_delete(CDB_USERS, usernamekey, strlen(usernamekey));
858
859 return(0);
860}
861
862
863// This is the back end processing that happens when we create a new user account.
864int internal_create_user(char *username, struct ctdluser *usbuf, uid_t uid) {
865 if (!CtdlGetUser(usbuf, username)) {
866 return(ERROR + ALREADY_EXISTS);
867 }
868
869 // Go ahead and initialize a new user record
870 memset(usbuf, 0, sizeof(struct ctdluser));
871 safestrncpy(usbuf->fullname, username, sizeof usbuf->fullname);
872 strcpy(usbuf->password, "");
873 usbuf->uid = uid;
874
875 // These are the default flags on new accounts
877 usbuf->axlevel = CtdlGetConfigInt("c_initax");
878 usbuf->lastcall = time(NULL);
879
880 // fetch a new user number
881 usbuf->usernum = get_new_user_number();
882
883 // add user to the database
884 CtdlPutUser(usbuf);
885 cdb_store(CDB_USERSBYNUMBER, &usbuf->usernum, sizeof(long), usbuf->fullname, strlen(usbuf->fullname)+1);
886
887 // If non-native auth, index by uid
888 if ((usbuf->uid > 0) && (usbuf->uid != NATIVE_AUTH_UID)) {
889 StrBuf *claimed_id = NewStrBuf();
890 StrBufPrintf(claimed_id, "uid:%d", usbuf->uid);
891 FreeStrBuf(&claimed_id);
892 }
893
894 return(0);
895}
896
897
898// create_user() - back end processing to create a new user
899//
900// Set 'newusername' to the desired account name.
901// Set 'become_user' to CREATE_USER_BECOME_USER if this is self-service account creation and we want to
902// actually log in as the user we just created, otherwise set it to CREATE_USER_DO_NOT_BECOME_USER
903// Set 'uid' to some uid_t value to associate the account with an external auth user, or (-1) for native auth
904int create_user(char *username, int become_user, uid_t uid) {
905 struct ctdluser usbuf;
906 struct ctdlroom qrbuf;
907 char mailboxname[ROOMNAMELEN];
908 char buf[SIZ];
909 int retval;
910
911 strproc(username);
912 if ((retval = internal_create_user(username, &usbuf, uid)) != 0) {
913 return retval;
914 }
915
916 // Give the user a private mailbox and a configuration room.
917 // Make the latter an invisible system room.
918 CtdlMailboxName(mailboxname, sizeof mailboxname, &usbuf, MAILROOM);
919 CtdlCreateRoom(mailboxname, 5, "", 0, 1, 1, VIEW_MAILBOX);
920
921 CtdlMailboxName(mailboxname, sizeof mailboxname, &usbuf, USERCONFIGROOM);
922 CtdlCreateRoom(mailboxname, 5, "", 0, 1, 1, VIEW_BBS);
923 if (CtdlGetRoomLock(&qrbuf, mailboxname) == 0) {
924 qrbuf.QRflags2 |= QR2_SYSTEM;
925 CtdlPutRoomLock(&qrbuf);
926 }
927
928 // Perform any create functions registered by server extensions
930
931 // Everything below this line can be bypassed if administratively
932 // creating a user, instead of doing self-service account creation
933
934 if (become_user == CREATE_USER_BECOME_USER) {
935 // Now become the user we just created
936 memcpy(&CC->user, &usbuf, sizeof(struct ctdluser));
937 safestrncpy(CC->curr_user, username, sizeof CC->curr_user);
938 do_login();
939
940 // Check to make sure we're still who we think we are
941 if (CtdlGetUser(&CC->user, CC->curr_user)) {
942 return(ERROR + INTERNAL_ERROR);
943 }
944 }
945
946 snprintf(buf, SIZ,
947 "New user account <%s> has been created, from host %s [%s].\n",
948 username,
949 CC->cs_host,
950 CC->cs_addr
951 );
952 CtdlAideMessage(buf, "User Creation Notice");
953 syslog(LOG_NOTICE, "user_ops: <%s> created", username);
954 return(0);
955}
956
957
958// set password - back end api code
959void CtdlSetPassword(char *new_pw) {
960 CtdlGetUserLock(&CC->user, CC->curr_user);
961 safestrncpy(CC->user.password, new_pw, sizeof(CC->user.password));
962 CtdlPutUserLock(&CC->user);
963 syslog(LOG_INFO, "user_ops: password changed for <%s>", CC->curr_user);
965}
966
967
968// API function for cmd_invt_kick() and anything else that needs to
969// invite or kick out a user to/from a room.
970//
971// Set iuser to the name of the user, and op to 1=invite or 0=kick
972int CtdlInvtKick(char *iuser, int op) {
973 struct ctdluser USscratch;
974 struct visit vbuf;
975 char bbb[SIZ];
976
977 if (CtdlGetUser(&USscratch, iuser) != 0) {
978 return(1);
979 }
980
981 CtdlGetRelationship(&vbuf, &USscratch, &CC->room);
982 if (op == 1) {
983 vbuf.v_flags = vbuf.v_flags & ~V_FORGET & ~V_LOCKOUT;
984 vbuf.v_flags = vbuf.v_flags | V_ACCESS;
985 }
986 if (op == 0) {
987 vbuf.v_flags = vbuf.v_flags & ~V_ACCESS;
988 vbuf.v_flags = vbuf.v_flags | V_FORGET | V_LOCKOUT;
989 }
990 CtdlSetRelationship(&vbuf, &USscratch, &CC->room);
991
992 // post a message in Aide> saying what we just did
993 snprintf(bbb, sizeof bbb, "%s has been %s \"%s\" by %s.\n",
994 iuser,
995 ((op == 1) ? "invited to" : "kicked out of"),
996 CC->room.QRname,
997 (CC->logged_in ? CC->user.fullname : "an administrator")
998 );
999 CtdlAideMessage(bbb,"User Admin Message");
1000 return(0);
1001}
1002
1003
1004// Forget (Zap) the current room (API call)
1005// Returns 0 on success
1007 struct visit vbuf;
1008
1009 // On some systems, Admins are not allowed to forget rooms
1010 if (is_aide() && (CtdlGetConfigInt("c_aide_zap") == 0)
1011 && ((CC->room.QRflags & QR_MAILBOX) == 0) ) {
1012 return(1);
1013 }
1014
1015 CtdlGetUserLock(&CC->user, CC->curr_user);
1016 CtdlGetRelationship(&vbuf, &CC->user, &CC->room);
1017
1018 vbuf.v_flags = vbuf.v_flags | V_FORGET;
1019 vbuf.v_flags = vbuf.v_flags & ~V_ACCESS;
1020
1021 CtdlSetRelationship(&vbuf, &CC->user, &CC->room);
1022 CtdlPutUserLock(&CC->user);
1023
1024 // Return to the Lobby, so we don't end up in an undefined room
1025 CtdlUserGoto(CtdlGetConfigStr("c_baseroom"), 0, 0, NULL, NULL, NULL, NULL);
1026 return(0);
1027}
1028
1029
1030// Traverse the user file and perform a callback for each user record.
1031// (New improved version that runs in two phases so that callbacks can perform writes without having a r/o cursor open)
1032void ForEachUser(void (*CallBack) (char *, void *out_data), void *in_data) {
1033 struct cdbkeyval cdbus;
1034 struct ctdluser *usptr;
1035
1036 Array *all_users = array_new(USERNAME_SIZE);
1037 if (all_users == NULL) {
1038 syslog(LOG_ERR, "user_ops: alloc failed, ForEachUser() exiting");
1039 return;
1040 }
1041
1042
1043 // Phase 1 : build an array of all our user account names
1045 while (cdbus = cdb_next_item(CDB_USERS), cdbus.val.ptr!=NULL) { // always read through to the end
1046 usptr = (struct ctdluser *) cdbus.val.ptr;
1047 if (strlen(usptr->fullname) > 0) {
1048 array_append(all_users, usptr->fullname);
1049 }
1050 }
1051
1052 // Phase 2 : perform the callback for each user while de-allocating the list
1053 for (int i=0; i<array_len(all_users); ++i) {
1054 (*CallBack) (array_get_element_at(all_users, i), in_data);
1055 }
1056
1057 // Phase 3 : free the array
1058 array_free(all_users);
1059}
1060
1061
1062// Return the number of new messages that have arrived in the user's inbox while they were logged in.
1063// Resets to zero when called.
1065 int num_newmsgs = 0;
1066 num_newmsgs = CC->newmail;
1067 CC->newmail = 0;
1068 return(num_newmsgs);
1069}
1070
1071
1072// Count the number of new mail messages the user has
1074 int num_newmsgs = 0;
1075 int a;
1076 char mailboxname[ROOMNAMELEN];
1077 struct ctdlroom mailbox;
1078 struct visit vbuf;
1079 long *msglist = NULL;
1080 int num_msgs = 0;
1081
1082 CtdlMailboxName(mailboxname, sizeof mailboxname, &CC->user, MAILROOM);
1083 if (CtdlGetRoom(&mailbox, mailboxname) != 0) {
1084 return(0);
1085 }
1086 CtdlGetRelationship(&vbuf, &CC->user, &mailbox);
1087
1088 num_msgs = CtdlFetchMsgList(mailbox.QRnumber, &msglist);
1089 if (num_msgs > 0) {
1090 for (a = 0; a < num_msgs; ++a) {
1091 if (msglist[a] > 0L) {
1092 if (msglist[a] > vbuf.v_lastseen) {
1093 ++num_newmsgs;
1094 }
1095 }
1096 }
1097 }
1098 free(msglist);
1099 return(num_newmsgs);
1100}
1101
1102
1103// This is an undocumented rescue mode that can be used to rewrite an admin user account that has been corrupted.
1104// To prevent abuse, it can only run as a one-shot when the server is not otherwise operational.
1105// Don't use this without asking about it.
1107 struct ctdluser usbuf;
1108 memset(&usbuf, 0, sizeof(struct ctdluser));
1109 extract_token(usbuf.fullname, rescue_string, 0, '|', sizeof usbuf.password);
1110 extract_token(usbuf.password, rescue_string, 1, '|', sizeof usbuf.password);
1111 usbuf.usernum = extract_long(rescue_string, 2);
1112 usbuf.axlevel = 6;
1113 usbuf.lastcall = time(NULL);
1114 CtdlPutUser(&usbuf);
1115}
#define ROOMNAMELEN
#define AUTHMODE_HOST
#define REV_LEVEL
#define AUTHMODE_LDAP
#define V_FORGET
#define V_ACCESS
@ CDB_VISIT
@ CDB_USERSBYNUMBER
@ CDB_USERS
#define CTDLEXIT_CHKPWD
#define USERNAME_SIZE
#define V_LOCKOUT
@ EVT_PURGEUSER
@ EVT_NEWUSER
@ EVT_LOGIN
@ EVT_LOGOUT
@ EVT_SETPASS
@ S_CHKPWD
@ S_USERS
#define AUTHMODE_LDAP_AD
#define file_chkpwd
int CtdlTryPasswordLDAP(char *user_dn, const char *password)
Definition ldap.c:226
int extract_email_addresses_from_ldap(char *ldap_dn, char *emailaddrs)
Definition ldap.c:447
int CtdlTryUserLDAP(char *username, char *found_dn, int found_dn_size, char *fullname, int fullname_size, uid_t *found_uid)
Definition ldap.c:149
char * CtdlGetConfigStr(char *key)
Definition config.c:360
int CtdlGetConfigInt(char *key)
Definition config.c:386
int CtdlIsUserLoggedInByNum(long usernum)
Definition context.c:152
int CtdlIsUserLoggedIn(char *user_name)
Definition context.c:131
#define CC
Definition context.h:131
long get_new_user_number(void)
Definition control.c:178
int CtdlGetRoom(struct ctdlroom *qrbuf, const char *room_name)
Definition room_ops.c:302
@ pass_internal_error
@ pass_ok
@ pass_no_user
@ pass_already_logged_in
@ pass_wrong_password
#define CtdlAideMessage(TEXT, SUBJECT)
Definition ctdl_module.h:59
int CtdlGetRoomLock(struct ctdlroom *qrbuf, const char *room_name)
Definition room_ops.c:339
@ ac_room_aide
@ ac_logged_in_or_guest
@ ac_aide
@ ac_logged_in
@ ac_internal
@ login_too_many_users
@ login_not_found
@ login_ok
@ login_already_logged_in
unsigned CtdlCreateRoom(char *new_room_name, int new_room_type, char *new_room_pass, int new_room_floor, int really_create, int avoid_access, int new_room_view)
Definition room_ops.c:1024
void CtdlUserGoto(char *where, int display_result, int transiently, int *msgs, int *new, long *oldest, long *newest)
Definition room_ops.c:626
void CtdlPutRoomLock(struct ctdlroom *qrbuf)
Definition room_ops.c:383
struct cdbkeyval(* cdb_next_item)(int)
Definition database.c:32
struct cdbdata(* cdb_fetch)(int, const void *, int)
Definition database.c:29
int(* cdb_delete)(int, void *, int)
Definition database.c:31
int(* cdb_store)(int, const void *, int, void *, int)
Definition database.c:30
void(* cdb_rewind)(int)
Definition database.c:41
void(* cdb_trunc)(int)
Definition database.c:37
struct recptypes * validate_recipients(char *supplied_recipients, const char *RemoteIdentifier, int Flags)
void free_recipients(struct recptypes *valid)
void CtdlSetEmailAddressesForUser(char *requested_user, char *new_emailaddrs)
void AutoGenerateEmailAddressForUser(struct ctdluser *user)
#define CIT_OK
Definition ipcdef.h:2
#define US_PAGINATOR
Definition ipcdef.h:67
#define US_FLOORS
Definition ipcdef.h:69
#define INTERNAL_ERROR
Definition ipcdef.h:10
#define HIGHER_ACCESS_REQUIRED
Definition ipcdef.h:19
#define US_DISAPPEAR
Definition ipcdef.h:65
#define US_LASTOLD
Definition ipcdef.h:60
#define QR_MAILBOX
Definition ipcdef.h:49
#define NOT_LOGGED_IN
Definition ipcdef.h:13
#define ERROR
Definition ipcdef.h:5
#define ALREADY_EXISTS
Definition ipcdef.h:29
#define QR2_SYSTEM
Definition ipcdef.h:51
#define NO_SUCH_USER
Definition ipcdef.h:25
#define US_INTERNET
Definition ipcdef.h:68
void makeuserkey(char *key, const char *username)
Definition makeuserkey.c:22
void * malloc(unsigned)
void free(void *)
int CtdlFetchMsgList(long roomnum, long **msgs)
Definition room_ops.c:600
void PerformSessionHooks(int EventType)
void PerformUserHooks(ctdluser *usbuf, int EventType)
char * rescue_string
Definition server_main.c:28
size_t len
Definition server.h:71
char * ptr
Definition server.h:72
struct cdbdata val
Definition server.h:79
unsigned QRflags2
Definition server.h:188
long QRnumber
Definition server.h:186
time_t QRgen
Definition server.h:179
int QRdefaultview
Definition server.h:189
unsigned flags
Definition server.h:145
cit_uint8_t axlevel
Definition server.h:148
char fullname[64]
Definition server.h:152
time_t lastcall
Definition server.h:150
uid_t uid
Definition server.h:143
long usernum
Definition server.h:149
int version
Definition server.h:142
char password[32]
Definition server.h:144
char * recp_local
Definition server.h:43
int num_local
Definition server.h:38
long iRoomGen
Definition server.h:101
long iRoomID
Definition server.h:100
long iUserID
Definition server.h:102
Definition server.h:86
long v_lastseen
Definition server.h:90
unsigned v_flags
Definition server.h:91
long v_usernum
Definition server.h:89
long v_roomnum
Definition server.h:87
char v_seen[4096]
Definition server.h:92
int v_view
Definition server.h:94
long v_roomgen
Definition server.h:88
void strproc(char *string)
Definition support.c:16
#define USERCONFIGROOM
Definition sysconfig.h:41
#define MAILROOM
Definition sysconfig.h:38
#define USERDRAFTROOM
Definition sysconfig.h:46
#define SENTITEMS
Definition sysconfig.h:39
#define USERTRASHROOM
Definition sysconfig.h:47
#define SIZ
Definition sysconfig.h:22
#define NLI
Definition sysconfig.h:11
void cprintf(const char *format,...)
Definition sysdep.c:363
void unbuffer_output(void)
Definition sysdep.c:262
void begin_critical_section(int which_one)
Definition threads.c:50
void end_critical_section(int which_one)
Definition threads.c:63
void CtdlGetRelationship(struct visit *vbuf, struct ctdluser *rel_user, struct ctdlroom *rel_room)
Definition user_ops.c:236
void CtdlPutUser(struct ctdluser *usbuf)
Definition user_ops.c:86
void CtdlMailboxName(char *buf, size_t n, const struct ctdluser *who, const char *prefix)
Definition user_ops.c:263
void ForEachUser(void(*CallBack)(char *, void *out_data), void *in_data)
Definition user_ops.c:1032
int CtdlLockGetCurrentUser(void)
Definition user_ops.c:68
int CtdlLoginExistingUser(const char *trythisname)
Definition user_ops.c:419
int internal_create_user(char *username, struct ctdluser *usbuf, uid_t uid)
Definition user_ops.c:864
void CtdlSetPassword(char *new_pw)
Definition user_ops.c:959
void do_login(void)
Definition user_ops.c:539
void CtdlSetRelationship(struct visit *newvisit, struct ctdluser *rel_user, struct ctdlroom *rel_room)
Definition user_ops.c:223
int CtdlUserCmp(char *s1, char *s2)
Definition user_ops.c:32
int CtdlAccessCheck(int required_level)
Definition user_ops.c:292
int is_aide(void)
Definition user_ops.c:329
void rebuild_usersbynumber(void)
Definition user_ops.c:384
void reindex_user_928(char *username, void *out_data)
Definition user_ops.c:177
int getuserbyuid(struct ctdluser *usbuf, uid_t number)
Definition user_ops.c:392
int purge_user(char pname[])
Definition user_ops.c:815
void CtdlPutCurrentUserLock()
Definition user_ops.c:94
int NewMailCount()
Definition user_ops.c:1064
int CtdlGetUserByNumber(struct ctdluser *usbuf, long number)
Definition user_ops.c:356
static int validpw(uid_t uid, const char *pass)
Definition user_ops.c:648
int create_user(char *username, int become_user, uid_t uid)
Definition user_ops.c:904
int CtdlForgetThisRoom(void)
Definition user_ops.c:1006
int GenerateRelationshipIndex(char *IndexBuf, long RoomID, long RoomGen, long UserID)
Definition user_ops.c:206
int CtdlCheckInternetMailPermission(struct ctdluser *who)
Definition user_ops.c:270
int is_room_aide(void)
Definition user_ops.c:340
void CtdlUserLogout(void)
Definition user_ops.c:617
int CtdlGetUserLock(struct ctdluser *usbuf, char *name)
Definition user_ops.c:74
void makeuserkey_pre928(char *key, const char *username)
Definition user_ops.c:160
int CtdlInvtKick(char *iuser, int op)
Definition user_ops.c:972
void put_visit(struct visit *newvisit)
Definition user_ops.c:217
int rename_user(char *oldname, char *newname)
Definition user_ops.c:108
void logged_in_response(void)
Definition user_ops.c:608
void start_chkpwd_daemon(void)
Definition user_ops.c:691
int CtdlTryPassword(const char *password, long len)
Definition user_ops.c:727
void undocumented_rescue_mode(char *rescue_string)
Definition user_ops.c:1106
void CtdlPutUserLock(struct ctdluser *usbuf)
Definition user_ops.c:100
int InitialMailCheck()
Definition user_ops.c:1073
void rebuild_ubn_for_user(char *username, void *data)
Definition user_ops.c:373
int chkpwd_read_pipe[2]
Definition user_ops.c:27
int chkpwd_write_pipe[2]
Definition user_ops.c:26
int CtdlGetUser(struct ctdluser *usbuf, char *name)
Definition user_ops.c:44
@ 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