/*
* Server functions which perform operations on user objects.
*
- * Copyright (c) 1987-2011 by the citadel.org team
+ * Copyright (c) 1987-2017 by the citadel.org team
*
* This program is open source software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, version 3.
* GNU General Public License for more details.
*/
+
#include "support.h"
#include "control.h"
#include "ctdl_module.h"
-
#include "citserver.h"
-
+#include "config.h"
#include "user_ops.h"
#include "internet_addressing.h"
-
/*
* USER cmd
*/
char username[256];
int a;
- CON_syslog(LOG_DEBUG, "cmd_user(%s)\n", cmdbuf);
extract_token(username, cmdbuf, 0, '|', sizeof username);
- CON_syslog(LOG_DEBUG, "username: %s\n", username);
striplt(username);
- CON_syslog(LOG_DEBUG, "username: %s\n", username);
+ syslog(LOG_DEBUG, "user_ops: cmd_user(%s)", username);
a = CtdlLoginExistingUser(NULL, username);
switch (a) {
"Too many users are already online "
"(maximum is %d)\n",
ERROR + MAX_SESSIONS_EXCEEDED,
- config.c_nodename, config.c_maxsessions);
+ CtdlGetConfigStr("c_nodename"), CtdlGetConfigInt("c_maxsessions"));
return;
case login_ok:
cprintf("%d Password required for %s\n",
long len;
char username[SIZ];
- if (config.c_auth_mode != AUTHMODE_NATIVE) {
+ if (CtdlGetConfigInt("c_auth_mode") != AUTHMODE_NATIVE) {
cprintf("%d This system does not use native mode authentication.\n",
ERROR + NOT_HERE);
return;
}
- if (config.c_disable_newu) {
+ if (CtdlGetConfigInt("c_disable_newu")) {
cprintf("%d Self-service user account creation "
"is disabled on this system.\n", ERROR + NOT_HERE);
return;
if (CC->nologin) {
cprintf("%d %s: Too many users are already online (maximum is %d)\n",
ERROR + MAX_SESSIONS_EXCEEDED,
- config.c_nodename, config.c_maxsessions);
+ CtdlGetConfigStr("c_nodename"), CtdlGetConfigInt("c_maxsessions"));
return;
}
extract_token(username, cmdbuf, 0, '|', sizeof username);
}
}
+
/*
* set password - citadel protocol implementation
*/
safestrncpy(tmp.password, password, sizeof(tmp.password));
CtdlPutUserLock(&tmp);
}
- cprintf("%d User '%s' created %s.\n", CIT_OK, username,
- (!IsEmptyStr(password)) ? "and password set" :
- "with no password");
+ cprintf("%d User '%s' created %s.\n", CIT_OK, username, (!IsEmptyStr(password)) ? "and password set" : "with no password");
return;
} else if (a == ERROR + ALREADY_EXISTS) {
cprintf("%d '%s' already exists.\n", ERROR + ALREADY_EXISTS, username);
return;
- } else if ( (config.c_auth_mode != AUTHMODE_NATIVE) && (a == ERROR + NO_SUCH_USER) ) {
- cprintf("%d User accounts are not created within Citadel in host authentication mode.\n",
- ERROR + NO_SUCH_USER);
+ } else if ( (CtdlGetConfigInt("c_auth_mode") != AUTHMODE_NATIVE) && (a == ERROR + NO_SUCH_USER) ) {
+ cprintf("%d User accounts are not created within Citadel in host authentication mode.\n", ERROR + NO_SUCH_USER);
return;
} else {
cprintf("%d An error occurred creating the user account.\n", ERROR + INTERNAL_ERROR);
}
-
/*
* get user parameters
*/
void cmd_getu(char *cmdbuf)
{
-
if (CtdlAccessCheck(ac_logged_in))
return;
CtdlGetUser(&CC->user, CC->curr_user);
- cprintf("%d 80|24|%d|\n",
- CIT_OK,
- (CC->user.flags & US_USER_SET)
- );
+ cprintf("%d 80|24|%d|\n", CIT_OK, (CC->user.flags & US_USER_SET));
}
+
/*
* set user parameters
*/
cprintf("%d Ok\n", CIT_OK);
}
+
/*
* set last read pointer
*/
client_write(HKEY("\n"));
}
+
/*
* INVT and KICK commands
*/
/* access granted */
} else {
/* access denied */
- cprintf("%d Higher access or room ownership required.\n",
- ERROR + HIGHER_ACCESS_REQUIRED);
+ cprintf("%d Higher access or room ownership required.\n", ERROR + HIGHER_ACCESS_REQUIRED);
return;
}
- if (!strncasecmp(CC->room.QRname, config.c_baseroom,
+ if (!strncasecmp(CC->room.QRname, CtdlGetConfigStr("c_baseroom"),
ROOMNAMELEN)) {
- cprintf("%d Can't add/remove users from this room.\n",
- ERROR + NOT_HERE);
+ cprintf("%d Can't add/remove users from this room.\n", ERROR + NOT_HERE);
return;
}
return;
}
-void cmd_invt(char *iuser) {cmd_invt_kick(iuser, 1);}
-void cmd_kick(char *iuser) {cmd_invt_kick(iuser, 0);}
+
+void cmd_invt(char *iuser) {
+ cmd_invt_kick(iuser, 1);
+}
+
+
+void cmd_kick(char *iuser) {
+ cmd_invt_kick(iuser, 0);
+}
/*
}
}
+
/*
* Get Next Unregistered User
*/
return;
}
- if ((CitControl.MMflags & MM_VALID) == 0) {
+ if ((CtdlGetConfigInt("MMflags") & MM_VALID) == 0) {
cprintf("%d There are no unvalidated users.\n", CIT_OK);
return;
}
cdb_rewind(CDB_USERS);
while (cdbus = cdb_next_item(CDB_USERS), cdbus != NULL) {
memset(&usbuf, 0, sizeof(struct ctdluser));
- memcpy(&usbuf, cdbus->ptr,
- ((cdbus->len > sizeof(struct ctdluser)) ?
- sizeof(struct ctdluser) : cdbus->len));
+ memcpy(&usbuf, cdbus->ptr, ((cdbus->len > sizeof(struct ctdluser)) ? sizeof(struct ctdluser) : cdbus->len));
cdb_free(cdbus);
- if ((usbuf.flags & US_NEEDVALID)
- && (usbuf.axlevel > AxDeleted)) {
+ if ((usbuf.flags & US_NEEDVALID) && (usbuf.axlevel > AxDeleted)) {
cprintf("%d %s\n", MORE_DATA, usbuf.fullname);
cdb_close_cursor(CDB_USERS);
return;
*/
begin_critical_section(S_CONTROL);
- get_control();
- CitControl.MMflags = CitControl.MMflags & (~MM_VALID);
- put_control();
+ int flags;
+ flags = CtdlGetConfigInt("MMflags");
+ flags = flags & (~MM_VALID);
+ CtdlSetConfigInt("MMflags", flags);
end_critical_section(S_CONTROL);
cprintf("%d *** End of registration.\n", CIT_OK);
-
-
}
extract_token(user, v_args, 0, '|', sizeof user);
newax = extract_int(v_args, 1);
- if (CtdlAccessCheck(ac_aide) ||
- (newax > AxAideU) ||
- (newax < AxDeleted)) {
+ if (CtdlAccessCheck(ac_aide) || (newax > AxAideU) || (newax < AxDeleted)) {
return;
}
}
-
-
/*
* assorted info we need to check at login
*/
return;
}
- CtdlGetUser(&CC->user, CC->curr_user); /* no lock is needed here */
- if ((REGISCALL != 0) && ((CC->user.flags & US_REGIS) == 0))
+ CtdlGetUser(&CC->user, CC->curr_user); // no lock is needed here
+ if ((REGISCALL != 0) && ((CC->user.flags & US_REGIS) == 0)) {
regis = 1;
+ }
if (CC->user.axlevel >= AxAideU) {
- get_control();
- if (CitControl.MMflags & MM_VALID)
+ if (CtdlGetConfigInt("MMflags") & MM_VALID) {
vali = 1;
+ }
}
- /* check for mail */
- mail = InitialMailCheck();
+ mail = InitialMailCheck(); // check for mail
cprintf("%d %d|%d|%d|%s|\n", CIT_OK, mail, regis, vali, CC->cs_inet_email);
}
}
-
/*
* Administrative Set User Parameters
*/
if (deleted) {
snprintf(notify, SIZ,
- "User \"%s\" has been deleted by %s.\n",
- usbuf.fullname,
- (CC->logged_in ? CC->user.fullname : "an administrator")
+ "User \"%s\" has been deleted by %s.\n",
+ usbuf.fullname, (CC->logged_in ? CC->user.fullname : "an administrator")
);
CtdlAideMessage(notify, "User Deletion Message");
}
cprintf("%d Ok", CIT_OK);
- if (deleted)
+ if (deleted) {
cprintf(" (%s deleted)", requested_user);
+ }
cprintf("\n");
}
return;
case RENAMEUSER_LOGGED_IN:
cprintf("%d '%s' is currently logged in and cannot be renamed.\n",
- ERROR + ALREADY_LOGGED_IN , oldname);
+ ERROR + ALREADY_LOGGED_IN , oldname
+ );
return;
case RENAMEUSER_NOT_FOUND:
cprintf("%d '%s' does not exist.\n", ERROR + NO_SUCH_USER, oldname);
}
-
void cmd_quit(char *argbuf)
{
cprintf("%d Goodbye.\n", CIT_OK);