#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>
((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);
}
}
{
struct cdbdata *cdbus;
+ cdb_begin_transaction();
cdb_rewind(CDB_USERSUPP);
while (cdbus = cdb_next_item(CDB_USERSUPP), cdbus != NULL) {
sizeof(struct usersupp) : cdbus->len));
cdb_free(cdbus);
if (usbuf->usernum == number) {
+ cdb_end_transaction();
return (0);
}
}
+ cdb_end_transaction();
return (-1);
}
/*
* 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 session_startup(void)
{
- syslog(LOG_NOTICE, "user <%s> logged in", CC->curr_user);
+ syslog(LOG_NOTICE, "session %d: user <%s> logged in",
+ CC->cs_pid, CC->curr_user);
lgetuser(&CC->usersupp, CC->curr_user);
++(CC->usersupp.timescalled);
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);
+ }
}
/*
/* There are unvalidated users. Traverse the usersupp database,
* and return the first user we find that needs validation.
*/
+ cdb_begin_transaction();
cdb_rewind(CDB_USERSUPP);
while (cdbus = cdb_next_item(CDB_USERSUPP), cdbus != NULL) {
memset(&usbuf, 0, sizeof(struct usersupp));
if ((usbuf.flags & US_NEEDVALID)
&& (usbuf.axlevel > 0)) {
cprintf("%d %s\n", MORE_DATA, usbuf.fullname);
+ cdb_end_transaction();
return;
}
}
+ cdb_end_transaction();
/* If we get to this point, there are no more unvalidated users.
* Therefore we clear the "users need validation" flag.
*/
void cmd_vali(char *v_args)
{
- char user[256];
+ char user[SIZ];
int newax;
struct usersupp userbuf;
struct usersupp usbuf;
struct cdbdata *cdbus;
+ cdb_begin_transaction();
cdb_rewind(CDB_USERSUPP);
while (cdbus = cdb_next_item(CDB_USERSUPP), cdbus != NULL) {
cdb_free(cdbus);
(*CallBack) (&usbuf, in_data);
}
+ cdb_end_transaction();
}
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;