to 5.55 format user records and generate vCards.
$Log$
+Revision 1.376 1999/10/03 21:48:21 ajc
+* Added serv_upgrade.h to automagically convert pre-5.55 format user records
+ to 5.55 format user records and generate vCards.
+
Revision 1.375 1999/09/29 21:13:17 ajc
* CtdlWriteObject() can now store objects in personal rooms for any specified
user -- rather than only the current user or non-personal rooms.
Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* Initial CVS import
+
CLIENT_TARGETS=citadel$(EXEEXT) whobbs$(EXEEXT)
SERVER_TARGETS=citserver setup $(CHKPWD)
SERV_MODULES=modules/serv_chat$(SO) modules/serv_vcard$(SO) \
+ modules/serv_upgrade$(SO) \
modules/serv_expire$(SO) modules/serv_icq$(SO)
UTIL_TARGETS=aidepost netmailer netproc netsetup msgform readlog rcit \
stats citmail netpoll mailinglist userlist sendcommand \
serv_info.c serv_test.c setup.c snprintf.c stats.c serv_vcard.c \
support.c sysdep.c tools.c user_ops.c userlist.c serv_expire.c \
whobbs.c sendcommand.c mime_parser.c base64.c qpdecode.c getutline.c \
- auth.c chkpwd.c client_icq.c html.c vcard.c
+ auth.c chkpwd.c client_icq.c html.c vcard.c serv_upgrade.c
DEP_FILES=$(SOURCES:.c=.d)
modules/serv_icq.mo: serv_icq.mo
ln -f serv_icq.mo modules
+modules/serv_upgrade.so: serv_upgrade.mo
+ $(LINK_SHARED) -o modules/serv_upgrade.so serv_upgrade.mo
+
+modules/serv_upgrade.mo: serv_upgrade.mo
+ ln -f serv_upgrade.mo modules
+
modules/serv_vcard.so: serv_vcard.mo vcard.mo
$(LINK_SHARED) -o modules/serv_vcard.so serv_vcard.mo vcard.mo
#include "sysdep.h"
#include "sysconfig.h"
#include "ipcdef.h"
-#define CITADEL "Citadel/UX 5.53"
-#define REV_LEVEL 553
+#define CITADEL "Citadel/UX 5.55"
+#define REV_LEVEL 555
#define SERVER_TYPE 0 /* zero for stock Citadel/UX; other developers please
obtain SERVER_TYPE codes for your implementations */
#define RESTRICT_INTERNET config.c_restrict
/* Defines the actual user record */
+
struct usersupp { /* User record */
- int USuid; /* userid (==BBSUID for bbs only) */
- char password[20]; /* password (for BBS-only users) */
+ int version; /* Cit vers. which created this rec */
+ uid_t uid; /* Associate with a unix account? */
+ char password[32]; /* password (for BBS-only users) */
unsigned flags; /* See US_ flags below */
- int timescalled; /* Total number of logins */
- int posted; /* Number of messages posted (ever) */
- char fullname[26]; /* Name for Citadel messages & mail */
- char axlevel; /* Access level */
- CIT_UBYTE USscreenwidth; /* Screen width (for textmode users)*/
- CIT_UBYTE USscreenheight; /* Screen height(for textmode users)*/
+ long timescalled; /* Total number of logins */
+ long posted; /* Number of messages posted (ever) */
+ CIT_UBYTE axlevel; /* Access level */
long usernum; /* User number (never recycled) */
time_t lastcall; /* Last time the user called */
- char USname[30]; /* Real name (i.e. not a handle) */
- char USaddr[25]; /* Street address */
- char UScity[15]; /* Municipality */
- char USstate[3]; /* State or province */
- char USzip[10]; /* ZIP code */
- char USphone[11]; /* Voice telephone number */
- char USemail[32]; /* E-mail address (elsewhere) */
int USuserpurge; /* Purge time (in days) for user */
+ char fullname[64]; /* Name for Citadel messages & mail */
+ CIT_UBYTE USscreenwidth; /* Screen width (for textmode users)*/
+ CIT_UBYTE USscreenheight; /* Screen height(for textmode users)*/
};
unsigned MMflags; /* Global system flags */
long MMnextuser; /* highest user number on system */
long MMnextroom; /* highest room number on system */
+ int version; /* Server-hosted upgrade level */
};
/* Bits which may appear in CitControl.MMflags. Note that these don't
};
-/* Private rooms are always flagged with QR_PRIVATE. If neither QR_PASSWORDED
- * or QR_GUESSNAME is set, then it is invitation-only. Passworded rooms are
+/* Private rooms are always flagged with QR_PRIVATE. If neither QR_PASSWORDED
+ * or QR_GUESSNAME is set, then it is invitation-only. Passworded rooms are
* flagged with both QR_PRIVATE and QR_PASSWORDED while guess-name rooms are
- * flagged with both QR_PRIVATE and QR_GUESSNAME. DO NOT set all three flags.
- *
- ****************************************************************************/
+ * flagged with both QR_PRIVATE and QR_GUESSNAME. NEVER set all three flags.
+ */
/*
* Events which might show up in the Citadel Log
#define MES_ERROR (-1) /* Can't send message due to bad address */
#define MES_LOCAL 0 /* Local message, do no network processing */
#define MES_INTERNET 1 /* Convert msg and send as Internet mail */
-#define MES_BINARY 2 /* Process recipient and send via C/UX net */
+#define MES_BINARY 2 /* Process recipient and send via Cit net */
/****************************************************************************/
--- /dev/null
+/* $Id$ */
+#include "sysdep.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <pwd.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <string.h>
+#include <limits.h>
+#ifdef HAVE_PTHREAD_H
+#include <pthread.h>
+#endif
+#include "citadel.h"
+#include "server.h"
+#include <syslog.h>
+#include <time.h>
+#include "sysdep_decls.h"
+#include "citserver.h"
+#include "support.h"
+#include "config.h"
+#include "control.h"
+#include "dynloader.h"
+#include "database.h"
+#include "user_ops.h"
+#include "msgbase.h"
+#include "serv_upgrade.h"
+
+void do_pre555_usersupp_upgrade(void) {
+ struct pre555usersupp usbuf;
+ struct usersupp newus;
+ struct cdbdata *cdbus;
+ char tempfilename[PATH_MAX];
+ FILE *fp, *tp;
+ static char vcard[1024];
+
+ lprintf(5, "Upgrading user file\n");
+ fp = tmpfile();
+ if (fp == NULL) {
+ lprintf(1, "%s\n", strerror(errno));
+ exit(errno);
+ }
+ strcpy(tempfilename, tmpnam(NULL));
+
+ /* First, back out all old version records to a flat file */
+ cdb_rewind(CDB_USERSUPP);
+ while(cdbus = cdb_next_item(CDB_USERSUPP), cdbus != NULL) {
+ memset(&usbuf, 0, sizeof(struct pre555usersupp));
+ memcpy(&usbuf, cdbus->ptr,
+ ( (cdbus->len > sizeof(struct pre555usersupp)) ?
+ sizeof(struct pre555usersupp) : cdbus->len) );
+ cdb_free(cdbus);
+ fwrite(&usbuf, sizeof(struct pre555usersupp), 1, fp);
+ }
+
+ /* ...and overwrite the records with new format records */
+ rewind(fp);
+ while (fread(&usbuf, sizeof(struct pre555usersupp), 1, fp) > 0) {
+ lprintf(9, "Upgrading <%s>\n", usbuf.fullname);
+ memset(&newus, 0, sizeof(struct usersupp));
+
+ newus.uid = usbuf.USuid;
+ strcpy(newus.password, usbuf.password);
+ newus.flags = usbuf.flags;
+ newus.timescalled = (long) usbuf.timescalled;
+ newus.posted = (long) usbuf.posted;
+ newus.axlevel = (CIT_UBYTE) usbuf.axlevel;
+ newus.usernum = (long) usbuf.usernum;
+ newus.lastcall = (long) usbuf.lastcall;
+ newus.USuserpurge = (int) usbuf.USuserpurge;
+ strcpy(newus.fullname, usbuf.fullname);
+ newus.USscreenwidth = (CIT_UBYTE) usbuf.USscreenwidth;
+ newus.USscreenheight = (CIT_UBYTE) usbuf.USscreenheight;
+
+ putuser(&newus);
+
+ /* write the vcard */
+ sprintf(vcard,
+ "Content-type: text/x-vcard\n\n"
+ "begin:vcard\n"
+ "n:%s\n"
+ "tel;home:%s\n"
+ "email;internet:%s\n"
+ "adr:;;%s;%s;%s;%s;USA\n"
+ "end:vcard\n",
+ usbuf.USname,
+ usbuf.USphone,
+ usbuf.USemail,
+ usbuf.USaddr,
+ usbuf.UScity,
+ usbuf.USstate,
+ usbuf.USzip);
+
+ tp = fopen(tempfilename, "w");
+ fwrite(vcard, strlen(vcard)+1, 1, tp);
+ fclose(tp);
+
+ CtdlWriteObject(CONFIGROOM, "text/x-vcard",
+ tempfilename, &newus, 0, 1);
+ unlink(tempfilename);
+
+ }
+
+ fclose(fp); /* this file deletes automatically */
+}
+
+
+
+
+
+
+
+
+void check_server_upgrades(void) {
+
+ get_control();
+ lprintf(5, "Server-hosted upgrade level is %d.%02d\n",
+ (CitControl.version / 100),
+ (CitControl.version % 100) );
+
+ if (CitControl.version < config.c_setup_level) {
+ lprintf(5, "Server hosted updates need to be processed at "
+ "this time. Please wait...\n");
+ }
+ else {
+ return;
+ }
+
+
+ if (CitControl.version < 555) do_pre555_usersupp_upgrade();
+
+
+ CitControl.version = config.c_setup_level;
+ put_control();
+}
+
+
+
+
+char *Dynamic_Module_Init(void)
+{
+ check_server_upgrades();
+ return "$Id$";
+}
--- /dev/null
+/*
+ * Format of a usersupp record prior to version 5.55
+ */
+struct pre555usersupp { /* User record */
+ int USuid; /* userid (==BBSUID for bbs only) */
+ char password[20]; /* password (for BBS-only users) */
+ unsigned flags; /* See US_ flags below */
+ int timescalled; /* Total number of logins */
+ int posted; /* Number of messages posted (ever) */
+ char fullname[26]; /* Name for Citadel messages & mail */
+ char axlevel; /* Access level */
+ CIT_UBYTE USscreenwidth; /* Screen width (for textmode users)*/
+ CIT_UBYTE USscreenheight; /* Screen height(for textmode users)*/
+ long usernum; /* User number (never recycled) */
+ time_t lastcall; /* Last time the user called */
+ char USname[30]; /* */
+ char USaddr[25]; /* */
+ char UScity[15]; /* */
+ char USstate[3]; /* */
+ char USzip[10]; /* */
+ char USphone[11]; /* */
+ char USemail[32]; /* */
+ int USuserpurge; /* Purge time (in days) for user */
+};
+++ /dev/null
-#/bin/sh
-#
-# Please don't add this to the Makefile
-#
-cc -O2 -Wall -D_REENTRANT -fPIC -c serv_upgrade.c
-cc -shared -o modules/serv_upgrade.so serv_upgrade.o
}
}
+ /*
+ * Do non system dependent startup functions.
+ */
+ master_startup();
+
+ /*
+ * Load any server-side modules (plugins) available here.
+ */
lprintf(7, "Initializing loadable modules\n");
if ((moddir = malloc(strlen(bbs_home_directory) + 9)) != NULL) {
sprintf(moddir, "%s/modules", bbs_home_directory);
}
lprintf(9, "Modules done initializing.\n");
- /*
- * Do non system dependent startup functions.
- */
- master_startup();
-
/*
* Endless loop. Listen on the master socket. When a connection
* comes in, create a socket, a context, and a thread.
}
lowercase_name[sizeof(lowercase_name)-1] = 0;
+ usbuf->version = config.c_setup_level;
cdb_store(CDB_USERSUPP,
lowercase_name, strlen(lowercase_name),
usbuf, sizeof(struct usersupp));
}
code = (-1);
- if (CC->usersupp.USuid == BBSUID) {
+ if (CC->usersupp.uid == BBSUID) {
strproc(password);
strproc(CC->usersupp.password);
code = strcasecmp(CC->usersupp.password,password);
}
#ifdef ENABLE_AUTOLOGIN
else {
- if (validpw(CC->usersupp.USuid, password)) {
+ if (validpw(CC->usersupp.uid, password)) {
code = 0;
lgetuser(&CC->usersupp, CC->curr_user);
safestrncpy(CC->usersupp.password, password,
for (a=0; a<strlen(username); ++a) {
if (username[a] == ',') username[a] = 0;
}
- CC->usersupp.USuid = p->pw_uid;
+ CC->usersupp.uid = p->pw_uid;
}
else {
- CC->usersupp.USuid = BBSUID;
+ CC->usersupp.uid = BBSUID;
}
if (!getuser(&usbuf,username)) {
CC->usersupp.USscreenwidth = 80;
CC->usersupp.USscreenheight = 24;
time(&CC->usersupp.lastcall);
- strcpy(CC->usersupp.USname, "");
- strcpy(CC->usersupp.USaddr, "");
- strcpy(CC->usersupp.UScity, "");
- strcpy(CC->usersupp.USstate, "");
- strcpy(CC->usersupp.USzip, "");
- strcpy(CC->usersupp.USphone, "");
/* fetch a new user number */
CC->usersupp.usernum = get_new_user_number();
cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN);
return;
}
- if (CC->usersupp.USuid != BBSUID) {
+ if (CC->usersupp.uid != BBSUID) {
cprintf("%d Not allowed. Use the 'passwd' command.\n",ERROR);
return;
}