perror(file_citadel_config);
else {
rv = fwrite((char *) &config, sizeof(struct config), 1, cfp);
+ if (rv == -1)
+ syslog(LOG_EMERG, "Failed to write: %s [%s]\n",
+ file_citadel_config, strerror(errno));
fclose(cfp);
}
}
{
CitContext *ccptr;
time_t now;
- int session_to_kill;
int killed = 0;
int longrunners = 0;
now = time(NULL);
- session_to_kill = 0;
begin_critical_section(S_SESSION_TABLE);
for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
if (
return;
}
rv = fread(&MimeTestBuf[0], 1, 32, CC->download_fp);
+ if (rv == -1) {
+ cprintf("%d Cannot access %s: %s\n",
+ ERROR + FILE_NOT_FOUND, pathname, strerror(errno));
+ return;
+ }
+
rewind (CC->download_fp);
OpenCmdResult(pathname, GuessMimeType(&MimeTestBuf[0], 32));
}
buf = malloc(bytes + 1);
client_read(buf, bytes);
rv = fwrite(buf, bytes, 1, CC->upload_fp);
+ if (rv == -1) {
+ syslog(LOG_EMERG, "Couldn't write: %s\n",
+ strerror(errno));
+ }
free(buf);
}
int num_rbl;
char rbl_domains[SIZ];
char txt_answer[1024];
- int ip_version = 4;
strcpy(message_to_spammer, "ok");
if ((strchr(CC->cs_addr, '.')) && (!strchr(CC->cs_addr, ':'))) {
int a1, a2, a3, a4;
- ip_version = 4;
sscanf(CC->cs_addr, "%d.%d.%d.%d", &a1, &a2, &a3, &a4);
snprintf(tbuf, sizeof tbuf, "%d.%d.%d.%d.", a4, a3, a2, a1);
char workbuf[sizeof tbuf];
char *ptr;
- ip_version = 6;
-
/* tedious code to expand and reverse an IPv6 address */
safestrncpy(tbuf, CC->cs_addr, sizeof tbuf);
num_colons = haschar(tbuf, ':');
void init_ssl(void)
{
- SSL_METHOD *ssl_method;
+ const SSL_METHOD *ssl_method;
DH *dh;
RSA *rsa=NULL;
X509_REQ *req = NULL;
CitContext *CCC = CC;
const char *pos = NULL;
const char *pLF;
- int len, rlen, retlen;
+ int len, rlen;
int nSuccessLess = 0;
const char *pch = NULL;
- retlen = 0;
if ((Line == NULL) ||
(Pos == NULL) ||
(IOBuf == NULL))
int nArgs;
int nest = 0;
const char *pch, *end;
- long initial_len;
/* Convert all whitespace to ordinary space characters. */
pch = ChrPtr(Cmd->CmdBuf);
*/
nArgs = StrLength(Cmd->CmdBuf) / 10 + 10;
nArgs = CmdAdjust(Cmd, nArgs, 0);
- initial_len = StrLength(Cmd->CmdBuf);
Cmd->num_parms = 0;
Cmd->Params[Cmd->num_parms].Key = pch = ChrPtr(Cmd->CmdBuf);
end = Cmd->Params[Cmd->num_parms].Key + StrLength(Cmd->CmdBuf);
int selection_left = (-1);
int selection_right = (-1);
int return_left = (-1);
- int return_right = (-1);
int root_pos = 2;
int patterns_left = 3;
int patterns_right = 3;
}
if (paren_nest == 0) {
- return_right = i; /* found end of patterns */
i = num_parms + 1; /* break out of the loop */
}
}
*/
void imap_append(int num_parms, ConstStr *Params) {
long literal_length;
- long bytes_transferred;
struct CtdlMessage *msg = NULL;
long new_msgnum = (-1L);
int ret = 0;
IUnbuffer ();
- bytes_transferred = 0;
client_read_blob(Imap->TransmittedMessage, literal_length, config.c_sleeping);
if ((ret < 0) || (StrLength(Imap->TransmittedMessage) < literal_length)) {
int ra = 0;
struct ctdlroom QRscratch;
int msgs, new;
- int floornum;
- int roomflags;
int i;
/* Convert the supplied folder name to a roomname */
Imap->selected = 0;
return;
}
- floornum = (i & 0x00ff);
- roomflags = (i & 0xff00);
/* First try a regular match */
c = CtdlGetRoom(&QRscratch, towhere);
{
char old_room[ROOMNAMELEN];
char new_room[ROOMNAMELEN];
- int oldr, newr;
+ int newr;
int new_floor;
int r;
struct irl *irl = NULL; /* the list */
return;
}
- oldr = imap_roomname(old_room, sizeof old_room, Params[2].Key);
+ imap_roomname(old_room, sizeof old_room, Params[2].Key);
newr = imap_roomname(new_room, sizeof new_room, Params[3].Key);
new_floor = (newr & 0xFF);
{
struct timeval tv1, tv2;
suseconds_t total_time = 0;
- int untagged_ok = 1;
citimap *Imap;
const char *pchs, *pche;
const imap_handler_hook *h;
* If the command just submitted does not contain a literal, we
* might think about delivering some untagged stuff...
*/
- if (*(ChrPtr(Imap->Cmd.CmdBuf) + StrLength(Imap->Cmd.CmdBuf) - 1)
- == '}') {
- untagged_ok = 0;
- }
/* Grab the tag, command, and parameters. */
imap_parameterize(&Imap->Cmd);
/* todo, check length*/
{
char auth[SIZ];
- int retval;
char *message;
char *username;
message = ReadString(GetSizeToken(parms[2]), parms[0]);
if (message != NULL) {/**< do we have tokenized login? */
- retval = CtdlDecodeBase64(auth, MGSVE->transmitted_message, SIZ);
+ CtdlDecodeBase64(auth, MGSVE->transmitted_message, SIZ);
}
else
- retval = CtdlDecodeBase64(auth, parms[2], SIZ);
+ CtdlDecodeBase64(auth, parms[2], SIZ);
username = auth;
if ((*username == '\0') && (*(username + 1) != '\0'))
username ++;
void migr_do_export(void) {
- struct config *buf;
- buf = &config;
CitContext *Ctx;
Ctx = CC;
long msglen;
char *recps = NULL;
size_t recps_len = SIZ;
- size_t siz;
struct recptypes *valid;
namelist *nptr;
char bounce_to[256];
msg->cm_fields['M'] = malloc(msglen + 1);
fseek(sc->digestfp, 0L, SEEK_SET);
- siz = fread(msg->cm_fields['M'], (size_t)msglen, 1, sc->digestfp);
+ fread(msg->cm_fields['M'], (size_t)msglen, 1, sc->digestfp);
msg->cm_fields['M'][msglen] = '\0';
fclose(sc->digestfp);
SpoolControl *sc;
int i;
char *newpath = NULL;
- size_t instr_len = SIZ;
struct CtdlMessage *msg = NULL;
namelist *nptr;
maplist *mptr;
/*
* Process mailing list recipients
*/
- instr_len = SIZ;
if (sc->listrecps != NULL) {
/* Fetch the message. We're going to need to modify it
* in order to insert the [list name] in it, etc.
/*
* Process client-side list participations for this room
*/
- instr_len = SIZ;
if (sc->participates != NULL) {
msg = CtdlFetchMessage(msgnum, 1);
if (msg != NULL) {
*/
void extract_link(StrBuf *target_buf, const char *rel, long repllen, StrBuf *source_buf)
{
- int len, i;
+ int i;
const char *ptr;
const char *href_start = NULL;
const char *href_end = NULL;
if (link_tag_end == NULL)
break;
for (i=0; i < 1; i++ ){
- len = link_tag_end - link_tag_start;
-
rel_start = cbmstrcasestr(link_tag_start, "rel=");
if ((rel_start == NULL) ||
(rel_start > link_tag_end))
if (len < 0)
len = sizeof(thiskey) - 1;
extract_token(thisdata, buf, 1, '|', sizeof thisdata);
- syslog(LOG_DEBUG, "%s: [%d] %s\n", thiskey, strlen(thisdata), thisdata);
+ syslog(LOG_DEBUG, "%s: ["SIZE_T_FMT"] %s\n", thiskey, strlen(thisdata), thisdata);
Put(keys, thiskey, len, strdup(thisdata), NULL);
}
* LMTP is like SMTP but with some extra bonus footage added.
*/
void lmtp_greeting(void) {
- citsmtp *sSMTP;
smtp_greeting(0);
- sSMTP = SMTP;
SMTP->is_lmtp = 1;
}
*/
void store_this_ha(struct addresses_to_be_filed *aptr) {
struct CtdlMessage *vmsg = NULL;
- long vmsgnum = (-1L);
char *ser = NULL;
struct vCard *v = NULL;
char recipient[256];
vcard_free(v);
syslog(LOG_DEBUG, "Adding contact: %s\n", recipient);
- vmsgnum = CtdlSubmitMsg(vmsg, NULL, aptr->roomname, QP_EADDR);
+ CtdlSubmitMsg(vmsg, NULL, aptr->roomname, QP_EADDR);
CtdlFreeMessage(vmsg);
}
}
fp = fopen(filename, "a");
if (fp != NULL) fclose(fp);
rv = chown(filename, CTDLUID, (-1));
+ if (rv == -1)
+ syslog(LOG_EMERG, "Failed to adjust ownership of: %s [%s]\n",
+ filename, strerror(errno));
}
/* for postfix tcpdict */
fclose(fp);
}
- syslog(LOG_DEBUG, "diff length is %d bytes", diffbuf_len);
+ syslog(LOG_DEBUG, "diff length is "SIZE_T_FMT" bytes", diffbuf_len);
unlink(diff_old_filename);
unlink(diff_new_filename);
*/
void xmpp_send_message(char *message_to, char *message_body) {
char *recp = NULL;
- int message_sent = 0;
struct CitContext *cptr;
if (message_body == NULL) return;
}
if (recp) {
- message_sent = PerformXmsgHooks(CC->user.fullname, CC->cs_inet_email, recp, message_body);
+ PerformXmsgHooks(CC->user.fullname, CC->cs_inet_email, recp, message_body);
}
free(XMPP->message_body);
return;
rv = fwrite(content, length, 1, CC->download_fp);
+ if (rv == -1) {
+ syslog(LOG_EMERG, "mime_download(): Couldn't write: %s\n",
+ strerror(errno));
+ }
fflush(CC->download_fp);
rewind(CC->download_fp);
void dump_message(struct CtdlMessage *msg, /* unserialized msg */
long Siz) /* how many chars ? */
{
- size_t wlen;
int i;
static char *forder = FORDER;
char *buf;
buf = (char*) malloc (Siz + 1);
- wlen = 3;
-
for (i=0; i<26; ++i) if (msg->cm_fields[(int)forder[i]] != NULL) {
snprintf (buf, Siz, " msg[%c] = %s ...\n", (char) forder[i],
msg->cm_fields[(int)forder[i]]);
network_fp = fopen(submit_filename, "wb+");
if (network_fp != NULL) {
rv = fwrite(smr.ser, smr.len, 1, network_fp);
+ if (rv == -1) {
+ syslog(LOG_EMERG, "CtdlSubmitMsg(): Couldn't write network spool file: %s\n",
+ strerror(errno));
+ }
fclose(network_fp);
}
free(smr.ser);
new_arcq.arcq_msgnum = msgnum;
new_arcq.arcq_delta = incr;
rv = fwrite(&new_arcq, sizeof(struct arcq), 1, arcfp);
+ if (rv == -1) {
+ syslog(LOG_EMERG, "Couldn't write Refcount Queue File %s: %s\n",
+ file_arcq,
+ strerror(errno));
+ }
fflush(arcfp);
return;
begin_critical_section(S_CHKPWD);
rv = write(chkpwd_write_pipe[1], &uid, sizeof(uid_t));
+ if (rv == -1) {
+ syslog(LOG_EMERG, "Communicatino with chkpwd broken: %s\n", strerror(errno));
+ end_critical_section(S_CHKPWD);
+ return 0;
+ }
rv = write(chkpwd_write_pipe[1], pass, 256);
+ if (rv == -1) {
+ syslog(LOG_EMERG, "Communicatino with chkpwd broken: %s\n", strerror(errno));
+ end_critical_section(S_CHKPWD);
+ return 0;
+ }
rv = read(chkpwd_read_pipe[0], buf, 4);
+ if (rv == -1) {
+ syslog(LOG_EMERG, "Communicatino with chkpwd broken: %s\n", strerror(errno));
+ end_critical_section(S_CHKPWD);
+ return 0;
+ }
end_critical_section(S_CHKPWD);
if (!strncmp(buf, "PASS", 4)) {
*/
void cmd_setp(char *new_pw)
{
- int generate_random_password = 0;
-
if (CtdlAccessCheck(ac_logged_in)) {
return;
}
if (!strcasecmp(new_pw, "GENERATE_RANDOM_PASSWORD")) {
char random_password[17];
- generate_random_password = 1;
snprintf(random_password, sizeof random_password, "%08lx%08lx", random(), random());
CtdlSetPassword(random_password);
cprintf("%d %s\n", CIT_OK, random_password);
//password[31] = 0;
strproc(username);
strproc(password);
+ len = strlen(username);
+ if (len >= USERNAME_SIZE)
+ {
+ syslog(LOG_EMERG, "Username to long: %s", username);
+ cit_backtrace ();
+ len = USERNAME_SIZE - 1;
+ username[63]='\0';
+ }
+
len = cutuserkey(username);
if (IsEmptyStr(username)) {
syslog(LOG_EMERG, "Username to long: %s", username);
cit_backtrace ();
len = USERNAME_SIZE - 1;
- ((char*)username)[USERNAME_SIZE - 1]='\0';
+ username[63]='\0';
}
return len;
}
{
int rv;
rv = mkdir(which, ACCESS);
+ if ((rv == -1) && (errno == EEXIST))
+ return rv;
rv = chmod(which, ACCESS);
+ if (rv == -1)
+ return rv;
rv = chown(which, UID, GID);
return rv;
}
-void create_run_directories(long UID, long GID)
+int create_run_directories(long UID, long GID)
{
int rv;
rv = create_dir(ctdl_info_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
- rv = create_dir(ctdl_bio_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
- rv = create_dir(ctdl_usrpic_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
- rv = create_dir(ctdl_message_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
- rv = create_dir(ctdl_hlp_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
- rv = create_dir(ctdl_image_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
- rv = create_dir(ctdl_bb_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
- rv = create_dir(ctdl_file_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
- rv = create_dir(ctdl_netcfg_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
- rv = create_dir(ctdl_key_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
- rv = create_dir(ctdl_run_dir , S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, UID, GID);
+ if (rv != -1)
+ rv = create_dir(ctdl_bio_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
+ if (rv != -1)
+ rv = create_dir(ctdl_usrpic_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
+ if (rv != -1)
+ rv = create_dir(ctdl_message_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
+ if (rv != -1)
+ rv = create_dir(ctdl_hlp_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
+ if (rv != -1)
+ rv = create_dir(ctdl_image_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
+ if (rv != -1)
+ rv = create_dir(ctdl_bb_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
+ if (rv != -1)
+ rv = create_dir(ctdl_file_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
+ if (rv != -1)
+ rv = create_dir(ctdl_netcfg_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
+ if (rv != -1)
+ rv = create_dir(ctdl_key_dir , S_IRUSR|S_IWUSR|S_IXUSR, UID, -1);
+ if (rv != -1)
+ rv = create_dir(ctdl_run_dir , S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, UID, GID);
+ return rv;
}