1 // Server functions which perform operations on user objects.
3 // Copyright (c) 1987-2022 by the citadel.org team
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.
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.
16 #include "ctdl_module.h"
17 #include "citserver.h"
20 #include "internet_addressing.h"
23 // USER command -- attempt to log in as an existing user
24 void cmd_user(char *cmdbuf) {
28 extract_token(username, cmdbuf, 0, '|', sizeof username);
30 syslog(LOG_DEBUG, "user_ops: cmd_user(%s)", username);
32 a = CtdlLoginExistingUser(username);
34 case login_already_logged_in:
35 cprintf("%d Already logged in.\n", ERROR + ALREADY_LOGGED_IN);
37 case login_too_many_users:
39 "Too many users are already online "
41 ERROR + MAX_SESSIONS_EXCEEDED,
42 CtdlGetConfigStr("c_nodename"), CtdlGetConfigInt("c_maxsessions"));
45 cprintf("%d Password required for %s\n", MORE_DATA, CC->curr_user);
48 cprintf("%d %s not found.\n", ERROR + NO_SUCH_USER, username);
51 cprintf("%d Internal error\n", ERROR + INTERNAL_ERROR);
56 // PASS command -- complete logging in as an existing user (used after USER returns MORE_DATA)
57 void cmd_pass(char *buf) {
62 memset(password, 0, sizeof(password));
63 len = extract_token(password, buf, 0, '|', sizeof password);
64 a = CtdlTryPassword(password, len);
67 case pass_already_logged_in:
68 cprintf("%d Already logged in.\n", ERROR + ALREADY_LOGGED_IN);
71 cprintf("%d You must send a name with USER first.\n",
72 ERROR + USERNAME_REQUIRED);
74 case pass_wrong_password:
75 cprintf("%d Wrong password.\n", ERROR + PASSWORD_REQUIRED);
84 // cmd_newu() - create a new user account and log in as that user
85 void cmd_newu(char *cmdbuf) {
89 if (CtdlGetConfigInt("c_auth_mode") != AUTHMODE_NATIVE) {
90 cprintf("%d This system does not use native mode authentication.\n",
95 if (CtdlGetConfigInt("c_disable_newu")) {
96 cprintf("%d Self-service user account creation is disabled on this system.\n", ERROR + NOT_HERE);
101 cprintf("%d Already logged in.\n", ERROR + ALREADY_LOGGED_IN);
105 cprintf("%d %s: Too many users are already online (maximum is %d)\n",
106 ERROR + MAX_SESSIONS_EXCEEDED,
107 CtdlGetConfigStr("c_nodename"), CtdlGetConfigInt("c_maxsessions"));
110 extract_token(username, cmdbuf, 0, '|', sizeof username);
113 if (IsEmptyStr(username)) {
114 cprintf("%d You must supply a user name.\n", ERROR + USERNAME_REQUIRED);
118 if ((!strcasecmp(username, "bbs")) ||
119 (!strcasecmp(username, "new")) ||
120 (!strcasecmp(username, "."))
122 cprintf("%d '%s' is an invalid login name.\n", ERROR + ILLEGAL_VALUE, username);
126 a = create_user(username, CREATE_USER_BECOME_USER, NATIVE_AUTH_UID);
129 logged_in_response();
131 else if (a == ERROR + ALREADY_EXISTS) {
132 cprintf("%d '%s' already exists.\n",
133 ERROR + ALREADY_EXISTS, username);
136 else if (a == ERROR + INTERNAL_ERROR) {
137 cprintf("%d Internal error - user record disappeared?\n",
138 ERROR + INTERNAL_ERROR);
142 cprintf("%d unknown error\n", ERROR + INTERNAL_ERROR);
147 // set password - citadel protocol implementation
148 void cmd_setp(char *new_pw) {
149 if (CtdlAccessCheck(ac_logged_in)) {
152 if ( (CC->user.uid != CTDLUID) && (CC->user.uid != (-1)) ) {
153 cprintf("%d Not allowed. Use the 'passwd' command.\n", ERROR + NOT_HERE);
157 if (!strcasecmp(new_pw, "GENERATE_RANDOM_PASSWORD")) {
158 char random_password[17];
159 snprintf(random_password, sizeof random_password, "%08lx%08lx", random(), random());
160 CtdlSetPassword(random_password);
161 cprintf("%d %s\n", CIT_OK, random_password);
165 if (IsEmptyStr(new_pw)) {
166 cprintf("%d Password unchanged.\n", CIT_OK);
169 CtdlSetPassword(new_pw);
170 cprintf("%d Password changed.\n", CIT_OK);
175 // cmd_creu() - administratively create a new user account (do not log in to it)
176 void cmd_creu(char *cmdbuf) {
182 if (CtdlAccessCheck(ac_aide)) {
186 extract_token(username, cmdbuf, 0, '|', sizeof username);
189 if (IsEmptyStr(username)) {
190 cprintf("%d You must supply a user name.\n", ERROR + USERNAME_REQUIRED);
194 extract_token(password, cmdbuf, 1, '|', sizeof password);
196 a = create_user(username, CREATE_USER_DO_NOT_BECOME_USER, NATIVE_AUTH_UID);
199 if (!IsEmptyStr(password)) {
200 CtdlGetUserLock(&tmp, username);
201 safestrncpy(tmp.password, password, sizeof(tmp.password));
202 CtdlPutUserLock(&tmp);
204 cprintf("%d User '%s' created %s.\n", CIT_OK, username, (!IsEmptyStr(password)) ? "and password set" : "with no password");
207 else if (a == ERROR + ALREADY_EXISTS) {
208 cprintf("%d '%s' already exists.\n", ERROR + ALREADY_EXISTS, username);
211 else if ( (CtdlGetConfigInt("c_auth_mode") != AUTHMODE_NATIVE) && (a == ERROR + NO_SUCH_USER) ) {
212 cprintf("%d User accounts are not created within Citadel in host authentication mode.\n", ERROR + NO_SUCH_USER);
216 cprintf("%d An error occurred creating the user account.\n", ERROR + INTERNAL_ERROR);
221 // get user parameters
222 void cmd_getu(char *cmdbuf) {
223 if (CtdlAccessCheck(ac_logged_in)) {
227 CtdlGetUser(&CC->user, CC->curr_user);
228 cprintf("%d 80|24|%d|\n", CIT_OK, (CC->user.flags & US_USER_SET));
232 // set user parameters
233 void cmd_setu(char *new_parms) {
234 if (CtdlAccessCheck(ac_logged_in)) {
238 if (num_parms(new_parms) < 3) {
239 cprintf("%d Usage error.\n", ERROR + ILLEGAL_VALUE);
242 CtdlLockGetCurrentUser();
243 CC->user.flags = CC->user.flags & (~US_USER_SET);
244 CC->user.flags = CC->user.flags | (extract_int(new_parms, 2) & US_USER_SET);
245 CtdlPutCurrentUserLock();
246 cprintf("%d Ok\n", CIT_OK);
250 // set last read pointer (marks all messages in the current room as read, up to the specified point)
251 void cmd_slrp(char *new_ptr) {
256 if (CtdlAccessCheck(ac_logged_in)) {
260 if (!strncasecmp(new_ptr, "highest", 7)) {
261 newlr = CC->room.QRhighest;
264 newlr = atol(new_ptr);
267 CtdlLockGetCurrentUser();
269 CtdlGetRelationship(&vbuf, &CC->user, &CC->room);
270 memcpy(&original_vbuf, &vbuf, sizeof(visit));
271 vbuf.v_lastseen = newlr;
272 snprintf(vbuf.v_seen, sizeof vbuf.v_seen, "*:%ld", newlr);
274 // Only rewrite the record if it changed
275 if ( (vbuf.v_lastseen != original_vbuf.v_lastseen)
276 || (strcmp(vbuf.v_seen, original_vbuf.v_seen))
278 CtdlSetRelationship(&vbuf, &CC->user, &CC->room);
281 CtdlPutCurrentUserLock();
282 cprintf("%d %ld\n", CIT_OK, newlr);
286 void cmd_seen(char *argbuf) {
287 long target_msgnum = 0L;
288 int target_setting = 0;
290 if (CtdlAccessCheck(ac_logged_in)) {
294 if (num_parms(argbuf) != 2) {
295 cprintf("%d Invalid parameters\n", ERROR + ILLEGAL_VALUE);
299 target_msgnum = extract_long(argbuf, 0);
300 target_setting = extract_int(argbuf, 1);
302 CtdlSetSeen(&target_msgnum, 1, target_setting,
303 ctdlsetseen_seen, NULL, NULL);
304 cprintf("%d OK\n", CIT_OK);
308 void cmd_gtsn(char *argbuf) {
311 if (CtdlAccessCheck(ac_logged_in)) {
315 // Learn about the user and room in question
316 CtdlGetRelationship(&vbuf, &CC->user, &CC->room);
318 cprintf("%d ", CIT_OK);
319 client_write(vbuf.v_seen, strlen(vbuf.v_seen));
320 client_write(HKEY("\n"));
324 // INVT and KICK commands (grant/revoke access to an invitation-only room)
325 void cmd_invt_kick(char *iuser, int op) {
327 // These commands are only allowed by admins, room admins,
328 // and room namespace owners
329 if (is_room_aide()) {
332 else if ( ((atol(CC->room.QRname) == CC->user.usernum) ) && (CC->user.usernum != 0) ) {
337 cprintf("%d Higher access or room ownership required.\n", ERROR + HIGHER_ACCESS_REQUIRED);
341 if (!strncasecmp(CC->room.QRname, CtdlGetConfigStr("c_baseroom"), ROOMNAMELEN)) {
342 cprintf("%d Can't add/remove users from this room.\n", ERROR + NOT_HERE);
346 if (CtdlInvtKick(iuser, op) != 0) {
347 cprintf("%d No such user.\n", ERROR + NO_SUCH_USER);
351 cprintf("%d %s %s %s.\n",
353 ((op == 1) ? "invited to" : "kicked out of"),
359 void cmd_invt(char *iuser) {
360 cmd_invt_kick(iuser, 1);
364 void cmd_kick(char *iuser) {
365 cmd_invt_kick(iuser, 0);
369 // forget (Zap) the current room
370 void cmd_forg(char *argbuf) {
372 if (CtdlAccessCheck(ac_logged_in)) {
376 if (CtdlForgetThisRoom() == 0) {
377 cprintf("%d Ok\n", CIT_OK);
380 cprintf("%d You may not forget this room.\n", ERROR + NOT_HERE);
385 // Get Next Unregistered User
386 void cmd_gnur(char *argbuf) {
387 struct cdbdata *cdbus;
388 struct ctdluser usbuf;
390 if (CtdlAccessCheck(ac_aide)) {
394 if ((CtdlGetConfigInt("MMflags") & MM_VALID) == 0) {
395 cprintf("%d There are no unvalidated users.\n", CIT_OK);
399 // There are unvalidated users. Traverse the user database, and return the first user we find that needs validation.
400 cdb_rewind(CDB_USERS);
401 while (cdbus = cdb_next_item(CDB_USERS), cdbus != NULL) {
402 memset(&usbuf, 0, sizeof(struct ctdluser));
403 memcpy(&usbuf, cdbus->ptr, ((cdbus->len > sizeof(struct ctdluser)) ? sizeof(struct ctdluser) : cdbus->len));
405 if ((usbuf.flags & US_NEEDVALID) && (usbuf.axlevel > AxDeleted)) {
406 cprintf("%d %s\n", MORE_DATA, usbuf.fullname);
407 cdb_close_cursor(CDB_USERS);
412 // If we get to this point, there are no more unvalidated users. Therefore we clear the "users need validation" flag.
413 begin_critical_section(S_CONTROL);
415 flags = CtdlGetConfigInt("MMflags");
416 flags = flags & (~MM_VALID);
417 CtdlSetConfigInt("MMflags", flags);
418 end_critical_section(S_CONTROL);
419 cprintf("%d *** End of registration.\n", CIT_OK);
424 void cmd_vali(char *v_args) {
427 struct ctdluser userbuf;
429 extract_token(user, v_args, 0, '|', sizeof user);
430 newax = extract_int(v_args, 1);
432 if (CtdlAccessCheck(ac_aide) || (newax > AxAideU) || (newax < AxDeleted)) {
436 if (CtdlGetUserLock(&userbuf, user) != 0) {
437 cprintf("%d '%s' not found.\n", ERROR + NO_SUCH_USER, user);
441 userbuf.axlevel = newax;
442 userbuf.flags = (userbuf.flags & ~US_NEEDVALID);
444 CtdlPutUserLock(&userbuf);
446 // If the access level was set to zero, delete the user
448 if (purge_user(user) == 0) {
449 cprintf("%d %s Deleted.\n", CIT_OK, userbuf.fullname);
453 cprintf("%d User '%s' validated.\n", CIT_OK, userbuf.fullname);
457 // List one user (this works with cmd_list)
458 void ListThisUser(char *username, void *data) {
460 struct ctdluser usbuf;
462 if (CtdlGetUser(&usbuf, username) != 0) {
466 searchstring = (char *)data;
467 if (bmstrcasestr(usbuf.fullname, searchstring) == NULL) {
471 if (usbuf.axlevel > AxDeleted) {
472 if ((CC->user.axlevel >= AxAideU)
473 || ((usbuf.flags & US_UNLISTED) == 0)
474 || ((CC->internal_pgm))) {
475 cprintf("%s|%d|%ld|%ld|%ld|%ld||\n",
479 (long)usbuf.lastcall,
487 // List users (searchstring may be empty to list all users)
488 void cmd_list(char *cmdbuf) {
489 char searchstring[256];
490 extract_token(searchstring, cmdbuf, 0, '|', sizeof searchstring);
491 striplt(searchstring);
492 cprintf("%d \n", LISTING_FOLLOWS);
493 ForEachUser(ListThisUser, (void *)searchstring );
498 // assorted info we need to check at login
499 void cmd_chek(char *argbuf) {
504 if (CtdlAccessCheck(ac_logged_in)) {
508 CtdlGetUser(&CC->user, CC->curr_user); // no lock is needed here
509 if ((REGISCALL != 0) && ((CC->user.flags & US_REGIS) == 0)) {
513 if (CC->user.axlevel >= AxAideU) {
514 if (CtdlGetConfigInt("MMflags") & MM_VALID) {
519 mail = InitialMailCheck(); // check for mail
520 cprintf("%d %d|%d|%d|%s|\n", CIT_OK, mail, regis, vali, CC->cs_inet_email);
524 // check to see if a user exists
525 void cmd_qusr(char *who) {
526 struct ctdluser usbuf;
528 if (CtdlGetUser(&usbuf, who) == 0) {
529 cprintf("%d %s\n", CIT_OK, usbuf.fullname);
532 cprintf("%d No such user.\n", ERROR + NO_SUCH_USER);
537 // Administrative Get User Parameters
538 void cmd_agup(char *cmdbuf) {
539 struct ctdluser usbuf;
540 char requested_user[128];
542 if (CtdlAccessCheck(ac_aide)) {
546 extract_token(requested_user, cmdbuf, 0, '|', sizeof requested_user);
547 if (CtdlGetUser(&usbuf, requested_user) != 0) {
548 cprintf("%d No such user.\n", ERROR + NO_SUCH_USER);
551 cprintf("%d %s|%s|%u|%ld|%ld|%d|%ld|%ld|%d\n",
560 (long)usbuf.lastcall,
565 // Administrative Set User Parameters
566 void cmd_asup(char *cmdbuf) {
567 struct ctdluser usbuf;
568 char requested_user[128];
574 if (CtdlAccessCheck(ac_aide))
577 extract_token(requested_user, cmdbuf, 0, '|', sizeof requested_user);
578 if (CtdlGetUserLock(&usbuf, requested_user) != 0) {
579 cprintf("%d No such user.\n", ERROR + NO_SUCH_USER);
582 np = num_parms(cmdbuf);
584 extract_token(usbuf.password, cmdbuf, 1, '|', sizeof usbuf.password);
586 usbuf.flags = extract_int(cmdbuf, 2);
588 usbuf.timescalled = extract_int(cmdbuf, 3);
590 usbuf.posted = extract_int(cmdbuf, 4);
592 newax = extract_int(cmdbuf, 5);
593 if ((newax >= AxDeleted) && (newax <= AxAideU)) {
594 usbuf.axlevel = newax;
598 usbuf.lastcall = extract_long(cmdbuf, 7);
601 usbuf.USuserpurge = extract_int(cmdbuf, 8);
603 CtdlPutUserLock(&usbuf);
604 if (usbuf.axlevel == AxDeleted) {
605 if (purge_user(requested_user) == 0) {
611 snprintf(notify, SIZ,
612 "User \"%s\" has been deleted by %s.\n",
613 usbuf.fullname, (CC->logged_in ? CC->user.fullname : "an administrator")
615 CtdlAideMessage(notify, "User Deletion Message");
618 cprintf("%d Ok", CIT_OK);
620 cprintf(" (%s deleted)", requested_user);
626 // Citadel protocol command to do the same
627 void cmd_isme(char *argbuf) {
630 if (CtdlAccessCheck(ac_logged_in)) return;
631 extract_token(addr, argbuf, 0, '|', sizeof addr);
633 if (CtdlIsMe(addr, sizeof addr)) {
634 cprintf("%d %s\n", CIT_OK, addr);
637 cprintf("%d Not you.\n", ERROR + ILLEGAL_VALUE);
643 // Retrieve all Internet email addresses/aliases for the specified user
644 void cmd_agea(char *cmdbuf) {
645 struct ctdluser usbuf;
646 char requested_user[128];
650 if (CtdlAccessCheck(ac_aide)) {
654 extract_token(requested_user, cmdbuf, 0, '|', sizeof requested_user);
655 if (CtdlGetUser(&usbuf, requested_user) != 0) {
656 cprintf("%d No such user.\n", ERROR + NO_SUCH_USER);
659 cprintf("%d internet email addresses for %s\n", LISTING_FOLLOWS, usbuf.fullname);
660 num_e = num_tokens(usbuf.emailaddrs, '|');
661 for (i=0; i<num_e; ++i) {
662 extract_token(e, usbuf.emailaddrs, i, '|', sizeof e);
669 // Set the Internet email addresses/aliases for the specified user
670 void cmd_asea(char *cmdbuf) {
671 struct ctdluser usbuf;
672 char requested_user[128];
675 char new_emailaddrs[512] = { 0 } ;
677 if (CtdlAccessCheck(ac_aide)) return;
679 extract_token(requested_user, cmdbuf, 0, '|', sizeof requested_user);
680 if (CtdlGetUser(&usbuf, requested_user) != 0) {
681 cprintf("%d No such user.\n", ERROR + NO_SUCH_USER);
685 cprintf("%d Ok\n", SEND_LISTING);
686 while (client_getln(buf, sizeof buf) >= 0 && strcmp(buf, "000")) {
687 if (IsEmptyStr(buf)) {
688 syslog(LOG_ERR, "user_ops: address <%s> is empty - not using", buf);
690 else if ((strlen(new_emailaddrs) + strlen(buf) + 2) > sizeof(new_emailaddrs)) {
691 syslog(LOG_ERR, "user_ops: address <%s> does not fit in buffer - not using", buf);
693 else if (!IsDirectory(buf, 0)) {
694 syslog(LOG_ERR, "user_ops: address <%s> is not in one of our domains - not using", buf);
696 else if ( (CtdlDirectoryLookup(whodat, buf, sizeof whodat) == 0) && (CtdlUserCmp(whodat, requested_user)) ) {
697 syslog(LOG_ERR, "user_ops: address <%s> already belongs to <%s> - not using", buf, whodat);
700 syslog(LOG_DEBUG, "user_ops: address <%s> validated", buf);
701 if (!IsEmptyStr(new_emailaddrs)) {
702 strcat(new_emailaddrs, "|");
704 strcat(new_emailaddrs, buf);
708 CtdlSetEmailAddressesForUser(requested_user, new_emailaddrs);
712 // Set the preferred view for the current user/room combination
713 void cmd_view(char *cmdbuf) {
717 if (CtdlAccessCheck(ac_logged_in)) {
721 requested_view = extract_int(cmdbuf, 0);
723 CtdlGetRelationship(&vbuf, &CC->user, &CC->room);
724 vbuf.v_view = requested_view;
725 CtdlSetRelationship(&vbuf, &CC->user, &CC->room);
727 cprintf("%d ok\n", CIT_OK);
732 void cmd_renu(char *cmdbuf) {
734 char oldname[USERNAME_SIZE];
735 char newname[USERNAME_SIZE];
737 if (CtdlAccessCheck(ac_aide)) {
741 extract_token(oldname, cmdbuf, 0, '|', sizeof oldname);
742 extract_token(newname, cmdbuf, 1, '|', sizeof newname);
744 retcode = rename_user(oldname, newname);
747 cprintf("%d '%s' has been renamed to '%s'.\n", CIT_OK, oldname, newname);
749 case RENAMEUSER_LOGGED_IN:
750 cprintf("%d '%s' is currently logged in and cannot be renamed.\n",
751 ERROR + ALREADY_LOGGED_IN , oldname
754 case RENAMEUSER_NOT_FOUND:
755 cprintf("%d '%s' does not exist.\n", ERROR + NO_SUCH_USER, oldname);
757 case RENAMEUSER_ALREADY_EXISTS:
758 cprintf("%d A user named '%s' already exists.\n", ERROR + ALREADY_EXISTS, newname);
762 cprintf("%d An unknown error occurred.\n", ERROR);
766 void cmd_quit(char *argbuf) {
767 cprintf("%d Goodbye.\n", CIT_OK);
768 CC->kill_me = KILLME_CLIENT_LOGGED_OUT;
772 void cmd_lout(char *argbuf) {
775 cprintf("%d logged out.\n", CIT_OK);
779 /*****************************************************************************/
780 /* MODULE INITIALIZATION STUFF */
781 /*****************************************************************************/
784 CTDL_MODULE_INIT(serv_user)
787 CtdlRegisterProtoHook(cmd_user, "USER", "Submit username for login");
788 CtdlRegisterProtoHook(cmd_pass, "PASS", "Complete login by submitting a password");
789 CtdlRegisterProtoHook(cmd_quit, "QUIT", "log out and disconnect from server");
790 CtdlRegisterProtoHook(cmd_lout, "LOUT", "log out but do not disconnect from server");
791 CtdlRegisterProtoHook(cmd_creu, "CREU", "Create User");
792 CtdlRegisterProtoHook(cmd_setp, "SETP", "Set the password for an account");
793 CtdlRegisterProtoHook(cmd_getu, "GETU", "Get User parameters");
794 CtdlRegisterProtoHook(cmd_setu, "SETU", "Set User parameters");
795 CtdlRegisterProtoHook(cmd_slrp, "SLRP", "Set Last Read Pointer");
796 CtdlRegisterProtoHook(cmd_invt, "INVT", "Invite a user to a room");
797 CtdlRegisterProtoHook(cmd_kick, "KICK", "Kick a user out of a room");
798 CtdlRegisterProtoHook(cmd_forg, "FORG", "Forget a room");
799 CtdlRegisterProtoHook(cmd_gnur, "GNUR", "Get Next Unregistered User");
800 CtdlRegisterProtoHook(cmd_vali, "VALI", "Validate new users");
801 CtdlRegisterProtoHook(cmd_list, "LIST", "List users");
802 CtdlRegisterProtoHook(cmd_chek, "CHEK", "assorted info we need to check at login");
803 CtdlRegisterProtoHook(cmd_qusr, "QUSR", "check to see if a user exists");
804 CtdlRegisterProtoHook(cmd_agup, "AGUP", "Administratively Get User Parameters");
805 CtdlRegisterProtoHook(cmd_asup, "ASUP", "Administratively Set User Parameters");
806 CtdlRegisterProtoHook(cmd_agea, "AGEA", "Administratively Get Email Addresses");
807 CtdlRegisterProtoHook(cmd_asea, "ASEA", "Administratively Set Email Addresses");
808 CtdlRegisterProtoHook(cmd_seen, "SEEN", "Manipulate seen/unread message flags");
809 CtdlRegisterProtoHook(cmd_gtsn, "GTSN", "Fetch seen/unread message flags");
810 CtdlRegisterProtoHook(cmd_view, "VIEW", "Set preferred view for user/room combination");
811 CtdlRegisterProtoHook(cmd_renu, "RENU", "Rename a user");
812 CtdlRegisterProtoHook(cmd_newu, "NEWU", "Log in as a new user");
813 CtdlRegisterProtoHook(cmd_isme, "ISME", "Determine whether an email address belongs to a user");
815 /* return our Subversion id for the Log */