*
*/
+#ifdef DLL_EXPORT
+#define IN_LIBCIT
+#endif
+
#include "sysdep.h"
#include <errno.h>
#include <stdlib.h>
#include <pwd.h>
#include <sys/types.h>
#include <sys/wait.h>
-#include <sys/time.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
#include <string.h>
#include <syslog.h>
#include <limits.h>
#include "server.h"
#include "database.h"
#include "user_ops.h"
+#include "dynloader.h"
#include "sysdep_decls.h"
#include "support.h"
#include "room_ops.h"
#include "control.h"
#include "msgbase.h"
#include "config.h"
-#include "dynloader.h"
#include "tools.h"
#include "citserver.h"
((cdbvisit->len > sizeof(struct visit)) ?
sizeof(struct visit) : cdbvisit->len));
cdb_free(cdbvisit);
- return;
+ }
+
+ /* Set v_seen if necessary */
+ if (vbuf->v_seen[0] == 0) {
+ sprintf(vbuf->v_seen, "*:%ld", vbuf->v_lastseen);
}
}
sizeof(struct usersupp) : cdbus->len));
cdb_free(cdbus);
if (usbuf->usernum == number) {
+ cdb_close_cursor(CDB_USERSUPP);
return (0);
}
}
/*
* Back end for cmd_user() and its ilk
*/
-int CtdlLoginExistingUser(char *username)
+int CtdlLoginExistingUser(char *trythisname)
{
- char autoname[256];
+ char username[SIZ];
+ char autoname[SIZ];
int found_user = 0;
struct passwd *p;
int a;
- username[25] = 0;
+ if (trythisname == NULL) return login_not_found;
+ safestrncpy(username, trythisname, sizeof username);
strproc(username);
if ((CC->logged_in)) {
*/
void cmd_user(char *cmdbuf)
{
- char username[256];
+ char username[SIZ];
int a;
extract(username, cmdbuf, 0);
void logout(struct CitContext *who)
{
who->logged_in = 0;
+
+ /*
+ * If there is a download in progress, abort it.
+ */
if (who->download_fp != NULL) {
fclose(who->download_fp);
who->download_fp = NULL;
}
+
+ /*
+ * If there is an upload in progress, abort it.
+ */
if (who->upload_fp != NULL) {
abort_upl(who);
}
+
+ /*
+ * If we were talking to a network node, we're not anymore...
+ */
+ if (strlen(who->net_node) > 0) {
+ network_talking_to(who->net_node, NTT_REMOVE);
+ }
+
/* Do modular stuff... */
PerformSessionHooks(EVT_LOGOUT);
}
int code;
if ((CC->logged_in)) {
+ lprintf(5, "CtdlTryPassword: already logged in\n");
return pass_already_logged_in;
}
if (!strcmp(CC->curr_user, NLI)) {
+ lprintf(5, "CtdlTryPassword: no user selected\n");
return pass_no_user;
}
if (getuser(&CC->usersupp, CC->curr_user)) {
+ lprintf(5, "CtdlTryPassword: internal error\n");
return pass_internal_error;
}
+ if (password == NULL) {
+ lprintf(5, "CtdlTryPassword: NULL password string supplied\n");
+ return pass_wrong_password;
+ }
code = (-1);
if (CC->usersupp.uid == BBSUID) {
strproc(password);
void cmd_pass(char *buf)
{
- char password[256];
+ char password[SIZ];
int a;
extract(password, buf, 0);
int a;
struct passwd *p = NULL;
char username[64];
- char mailboxname[ROOMNAMELEN];
strcpy(username, newusername);
strproc(username);
return (ERROR + INTERNAL_ERROR);
}
/* give the user a private mailbox */
- MailboxName(mailboxname, &CC->usersupp, MAILROOM);
- create_room(mailboxname, 4, "", 0);
+ create_room(MAILROOM, 4, "", 0, 1);
rec_log(CL_NEWUSER, CC->curr_user);
return (0);
void cmd_newu(char *cmdbuf)
{
int a;
- char username[256];
+ char username[SIZ];
if ((CC->logged_in)) {
cprintf("%d Already logged in.\n", ERROR);
long newlr;
struct visit vbuf;
- if (CtdlAccessCheck(ac_logged_in))
+ if (CtdlAccessCheck(ac_logged_in)) {
return;
+ }
if (!strncasecmp(new_ptr, "highest", 7)) {
newlr = CC->quickroom.QRhighest;
CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
vbuf.v_lastseen = newlr;
+ sprintf(vbuf.v_seen, "*:%ld", newlr);
CtdlSetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
lputuser(&CC->usersupp);
}
+void cmd_seen(char *argbuf) {
+ long target_msgnum = 0L;
+ int target_setting = 0;
+
+ if (CtdlAccessCheck(ac_logged_in)) {
+ return;
+ }
+
+ if (num_parms(argbuf) != 2) {
+ cprintf("%d Invalid parameters\n", ERROR);
+ return;
+ }
+
+ target_msgnum = extract_long(argbuf, 0);
+ target_setting = extract_int(argbuf, 1);
+
+ CtdlSetSeen(target_msgnum, target_setting);
+ cprintf("%d OK\n", OK);
+}
+
+
/*
* INVT and KICK commands
*/
/* user name */
{ /* 1 = invite, 0 = kick out */
struct usersupp USscratch;
- char bbb[256];
+ char bbb[SIZ];
struct visit vbuf;
if (CtdlAccessCheck(ac_room_aide))
/*
- * forget (Zap) the current room
+ * Forget (Zap) the current room (API call)
+ * Returns 0 on success
*/
-void cmd_forg(void)
-{
+int CtdlForgetThisRoom(void) {
struct visit vbuf;
- if (CtdlAccessCheck(ac_logged_in)) {
- return;
- }
-
+ /* On some systems, Aides are not allowed to forget rooms */
if (is_aide() && (config.c_aide_zap == 0)) {
- cprintf("%d Aides cannot forget rooms.\n", ERROR);
- return;
+ return(1);
}
lgetuser(&CC->usersupp, CC->curr_user);
CtdlSetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
lputuser(&CC->usersupp);
- cprintf("%d Ok\n", OK);
+
+ /* Return to the Lobby, so we don't end up in an undefined room */
usergoto(BASEROOM, 0, NULL, NULL);
+ return(0);
+
+}
+
+
+/*
+ * forget (Zap) the current room
+ */
+void cmd_forg(void)
+{
+
+ if (CtdlAccessCheck(ac_logged_in)) {
+ return;
+ }
+
+ if (CtdlForgetThisRoom() == 0) {
+ cprintf("%d Ok\n", OK);
+ }
+ else {
+ cprintf("%d You may not forget this room.\n", ERROR);
+ }
}
/*
if ((usbuf.flags & US_NEEDVALID)
&& (usbuf.axlevel > 0)) {
cprintf("%d %s\n", MORE_DATA, usbuf.fullname);
+ cdb_close_cursor(CDB_USERSUPP);
return;
}
}
*/
void cmd_vali(char *v_args)
{
- char user[256];
+ char user[SIZ];
int newax;
struct usersupp userbuf;
void cmd_agup(char *cmdbuf)
{
struct usersupp usbuf;
- char requested_user[256];
+ char requested_user[SIZ];
if (CtdlAccessCheck(ac_aide)) {
return;
void cmd_asup(char *cmdbuf)
{
struct usersupp usbuf;
- char requested_user[256];
+ char requested_user[SIZ];
int np;
int newax;
int deleted = 0;