projects
/
citadel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7c76988
)
Patches from Matt with slight mod from me to do without strlen. Also modified lprintf...
author
Dave West
<davew@uncensored.citadel.org>
Thu, 23 Aug 2007 19:43:29 +0000
(19:43 +0000)
committer
Dave West
<davew@uncensored.citadel.org>
Thu, 23 Aug 2007 19:43:29 +0000
(19:43 +0000)
15 files changed:
citadel/citadel.c
patch
|
blob
|
history
citadel/citadel_ipc.c
patch
|
blob
|
history
citadel/citserver.c
patch
|
blob
|
history
citadel/client_chat.c
patch
|
blob
|
history
citadel/messages.c
patch
|
blob
|
history
citadel/modules/network/serv_network.c
patch
|
blob
|
history
citadel/room_ops.c
patch
|
blob
|
history
citadel/routines.c
patch
|
blob
|
history
citadel/routines2.c
patch
|
blob
|
history
citadel/screen.c
patch
|
blob
|
history
citadel/server.h
patch
|
blob
|
history
citadel/server_main.c
patch
|
blob
|
history
citadel/setup.c
patch
|
blob
|
history
citadel/sysdep.c
patch
|
blob
|
history
citadel/sysdep_decls.h
patch
|
blob
|
history
diff --git
a/citadel/citadel.c
b/citadel/citadel.c
index 920f06cc402b1ce1537991109cdfb85f2cf71d39..e9c979adbc91489e818998f93994dd4db53acbfc 100644
(file)
--- a/
citadel/citadel.c
+++ b/
citadel/citadel.c
@@
-517,6
+517,8
@@
void gotonext(CtdlIPC *ipc)
*/
mptr = (struct march *) malloc(sizeof(struct march));
mptr->next = NULL;
*/
mptr = (struct march *) malloc(sizeof(struct march));
mptr->next = NULL;
+ mptr->march_order = 0;
+ mptr->march_floor = 0;
strcpy(mptr->march_name, "_BASEROOM_");
if (march == NULL) {
march = mptr;
strcpy(mptr->march_name, "_BASEROOM_");
if (march == NULL) {
march = mptr;
@@
-747,8
+749,18
@@
void gotoroomstep(CtdlIPC *ipc, int direction, int mode)
struct ctdlroomlisting *rs;
int list_it;
char rmname[ROOMNAMELEN];
struct ctdlroomlisting *rs;
int list_it;
char rmname[ROOMNAMELEN];
- int rmslot;
+ int rmslot
= 0
;
int rmtotal;
int rmtotal;
+ struct ctdlroom *attr = NULL;
+
+ /* Fetch the existing room config */
+ r = CtdlIPCGetRoomAttributes(ipc, &attr, buf);
+ if (r / 100 != 2) {
+ scr_printf("%s\n", buf);
+ return;
+ }
+ strcpy (room_name , attr->QRname);
+ free(attr);
/* Ask the server for a room list */
r = CtdlIPCKnownRooms(ipc, SubscribedRooms, (-1), &listing, buf);
/* Ask the server for a room list */
r = CtdlIPCKnownRooms(ipc, SubscribedRooms, (-1), &listing, buf);
diff --git
a/citadel/citadel_ipc.c
b/citadel/citadel_ipc.c
index df52ea719473c0e96f6a81f997b8086a78a1646e..54d076e84a852e0a91c4254044fea32c08d4070d 100644
(file)
--- a/
citadel/citadel_ipc.c
+++ b/
citadel/citadel_ipc.c
@@
-121,7
+121,7
@@
int CtdlIPCEcho(CtdlIPC *ipc, const char *arg, char *cret)
int CtdlIPCQuit(CtdlIPC *ipc)
{
register int ret = 221; /* Default to successful quit */
int CtdlIPCQuit(CtdlIPC *ipc)
{
register int ret = 221; /* Default to successful quit */
- char aaa[
128];
+ char aaa[
SIZ];
CtdlIPC_lock(ipc);
if (ipc->sock > -1) {
CtdlIPC_lock(ipc);
if (ipc->sock > -1) {
@@
-149,7
+149,7
@@
int CtdlIPCQuit(CtdlIPC *ipc)
int CtdlIPCLogout(CtdlIPC *ipc)
{
register int ret;
int CtdlIPCLogout(CtdlIPC *ipc)
{
register int ret;
- char aaa[
128
];
+ char aaa[
SIZ
];
CtdlIPC_lock(ipc);
CtdlIPC_putline(ipc, "LOUT");
CtdlIPC_lock(ipc);
CtdlIPC_putline(ipc, "LOUT");
@@
-2335,6
+2335,7
@@
int CtdlIPCWriteUpload(CtdlIPC *ipc, const char *path,
char aaa[SIZ];
char buf[4096];
FILE *fd;
char aaa[SIZ];
char buf[4096];
FILE *fd;
+ int ferr;
if (!cret) return -1;
if (!path) return -1;
if (!cret) return -1;
if (!path) return -1;
@@
-2379,7
+2380,9
@@
int CtdlIPCWriteUpload(CtdlIPC *ipc, const char *path,
}
if (progress_gauge_callback)
progress_gauge_callback(ipc, 1, 1);
}
if (progress_gauge_callback)
progress_gauge_callback(ipc, 1, 1);
- return (!ferror(fd) ? ret : -2);
+ ferr = ferror(fd);
+ fclose(fd);
+ return (!ferr ? ret : -2);
}
}
@@
-2870,8
+2873,8
@@
static void CtdlIPC_getline(CtdlIPC* ipc, char *buf)
serv_read(ipc, &buf[i], 1);
/* Strip the trailing newline (and carriage return, if present) */
serv_read(ipc, &buf[i], 1);
/* Strip the trailing newline (and carriage return, if present) */
- if (buf[i] == 10) buf[i--] = 0;
- if (buf[i] == 13) buf[i--] = 0;
+ if (
i>=0 &&
buf[i] == 10) buf[i--] = 0;
+ if (
i>=0 &&
buf[i] == 13) buf[i--] = 0;
}
void CtdlIPC_chat_recv(CtdlIPC* ipc, char* buf)
}
void CtdlIPC_chat_recv(CtdlIPC* ipc, char* buf)
diff --git
a/citadel/citserver.c
b/citadel/citserver.c
index 87f4f6f827d4c65be909a214d6e092a56f77152d..43c0567bf94e1341275adc37dd43e355acf6e159 100644
(file)
--- a/
citadel/citserver.c
+++ b/
citadel/citserver.c
@@
-175,9
+175,6
@@
void master_cleanup(int exitcode) {
lprintf(CTDL_INFO, "Closing databases\n");
close_databases();
lprintf(CTDL_INFO, "Closing databases\n");
close_databases();
- /* flush the networker stuff */
-/* destroy_network_queue_room();*/
-
/* Do system-dependent stuff */
sysdep_master_cleanup();
/* Do system-dependent stuff */
sysdep_master_cleanup();
@@
-369,8
+366,9
@@
int is_public_client(void)
}
else ptr++;
}
}
else ptr++;
}
- while (isspace((buf[strlen(buf)-1]))) {
- buf[strlen(buf)-1] = 0;
+ ptr--;
+ while (ptr>buf && isspace(*ptr)) {
+ *(ptr--) = 0;
}
if (hostname_to_dotted_quad(addrbuf, buf) == 0) {
if ((strlen(public_clients) +
}
if (hostname_to_dotted_quad(addrbuf, buf) == 0) {
if ((strlen(public_clients) +
diff --git
a/citadel/client_chat.c
b/citadel/client_chat.c
index 535055fc9d40f7e8add4c2d70d57e1fcf3da4711..a1ad06ce101ea34b9094d062055431bb221adf98 100644
(file)
--- a/
citadel/client_chat.c
+++ b/
citadel/client_chat.c
@@
-84,6
+84,7
@@
void chatmode(CtdlIPC *ipc)
strcpy(buf, "");
strcpy(wbuf, "");
strcpy(buf, "");
strcpy(wbuf, "");
+ strcpy(last_user, "");
color(BRIGHT_YELLOW);
sln_printf_if("\n");
sln_printf("> ");
color(BRIGHT_YELLOW);
sln_printf_if("\n");
sln_printf("> ");
diff --git
a/citadel/messages.c
b/citadel/messages.c
index 79e03b1b4d32e931a62b89e52e988ee24fe0f787..7de1c23299f45b5a5bb8fcdb06ba842c08b35b32 100644
(file)
--- a/
citadel/messages.c
+++ b/
citadel/messages.c
@@
-411,9
+411,11
@@
int read_message(CtdlIPC *ipc,
if (r / 100 != 1) {
err_printf("*** msg #%ld: %d %s\n", num, r, buf);
++lines_printed;
if (r / 100 != 1) {
err_printf("*** msg #%ld: %d %s\n", num, r, buf);
++lines_printed;
- lines_printed =
- checkpagin(lines_printed, pagin, screenheight);
+ lines_printed = checkpagin(lines_printed, pagin, screenheight);
stty_ctdl(0);
stty_ctdl(0);
+ free(message->text);
+ free_parts(message->attachments);
+ free(message);
return (0);
}
return (0);
}
@@
-461,6
+463,9
@@
int read_message(CtdlIPC *ipc,
}
pprintf("\n");
stty_ctdl(0);
}
pprintf("\n");
stty_ctdl(0);
+ free(message->text);
+ free_parts(message->attachments);
+ free(message);
return (0);
}
return (0);
}
@@
-669,7
+674,7
@@
int read_message(CtdlIPC *ipc,
if (sigcaught == 0) {
linelen = strlen(lineptr);
if (sigcaught == 0) {
linelen = strlen(lineptr);
- if (line
ptr[linelen-1] == '\r'
) {
+ if (line
len && (lineptr[linelen-1] == '\r')
) {
lineptr[--linelen] = 0;
}
if (dest) {
lineptr[--linelen] = 0;
}
if (dest) {
@@
-697,6
+702,7
@@
int read_message(CtdlIPC *ipc,
scr_printf("\n");
++lines_printed;
lines_printed = checkpagin(lines_printed, pagin, screenheight);
scr_printf("\n");
++lines_printed;
lines_printed = checkpagin(lines_printed, pagin, screenheight);
+ fr = sigcaught;
}
}
}
}
@@
-1630,10
+1636,10
@@
RMSGREAD: scr_flush();
r = CtdlIPCSetMessageSeen(ipc, msg_arr[a], 1, buf);
}
r = CtdlIPCSetMessageSeen(ipc, msg_arr[a], 1, buf);
}
- if (e ==
3
)
+ if (e ==
SIGQUIT
)
return;
return;
- if (((userflags & US_NOPROMPT) || (e ==
2
))
- && (((room_flags & QR_MAILBOX) == 0)
+ if (((userflags & US_NOPROMPT) || (e ==
SIGINT
))
+
&& (((room_flags & QR_MAILBOX) == 0)
|| (rc_force_mail_prompts == 0))) {
e = 'n';
} else {
|| (rc_force_mail_prompts == 0))) {
e = 'n';
} else {
diff --git
a/citadel/modules/network/serv_network.c
b/citadel/modules/network/serv_network.c
index 71dc40a26bf215b0816e5225558ebef3ba72bb3e..29ad8379bdf78ef1045f23b98f7e08bebb78e189 100644
(file)
--- a/
citadel/modules/network/serv_network.c
+++ b/
citadel/modules/network/serv_network.c
@@
-1435,6
+1435,7
@@
void network_process_buffer(char *buffer, long size) {
* connected that it's inevitable.)
*/
if (network_usetable(msg) != 0) {
* connected that it's inevitable.)
*/
if (network_usetable(msg) != 0) {
+ CtdlFreeMessage(msg);
return;
}
return;
}
@@
-1706,9
+1707,9
@@
void receive_spool(int sock, char *remote_nodename) {
return;
}
if (download_len > 0)
return;
}
if (download_len > 0)
- lprintf(CTDL_NOTICE, "Received %ld octets from <%s>",
+ lprintf(CTDL_NOTICE, "Received %ld octets from <%s>
\n
",
download_len, remote_nodename);
download_len, remote_nodename);
- lprintf(CTDL_DEBUG, "%s", buf);
+ lprintf(CTDL_DEBUG, "%s
\n
", buf);
/* TODO: make move inline. forking is verry expensive. */
snprintf(buf,
sizeof buf,
/* TODO: make move inline. forking is verry expensive. */
snprintf(buf,
sizeof buf,
diff --git
a/citadel/room_ops.c
b/citadel/room_ops.c
index 3cfd2af32b32ef44a7a6a480afc1c20cb559574f..caed7a3054684917e6f1be2f1af594446a542ee5 100644
(file)
--- a/
citadel/room_ops.c
+++ b/
citadel/room_ops.c
@@
-520,7
+520,7
@@
int sort_msglist(long listptrs[], int oldcount)
/* and yank any nulls */
while ((numitems > 0) && (listptrs[0] == 0L)) {
/* and yank any nulls */
while ((numitems > 0) && (listptrs[0] == 0L)) {
- mem
cpy
(&listptrs[0], &listptrs[1],
+ mem
move
(&listptrs[0], &listptrs[1],
(sizeof(long) * (numitems - 1)));
--numitems;
}
(sizeof(long) * (numitems - 1)));
--numitems;
}
@@
-1882,7
+1882,7
@@
void cmd_cre8(char *args)
if (CtdlAccessCheck(ac_logged_in)) return;
if (CtdlAccessCheck(ac_logged_in)) return;
- if (CC->user.axlevel < config.c_createax
||
CC->internal_pgm) {
+ if (CC->user.axlevel < config.c_createax
&& !
CC->internal_pgm) {
cprintf("%d You need higher access to create rooms.\n",
ERROR + HIGHER_ACCESS_REQUIRED);
return;
cprintf("%d You need higher access to create rooms.\n",
ERROR + HIGHER_ACCESS_REQUIRED);
return;
diff --git
a/citadel/routines.c
b/citadel/routines.c
index 41d971e8ae1aed7cc67678abe2928bc42692e225..30db9a5ce161671d2e6bc7cb987d78d1c8d531ce 100644
(file)
--- a/
citadel/routines.c
+++ b/
citadel/routines.c
@@
-59,7
+59,7
@@
struct utmp *getutline(struct utmp *ut);
#define IFNAIDE if (axlevel<6)
extern unsigned userflags;
#define IFNAIDE if (axlevel<6)
extern unsigned userflags;
-
extern char *axdefs[7
];
+
//extern char *axdefs[8
];
extern char sigcaught;
extern char rc_floor_mode;
extern int rc_ansi_color;
extern char sigcaught;
extern char rc_floor_mode;
extern int rc_ansi_color;
@@
-159,7
+159,10
@@
void edituser(CtdlIPC *ipc, int cmd)
if (cmd == 96) {
scr_printf("Do you want to delete this user? ");
if (cmd == 96) {
scr_printf("Do you want to delete this user? ");
- if (!yesno()) return;
+ if (!yesno()) {
+ free(user);
+ return;
+ }
user->axlevel = 0;
}
user->axlevel = 0;
}
diff --git
a/citadel/routines2.c
b/citadel/routines2.c
index 3687f06eafbd9419b862e0cd484eea56d11a9d23..93c1814e51d7003a445a72f3b41e577704c77379 100644
(file)
--- a/
citadel/routines2.c
+++ b/
citadel/routines2.c
@@
-51,7
+51,7
@@
extern char temp[];
extern char tempdir[];
extern char temp[];
extern char tempdir[];
-extern char *axdefs[
7
];
+extern char *axdefs[
8
];
extern long highest_msg_read;
extern long maxmsgnum;
extern unsigned room_flags;
extern long highest_msg_read;
extern long maxmsgnum;
extern unsigned room_flags;
@@
-451,6
+451,11
@@
int val_user(CtdlIPC *ipc, char *user, int do_validate)
if (a == 11)
scr_printf("%s\n", buf);
} while (!IsEmptyStr(resp));
if (a == 11)
scr_printf("%s\n", buf);
} while (!IsEmptyStr(resp));
+
+/* TODODRW: discrepancy here. Parts of the code refer to axdefs[7] as the highest
+ * but most of it limits it to axdefs[6].
+ * Webcit limits to 6 as does the code here but there are 7 in axdefs.h
+ */
scr_printf("Current access level: %d (%s)\n", ax, axdefs[ax]);
} else {
scr_printf("%s\n%s\n", user, &cmd[4]);
scr_printf("Current access level: %d (%s)\n", ax, axdefs[ax]);
} else {
scr_printf("%s\n%s\n", user, &cmd[4]);
diff --git
a/citadel/screen.c
b/citadel/screen.c
index 398f945ce8ce570cb9327f9420cf9c09a7828e5f..a1d8abd7546f0c477d62725f061458e36fc40684 100644
(file)
--- a/
citadel/screen.c
+++ b/
citadel/screen.c
@@
-86,7
+86,7
@@
void status_line(const char *humannode, const char *site_location,
#if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
void wait_indicator(int state) {
#if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
void wait_indicator(int state) {
- if (
!isendwin() && statuswindow
) {
+ if (
statuswindow && !isendwin()
) {
mvwinch(statuswindow, 0, screenwidth - 2);
switch (state) {
mvwinch(statuswindow, 0, screenwidth - 2);
switch (state) {
diff --git
a/citadel/server.h
b/citadel/server.h
index 927abb6e867ace165e62846b6ab8f6c253cd146d..3d1c9c487a721d151a8dd3769c528f2eb4dc36c4 100644
(file)
--- a/
citadel/server.h
+++ b/
citadel/server.h
@@
-237,6
+237,7
@@
enum {
S_RPLIST,
S_SIEVELIST,
S_CHKPWD,
S_RPLIST,
S_SIEVELIST,
S_CHKPWD,
+ S_LOG,
MAX_SEMAPHORES
};
MAX_SEMAPHORES
};
diff --git
a/citadel/server_main.c
b/citadel/server_main.c
index 318f72e2b5f149041b5bb42ae125f23d8a98f5b0..4c69e608342f9c9c3af4aa9cdc653f77f279b3fa 100644
(file)
--- a/
citadel/server_main.c
+++ b/
citadel/server_main.c
@@
-87,6
+87,11
@@
int main(int argc, char **argv)
#ifdef HAVE_RUN_DIR
struct stat filestats;
#endif
#ifdef HAVE_RUN_DIR
struct stat filestats;
#endif
+
+ /* initialise semaphores here. Patch by Matt and davew
+ * its called here as they are needed by lprintf for thread safety
+ */
+ InitialiseSemaphores();
/* initialize the master context */
InitializeMasterCC();
/* initialize the master context */
InitializeMasterCC();
diff --git
a/citadel/setup.c
b/citadel/setup.c
index 1e741f002e333108de525312c87fdb07d85ecd72..bf1374d5a018e3be3ee3d41e85150c1fea856311 100644
(file)
--- a/
citadel/setup.c
+++ b/
citadel/setup.c
@@
-752,8
+752,8
@@
void edit_value(int curr)
config.c_ctdluid = atoi(ctdluidname);
}
}
config.c_ctdluid = atoi(ctdluidname);
}
}
- }
#endif
#endif
+ }
break;
case 3:
break;
case 3:
diff --git
a/citadel/sysdep.c
b/citadel/sysdep.c
index cd7f12107a5a15da0f3841d489cf7fda72b93cfe..94029bc68fead4090dc82b1199eaea7990d52945 100644
(file)
--- a/
citadel/sysdep.c
+++ b/
citadel/sysdep.c
@@
-103,6
+103,7
@@
void DestroyWorkerList(void);
* lprintf() ... Write logging information
*/
void lprintf(enum LogLevel loglevel, const char *format, ...) {
* lprintf() ... Write logging information
*/
void lprintf(enum LogLevel loglevel, const char *format, ...) {
+ char *buf;
va_list arg_ptr;
if (enable_syslog) {
va_list arg_ptr;
if (enable_syslog) {
@@
-112,7
+113,9
@@
void lprintf(enum LogLevel loglevel, const char *format, ...) {
}
/* stderr output code */
}
/* stderr output code */
- if (enable_syslog || running_as_daemon) return;
+ if (enable_syslog || running_as_daemon) {
+ return;
+ }
/* if we run in forground and syslog is disabled, log to terminal */
if (loglevel <= verbosity) {
/* if we run in forground and syslog is disabled, log to terminal */
if (loglevel <= verbosity) {
@@
-124,24
+127,30
@@
void lprintf(enum LogLevel loglevel, const char *format, ...) {
/* Promote to time_t; types differ on some OSes (like darwin) */
unixtime = tv.tv_sec;
localtime_r(&unixtime, &tim);
/* Promote to time_t; types differ on some OSes (like darwin) */
unixtime = tv.tv_sec;
localtime_r(&unixtime, &tim);
+// begin_critical_section(S_LOG);
+
+ buf = malloc(SIZ+strlen(format));
+
if (CC->cs_pid != 0) {
if (CC->cs_pid != 0) {
-
fprintf(stderr
,
+
sprintf(buf
,
"%04d/%02d/%02d %2d:%02d:%02d.%06ld [%3d] ",
tim.tm_year + 1900, tim.tm_mon + 1,
tim.tm_mday, tim.tm_hour, tim.tm_min,
tim.tm_sec, (long)tv.tv_usec,
CC->cs_pid);
} else {
"%04d/%02d/%02d %2d:%02d:%02d.%06ld [%3d] ",
tim.tm_year + 1900, tim.tm_mon + 1,
tim.tm_mday, tim.tm_hour, tim.tm_min,
tim.tm_sec, (long)tv.tv_usec,
CC->cs_pid);
} else {
-
fprintf(stderr
,
+
sprintf(buf
,
"%04d/%02d/%02d %2d:%02d:%02d.%06ld ",
tim.tm_year + 1900, tim.tm_mon + 1,
tim.tm_mday, tim.tm_hour, tim.tm_min,
tim.tm_sec, (long)tv.tv_usec);
}
"%04d/%02d/%02d %2d:%02d:%02d.%06ld ",
tim.tm_year + 1900, tim.tm_mon + 1,
tim.tm_mday, tim.tm_hour, tim.tm_min,
tim.tm_sec, (long)tv.tv_usec);
}
- va_start(arg_ptr, format);
- vfprintf(stderr, format, arg_ptr);
+ strcat(buf, format);
+ va_start(arg_ptr, buf);
+ vfprintf(stderr, buf, arg_ptr);
va_end(arg_ptr);
fflush(stderr);
va_end(arg_ptr);
fflush(stderr);
+// end_critical_section(S_LOG);
}
}
}
}
@@
-162,11
+171,25
@@
static RETSIGTYPE signal_cleanup(int signum) {
master_cleanup(signum);
}
master_cleanup(signum);
}
+
+
+
+void InitialiseSemaphores(void)
+{
+ int i;
+
+ /* Set up a bunch of semaphores to be used for critical sections */
+ for (i=0; i<MAX_SEMAPHORES; ++i) {
+ pthread_mutex_init(&Critters[i], NULL);
+ }
+}
+
+
+
/*
* Some initialization stuff...
*/
void init_sysdep(void) {
/*
* Some initialization stuff...
*/
void init_sysdep(void) {
- int i;
sigset_t set;
/* Avoid vulnerabilities related to FD_SETSIZE if we can. */
sigset_t set;
/* Avoid vulnerabilities related to FD_SETSIZE if we can. */
@@
-185,11
+208,6
@@
void init_sysdep(void) {
init_ssl();
#endif
init_ssl();
#endif
- /* Set up a bunch of semaphores to be used for critical sections */
- for (i=0; i<MAX_SEMAPHORES; ++i) {
- pthread_mutex_init(&Critters[i], NULL);
- }
-
/*
* Set up a place to put thread-specific data.
* We only need a single pointer per thread - it points to the
/*
* Set up a place to put thread-specific data.
* We only need a single pointer per thread - it points to the
diff --git
a/citadel/sysdep_decls.h
b/citadel/sysdep_decls.h
index 54d889384be131e951fee142a9c94ab0c27a1bf8..99a29e68e52d0f5910807c0c02ba2d9483d10ef6 100644
(file)
--- a/
citadel/sysdep_decls.h
+++ b/
citadel/sysdep_decls.h
@@
-74,6
+74,7
@@
void become_session(struct CitContext *which_con);
void InitializeMasterCC(void);
void init_master_fdset(void);
void create_worker(void);
void InitializeMasterCC(void);
void init_master_fdset(void);
void create_worker(void);
+void InitialiseSemaphores(void);
extern int num_sessions;
extern volatile int time_to_die;
extern int num_sessions;
extern volatile int time_to_die;