#include "citadel_ipc.h"
#include "citadel_decls.h"
#include "tools.h"
-
+#include "citadel_dirs.h"
#ifdef THREADED_CLIENT
pthread_mutex_t rwlock;
#endif
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) {
int CtdlIPCLogout(CtdlIPC *ipc)
{
register int ret;
- char aaa[128];
+ char aaa[SIZ];
CtdlIPC_lock(ipc);
CtdlIPC_putline(ipc, "LOUT");
}
}
*listing = march;
+ if (bbb) free(bbb);
return ret;
}
rret[0]->RRaide = extract_int(cret, 8);
rret[0]->RRnewmail = extract_long(cret, 9);
rret[0]->RRfloor = extract_int(cret, 10);
+ rret[0]->RRflags2 = extract_int(cret, 14);
} else {
free(*rret);
+ *rret = NULL;
}
+ free(aaa);
return ret;
}
/* If doing a MIME thing, pull out the extra headers */
if (as_mime == 4) {
do {
- if (!strncasecmp(bbb, "Content-type: ", 14)) {
+ if (!strncasecmp(bbb, "Content-type:", 13)) {
extract_token(mret[0]->content_type, bbb, 0, '\n', sizeof mret[0]->content_type);
- strcpy(mret[0]->content_type,
- &mret[0]->content_type[14]);
+ strcpy(mret[0]->content_type, &mret[0]->content_type[13]);
striplt(mret[0]->content_type);
/* strip out ";charset=" portion. FIXME do something with
}
}
+ if (!strncasecmp(bbb, "X-Citadel-MSG4-Partnum:", 23)) {
+ extract_token(mret[0]->mime_chosen, bbb, 0, '\n', sizeof mret[0]->mime_chosen);
+ strcpy(mret[0]->mime_chosen, &mret[0]->mime_chosen[23]);
+ striplt(mret[0]->mime_chosen);
+ }
remove_token(bbb, 0, '\n');
} while ((bbb[0] != 0) && (bbb[0] != '\n'));
remove_token(bbb, 0, '\n');
break;
case 14: ipc->ServInfo.supports_ldap = atoi(buf);
break;
+ case 15: ipc->ServInfo.newuser_disabled = atoi(buf);
+ break;
}
}
}
+ if (listing) free(listing);
return ret;
}
/* ENT0 */
-int CtdlIPCPostMessage(CtdlIPC *ipc, int flag, const struct ctdlipcmessage *mr, char *cret)
+int CtdlIPCPostMessage(CtdlIPC *ipc, int flag, int *subject_required, const struct ctdlipcmessage *mr, char *cret)
{
register int ret;
char cmd[SIZ];
mr->anonymous, mr->type, mr->subject, mr->author);
ret = CtdlIPCGenericCommand(ipc, cmd, mr->text, strlen(mr->text), NULL,
NULL, cret);
+ if ((flag == 0) && (subject_required != NULL)) {
+ /* Is the server strongly recommending that the user enter a message subject? */
+ if ((cret[3] != '\0') && (cret[4] != '\0')) {
+ *subject_required = extract_int(&cret[4], 1);
+ }
+
+
+ }
return ret;
}
struct ExpirePolicy **policy, char *cret)
{
static char *proto[] = {"room", "floor", "site", "mailboxes" };
- char aaa[11];
+ char cmd[256];
register int ret;
if (!cret) return -2;
if (!*policy) return -1;
if (which < 0 || which > 3) return -2;
- sprintf(aaa, "GPEX %s", proto[which]);
- ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
+ sprintf(cmd, "GPEX %s", proto[which]);
+ ret = CtdlIPCGenericCommand(ipc, cmd, NULL, 0, NULL, NULL, cret);
if (ret / 100 == 2) {
policy[0]->expire_mode = extract_int(cret, 0);
policy[0]->expire_value = extract_int(cret, 1);
}
return ret;
-
}
int CtdlIPCGetSystemConfigByType(CtdlIPC *ipc, const char *mimetype,
char **listing, char *cret)
{
+ register int ret;
char *aaa;
size_t bytes;
aaa = malloc(strlen(mimetype) + 13);
if (!aaa) return -1;
sprintf(aaa, "CONF GETSYS|%s", mimetype);
- return CtdlIPCGenericCommand(ipc, aaa, NULL, 0,
+ ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0,
listing, &bytes, cret);
+ free(aaa);
+ return ret;
}
int CtdlIPCSetSystemConfigByType(CtdlIPC *ipc, const char *mimetype,
const char *listing, char *cret)
{
+ register int ret;
char *aaa;
if (!cret) return -2;
aaa = malloc(strlen(mimetype) + 13);
if (!aaa) return -1;
sprintf(aaa, "CONF PUTSYS|%s", mimetype);
- return CtdlIPCGenericCommand(ipc, aaa, listing, strlen(listing),
+ ret = CtdlIPCGenericCommand(ipc, aaa, listing, strlen(listing),
NULL, NULL, cret);
+ free(aaa);
+ return ret;
}
/* QDIR */
int CtdlIPCDirectoryLookup(CtdlIPC *ipc, const char *address, char *cret)
{
+ register int ret;
char *aaa;
if (!address) return -2;
if (!aaa) return -1;
sprintf(aaa, "QDIR %s", address);
- return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
+ ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
+ free(aaa);
+ return ret;
}
char aaa[SIZ];
char buf[4096];
FILE *fd;
+ int ferr;
if (!cret) return -1;
if (!path) return -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);
}
sleep(1);
continue;
}
+/***
+ Not sure why we'd want to handle these error codes any differently,
+ but this definitely isn't the way to handle them. Someone must have
+ naively assumed that we could fall back to unencrypted communications,
+ but all it does is just recursively blow the stack.
if (errval == SSL_ERROR_ZERO_RETURN ||
errval == SSL_ERROR_SSL) {
serv_read(ipc, &buf[len], bytes - len);
return;
}
+ ***/
error_printf("SSL_read in serv_read: %s\n",
ERR_reason_error_string(ERR_peek_error()));
connection_died(ipc, 1);
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)
/* If we're using a unix domain socket we can do a bunch of stuff */
if (!strcmp(cithost, UDS)) {
if (!strcasecmp(citport, DEFAULT_PORT)) {
-#ifdef HAVE_RUN_DIR
- snprintf(sockpath, sizeof sockpath, RUN_DIR "/citadel.socket");
-#else
- snprintf(sockpath, sizeof sockpath, CTDLDIR "/citadel.socket");
-#endif
+ snprintf(sockpath, sizeof sockpath, file_citadel_socket);
}
else {
snprintf(sockpath, sizeof sockpath, "%s/%s", citport, "citadel.socket");