"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/post.c" between
tin-2.4.4.tar.xz and tin-2.4.5.tar.xz

About: TIN is a threaded NNTP and spool based UseNet newsreader.

post.c  (tin-2.4.4.tar.xz):post.c  (tin-2.4.5.tar.xz)
/* /*
* Project : tin - a Usenet reader * Project : tin - a Usenet reader
* Module : post.c * Module : post.c
* Author : I. Lea * Author : I. Lea
* Created : 1991-04-01 * Created : 1991-04-01
* Updated : 2019-07-09 * Updated : 2020-09-23
* Notes : mail/post/replyto/followup/repost & cancel articles * Notes : mail/post/replyto/followup/repost & cancel articles
* *
* Copyright (c) 1991-2020 Iain Lea <iain@bricbrac.de> * Copyright (c) 1991-2021 Iain Lea <iain@bricbrac.de>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
skipping to change at line 138 skipping to change at line 138
char *text; char *text;
} msg_headers[MAX_MSG_HEADERS]; } msg_headers[MAX_MSG_HEADERS];
/* /*
* Local prototypes * Local prototypes
*/ */
static FILE *create_mail_headers(char *filename, size_t filename_len, const char *suffix, const char *to, const char *subject, struct t_header *extra_hdrs); static FILE *create_mail_headers(char *filename, size_t filename_len, const char *suffix, const char *to, const char *subject, struct t_header *extra_hdrs);
static char **build_nglist(char *ngs_list, int *ngcnt); static char **build_nglist(char *ngs_list, int *ngcnt);
static char **split_address_list(const char *addresses, unsigned int *cnt); static char **split_address_list(const char *addresses, unsigned int *cnt);
static int add_mail_quote(FILE *fp, int respnum); static int add_mail_quote(FILE *fp, int respnum);
static int append_mail(const char *the_article, const char *addr, const char *th e_mailbox);
static int check_article_to_be_posted(const char *the_article, int art_type, str uct t_group **group, t_bool art_unchanged, t_bool use_cache); static int check_article_to_be_posted(const char *the_article, int art_type, str uct t_group **group, t_bool art_unchanged, t_bool use_cache);
static int mail_loop(const char *filename, t_function func, char *subject, const char *groupname, const char *prompt, FILE *articlefp); static int mail_loop(const char *filename, t_function func, char *subject, const char *groupname, const char *prompt, FILE *articlefp);
static int msg_add_x_body(FILE *fp_out, const char *body); static int msg_add_x_body(FILE *fp_out, const char *body);
static int msg_write_headers(FILE *fp); static int msg_write_headers(FILE *fp);
static int post_loop(int type, struct t_group *group, t_function func, const cha r *posting_msg, int art_type, int offset); static int post_loop(int type, struct t_group *group, t_function func, const cha r *posting_msg, int art_type, int offset);
static unsigned int get_recipients(struct t_header *hdr, char *buf, size_t bufle n); static unsigned int get_recipients(struct t_header *hdr, char *buf, size_t bufle n);
static size_t skip_id(const char *id); static size_t skip_id(const char *id);
static struct t_group *check_moderated(const char *groups, int *art_type, const char *failmsg); static struct t_group *check_moderated(const char *groups, int *art_type, const char *failmsg);
static t_bool address_in_list(const char *addresses, const char *address); static t_bool address_in_list(const char *addresses, const char *address);
static t_bool append_mail(const char *the_article, const char *addr, const char *the_mailbox);
static t_bool backup_article(const char *the_article); static t_bool backup_article(const char *the_article);
static t_bool check_for_spamtrap(const char *addr); static t_bool check_for_spamtrap(const char *addr);
static t_bool create_normal_article_headers(struct t_group *group, const char *n ewsgroups, int art_type); static t_bool create_normal_article_headers(struct t_group *group, const char *n ewsgroups, int art_type);
static t_bool damaged_id(const char *id); static t_bool damaged_id(const char *id);
static t_bool fetch_postponed_article(const char tmp_file[], char subject[], cha r newsgroups[]); static t_bool fetch_postponed_article(const char tmp_file[], char subject[], cha r newsgroups[]);
static t_bool insert_from_header(const char *infile); static t_bool insert_from_header(const char *infile);
static t_bool is_crosspost(const char *xref); static t_bool is_crosspost(const char *xref);
static t_bool must_include(const char *id); static t_bool must_include(const char *id);
static t_bool repair_article(t_function *result, struct t_group *group); static t_bool repair_article(t_function *result, struct t_group *group);
static t_bool stripped_double_ngs(char **newsgroups, int *ngcnt); static t_bool stripped_double_ngs(char **newsgroups, int *ngcnt);
skipping to change at line 609 skipping to change at line 609
} else } else
rename_file(file_tmp, posted_info_file); rename_file(file_tmp, posted_info_file);
free(file_tmp); free(file_tmp);
} }
/* /*
* appends the content of the_article to the_mailbox, with a From_ line of * appends the content of the_article to the_mailbox, with a From_ line of
* addr, does mboxo/mboxrd From_ line quoting if needed (!MMDF-style mbox) * addr, does mboxo/mboxrd From_ line quoting if needed (!MMDF-style mbox)
*/ */
static t_bool static int
append_mail( append_mail(
const char *the_article, const char *the_article,
const char *addr, const char *addr,
const char *the_mailbox) const char *the_mailbox)
{ {
FILE *fp_in, *fp_out; FILE *fp_in, *fp_out;
char *bufp; char *bufp;
char buf[LEN]; char buf[LEN];
time_t epoch; time_t epoch;
t_bool mmdf = FALSE; t_bool mmdf = FALSE;
t_bool rval = FALSE; int rval;
#ifndef NO_LOCKING #ifndef NO_LOCKING
int fd; int fd;
unsigned int retrys = 11; /* maximum lock retrys + 1 */ unsigned int retrys = 11; /* maximum lock retrys + 1 */
#endif /* !NO_LOCKING */ #endif /* !NO_LOCKING */
if (!strcasecmp(txt_mailbox_formats[tinrc.mailbox_format], "MMDF") && the _mailbox != postponed_articles_file) if (!strcasecmp(txt_mailbox_formats[tinrc.mailbox_format], "MMDF") && the _mailbox != postponed_articles_file)
mmdf = TRUE; mmdf = TRUE;
if ((fp_in = fopen(the_article, "r")) == NULL) if ((fp_in = fopen(the_article, "r")) == NULL)
return rval; return errno;
if ((fp_out = fopen(the_mailbox, "a+")) != NULL) { if ((fp_out = fopen(the_mailbox, "a+")) != NULL) {
#ifndef NO_LOCKING #ifndef NO_LOCKING
fd = fileno(fp_out); fd = fileno(fp_out);
/* TODO: move the retry/error stuff into a function? */
while (--retrys && fd_lock(fd, FALSE)) while ((rval = fd_lock(fd, FALSE)) && --retrys)
wait_message(1, _(txt_trying_lock), retrys, the_mailbox); wait_message(1, _(txt_trying_lock), retrys, the_mailbox);
if (!retrys) { if (!retrys) {
wait_message(5, _(txt_error_couldnt_lock), the_mailbox); wait_message(5, _(txt_error_couldnt_lock), the_mailbox);
fclose(fp_out); fclose(fp_out);
fclose(fp_in); fclose(fp_in);
return rval; return rval;
} }
retrys++; retrys++;
while (--retrys && !dot_lock(the_mailbox)) while (--retrys && !dot_lock(the_mailbox))
wait_message(1, _(txt_trying_dotlock), retrys, the_mailbo x); wait_message(1, _(txt_trying_dotlock), retrys, the_mailbo x);
if (!retrys) { if (!retrys) {
wait_message(5, _(txt_error_couldnt_dotlock), the_mailbox ); wait_message(5, _(txt_error_couldnt_dotlock), the_mailbox );
fd_unlock(fd); fd_unlock(fd);
fclose(fp_out); fclose(fp_out);
fclose(fp_in); fclose(fp_in);
return rval; return ENOENT; /* FIXME! dot_lock() doesn't return more i nfo yet */
} }
#endif /* !NO_LOCKING */ #endif /* !NO_LOCKING */
if (mmdf) if (mmdf)
fprintf(fp_out, "%s", MMDFHDRTXT); fprintf(fp_out, "%s", MMDFHDRTXT);
else { else {
(void) time(&epoch); (void) time(&epoch);
fprintf(fp_out, "From %s %s", addr, ctime(&epoch)); fprintf(fp_out, "From %s %s", addr, ctime(&epoch));
} }
while (fgets(buf, (int) sizeof(buf), fp_in) != NULL) { while (fgets(buf, (int) sizeof(buf), fp_in) != NULL) {
skipping to change at line 686 skipping to change at line 689
if (strncmp(buf, "From ", 5) == 0) if (strncmp(buf, "From ", 5) == 0)
fputc('>', fp_out); fputc('>', fp_out);
} }
} }
fputs(buf, fp_out); fputs(buf, fp_out);
} }
print_art_separator_line(fp_out, mmdf); print_art_separator_line(fp_out, mmdf);
fflush(fp_out); fflush(fp_out);
#ifndef NO_LOCKING #ifndef NO_LOCKING
if (fd_unlock(fd) || !dot_unlock(the_mailbox)) if ((rval = fd_unlock(fd)) || !dot_unlock(the_mailbox))
wait_message(4, _(txt_error_cant_unlock), the_mailbox); wait_message(4, _(txt_error_cant_unlock), the_mailbox);
#endif /* !NO_LOCKING */ #endif /* !NO_LOCKING */
fclose(fp_out); fclose(fp_out);
rval = TRUE; } else
} rval = errno;
fclose(fp_in); fclose(fp_in);
return rval; return rval;
} }
/* /*
* TODO: * TODO:
* - cleanup!! * - cleanup!!
* - check for illegal (8bit) chars in References, X-Face, MIME-Version, * - check for illegal (8bit) chars in References, X-Face, MIME-Version,
* Content-Type, Content-Transfer-Encoding, Content-Disposition, Supersedes * Content-Type, Content-Transfer-Encoding, Content-Disposition, Supersedes
* - check for 'illegal' headers: Xref, Injection-Info, (NNTP-Posting-Host, * - check for 'illegal' headers: Xref, Injection-Info, (NNTP-Posting-Host,
skipping to change at line 945 skipping to change at line 949
errors++; errors++;
#else #else
warnings++; warnings++;
#endif /* HAVE_FASCIST_NEWSADMIN */ #endif /* HAVE_FASCIST_NEWSADMIN */
} }
#ifdef CHARSET_CONVERSION #ifdef CHARSET_CONVERSION
cp2 = rfc1522_encode(line, txt_mime_charsets[mmnwcharset] , FALSE); cp2 = rfc1522_encode(line, txt_mime_charsets[mmnwcharset] , FALSE);
#else #else
cp2 = rfc1522_encode(line, tinrc.mm_charset, FALSE); cp2 = rfc1522_encode(line, tinrc.mm_charset, FALSE);
#endif /* CHARSET_CONVERSION */ #endif /* CHARSET_CONVERSION */
if ((i = gnksa_check_from(cp2 + (cp - line) + 1)) != GNKS i = gnksa_check_from(cp2 + (cp - line) + 1);
A_OK) { if (i > GNKSA_OK && i < GNKSA_MISSING_REALNAME) {
StartInverse(); StartInverse();
my_fprintf(stderr, "%s", _(txt_error_bad_approved )); my_fprintf(stderr, "%s", _(txt_error_bad_approved ));
my_fprintf(stderr, "%s\n", cp2);
my_fprintf(stderr, gnksa_strerror(i), i); my_fprintf(stderr, gnksa_strerror(i), i);
EndInverse(); EndInverse();
my_fflush(stderr); my_fflush(stderr);
#ifndef FORGERY #ifndef FORGERY
errors++; errors++;
#endif /* !FORGERY */ #endif /* !FORGERY */
} }
free(cp2); free(cp2);
} }
if (cp - line == 4 && !strncasecmp(line, "From", 4)) { if (cp - line == 4 && !strncasecmp(line, "From", 4)) {
found_from_lines++; found_from_lines++;
#ifdef CHARSET_CONVERSION #ifdef CHARSET_CONVERSION
cp2 = rfc1522_encode(line, txt_mime_charsets[mmnwcharset] , FALSE); cp2 = rfc1522_encode(line, txt_mime_charsets[mmnwcharset] , FALSE);
#else #else
cp2 = rfc1522_encode(line, tinrc.mm_charset, FALSE); cp2 = rfc1522_encode(line, tinrc.mm_charset, FALSE);
#endif /* CHARSET_CONVERSION */ #endif /* CHARSET_CONVERSION */
if ((i = gnksa_check_from(cp2 + (cp - line) + 1)) != GNKS i = gnksa_check_from(cp2 + (cp - line) + 1);
A_OK) { if (i > GNKSA_OK && i < GNKSA_MISSING_REALNAME) {
StartInverse(); StartInverse();
my_fprintf(stderr, "%s", _(txt_error_bad_from)); my_fprintf(stderr, "%s", _(txt_error_bad_from));
my_fprintf(stderr, "%s\n", cp2);
my_fprintf(stderr, gnksa_strerror(i), i); my_fprintf(stderr, gnksa_strerror(i), i);
EndInverse(); EndInverse();
my_fflush(stderr); my_fflush(stderr);
#ifndef FORGERY #ifndef FORGERY
errors++; errors++;
#endif /* !FORGERY */ #endif /* !FORGERY */
} }
free(cp2); free(cp2);
} }
if (cp - line == 8 && !strncasecmp(line, "Reply-To", 8)) { if (cp - line == 8 && !strncasecmp(line, "Reply-To", 8)) {
#ifdef CHARSET_CONVERSION #ifdef CHARSET_CONVERSION
cp2 = rfc1522_encode(line, txt_mime_charsets[mmnwcharset] , FALSE); cp2 = rfc1522_encode(line, txt_mime_charsets[mmnwcharset] , FALSE);
#else #else
cp2 = rfc1522_encode(line, tinrc.mm_charset, FALSE); cp2 = rfc1522_encode(line, tinrc.mm_charset, FALSE);
#endif /* CHARSET_CONVERSION */ #endif /* CHARSET_CONVERSION */
if ((i = gnksa_check_from(cp2 + (cp - line) + 1)) != GNKS i = gnksa_check_from(cp2 + (cp - line) + 1);
A_OK) { if (i > GNKSA_OK && i < GNKSA_MISSING_REALNAME) {
StartInverse(); StartInverse();
my_fprintf(stderr, "%s", _(txt_error_bad_replyto) ); my_fprintf(stderr, "%s", _(txt_error_bad_replyto) );
my_fprintf(stderr, "%s\n", cp2);
my_fprintf(stderr, gnksa_strerror(i), i); my_fprintf(stderr, gnksa_strerror(i), i);
EndInverse(); EndInverse();
my_fflush(stderr); my_fflush(stderr);
#ifndef FORGERY #ifndef FORGERY
errors++; errors++;
#endif /* !FORGERY */ #endif /* !FORGERY */
} }
free(cp2); free(cp2);
} }
if (cp - line == 2 && !strncasecmp(line, "To", 2)) { if (cp - line == 2 && !strncasecmp(line, "To", 2)) {
#ifdef CHARSET_CONVERSION #ifdef CHARSET_CONVERSION
cp2 = rfc1522_encode(line, txt_mime_charsets[mmnwcharset] , FALSE); cp2 = rfc1522_encode(line, txt_mime_charsets[mmnwcharset] , FALSE);
#else #else
cp2 = rfc1522_encode(line, tinrc.mm_charset, FALSE); cp2 = rfc1522_encode(line, tinrc.mm_charset, FALSE);
#endif /* CHARSET_CONVERSION */ #endif /* CHARSET_CONVERSION */
if ((i = gnksa_check_from(cp2 + (cp - line) + 1)) != GNKS i = gnksa_check_from(cp2 + (cp - line) + 1);
A_OK) { if (i > GNKSA_OK && i < GNKSA_MISSING_REALNAME) {
StartInverse(); StartInverse();
my_fprintf(stderr, "%s", _(txt_error_bad_to)); my_fprintf(stderr, "%s", _(txt_error_bad_to));
my_fprintf(stderr, "%s\n", cp2);
my_fprintf(stderr, gnksa_strerror(i), i); my_fprintf(stderr, gnksa_strerror(i), i);
EndInverse(); EndInverse();
my_fflush(stderr); my_fflush(stderr);
#ifndef FORGERY #ifndef FORGERY
errors++; errors++;
#endif /* !FORGERY */ #endif /* !FORGERY */
} }
to = my_strdup(cp2 + (cp - line) + 1); to = my_strdup(cp2 + (cp - line) + 1);
free(cp2); free(cp2);
} }
skipping to change at line 1032 skipping to change at line 1044
i = gnksa_check_from(++cp); i = gnksa_check_from(++cp);
gnksa_split_from(cp, addr, name, &type); gnksa_split_from(cp, addr, name, &type);
if (((GNKSA_OK != i) && (GNKSA_LOCALPART_MISSING > i)) || !*addr) if (((GNKSA_OK != i) && (GNKSA_LOCALPART_MISSING > i)) || !*addr)
#else #else
i = gnksa_check_from(++cp); i = gnksa_check_from(++cp);
if ((GNKSA_OK != i) && (GNKSA_LOCALPART_MISSING > i)) if ((GNKSA_OK != i) && (GNKSA_LOCALPART_MISSING > i))
#endif /* 0 */ #endif /* 0 */
{ {
StartInverse(); StartInverse();
my_fprintf(stderr, "%s", _(txt_error_bad_msgidfqd n)); my_fprintf(stderr, "%s", _(txt_error_bad_msgidfqd n));
my_fprintf(stderr, "%s\n", line);
my_fprintf(stderr, gnksa_strerror(i), i); my_fprintf(stderr, gnksa_strerror(i), i);
EndInverse(); EndInverse();
my_fflush(stderr); my_fflush(stderr);
#ifndef FORGERY #ifndef FORGERY
errors++; errors++;
#endif /* !FORGERY */ #endif /* !FORGERY */
} }
if (damaged_id(cp)) if (damaged_id(cp))
errors_catbp |= CA_ERROR_BAD_MESSAGE_ID; errors_catbp |= CA_ERROR_BAD_MESSAGE_ID;
} }
skipping to change at line 2037 skipping to change at line 2050
update_posted_info_file(header.to, tag, h eader.subj, ""); update_posted_info_file(header.to, tag, h eader.subj, "");
break; break;
default: default:
break; break;
} }
my_strncpy(tinrc.default_post_subject, header.subj, sizeo f(tinrc.default_post_subject) - 1); my_strncpy(tinrc.default_post_subject, header.subj, sizeo f(tinrc.default_post_subject) - 1);
} }
if (*tinrc.posted_articles_file && type != POST_REPOST) { if (*tinrc.posted_articles_file && type != POST_REPOST) { /* TODO
char a_mailbox[LEN]; : either document the !POST_REPOST logic or remove it */
char a_mailbox[PATH_LEN];
char posted_msgs_file[PATH_LEN]; char posted_msgs_file[PATH_LEN];
joinpath(posted_msgs_file, sizeof(posted_msgs_file), (cmd if (!strfpath(tinrc.posted_articles_file, posted_msgs_fil
line.args & CMDLINE_MAILDIR) ? cmdline.maildir : (group ? group->attribute->mail e, sizeof(posted_msgs_file), group, TRUE))
dir : tinrc.maildir), tinrc.posted_articles_file); STRCPY(posted_msgs_file, tinrc.posted_articles_fi
le);
else {
if (!strcmp(tinrc.posted_articles_file, posted_ms
gs_file)) /* only prefix tinrc.posted_articles_file if it was a plain file witho
ut path */
joinpath(posted_msgs_file, sizeof(posted_
msgs_file), (cmdline.args & CMDLINE_MAILDIR) ? cmdline.maildir : (group ? group-
>attribute->maildir : tinrc.maildir), tinrc.posted_articles_file);
}
/* re-strfpath as maildir may also need expansion */
if (!strfpath(posted_msgs_file, a_mailbox, sizeof(a_mailb
ox), group, TRUE))
STRCPY(a_mailbox, posted_msgs_file);
/* /*
* log Message-ID if given in a_message_id, * log Message-ID if given in a_message_id,
* add Date:, remove empty headers * add Date: if required, remove empty headers
*/ */
add_headers(article_name, a_message_id); add_headers(article_name, a_message_id);
if (!strfpath(posted_msgs_file, a_mailbox, sizeof(a_mailb
ox), group, TRUE)) if ((errno = append_mail(article_name, userid, a_mailbox)
STRCPY(a_mailbox, posted_msgs_file); )) {
if (!append_mail(article_name, userid, a_mailbox)) { perror_message(_(txt_cannot_open_for_saving), a_m
/* TODO: error handling */ ailbox);
} }
} }
free_and_init_header(&header); free_and_init_header(&header);
} }
post_article_postponed: post_article_postponed:
curr_group = ogroup; curr_group = ogroup;
if (tinrc.unlink_article) if (tinrc.unlink_article)
unlink(article_name); unlink(article_name);
skipping to change at line 2177 skipping to change at line 2199
return FALSE; return FALSE;
} }
free(prompt); free(prompt);
free(tmp2); free(tmp2);
if ((fp = fopen(article_name, "w")) == NULL) { if ((fp = fopen(article_name, "w")) == NULL) {
perror_message(_(txt_cannot_open), article_name); perror_message(_(txt_cannot_open), article_name);
return FALSE; return FALSE;
} }
#ifdef HAVE_FCHMOD
fchmod(fileno(fp), (mode_t) (S_IRUSR|S_IWUSR)); fchmod(fileno(fp), (mode_t) (S_IRUSR|S_IWUSR));
#else
# ifdef HAVE_CHMOD
chmod(article_name, (mode_t) (S_IRUSR|S_IWUSR));
# endif /* HAVE_CHMOD */
#endif /* HAVE_FCHMOD */
get_from_name(from_name, group); get_from_name(from_name, group);
#ifdef FORGERY #ifdef FORGERY
make_path_header(tmp); make_path_header(tmp);
msg_add_header("Path", tmp); msg_add_header("Path", tmp);
#endif /* FORGERY */ #endif /* FORGERY */
msg_add_header("From", from_name); msg_add_header("From", from_name);
msg_add_header("Subject", tinrc.default_post_subject); msg_add_header("Subject", tinrc.default_post_subject);
if (art_type == GROUP_TYPE_MAIL) if (art_type == GROUP_TYPE_MAIL)
skipping to change at line 2496 skipping to change at line 2524
switch (func) { switch (func) {
case PROMPT_YES: case PROMPT_YES:
case POSTPONE_OVERRIDE: case POSTPONE_OVERRIDE:
post_postponed_article(func == PROMPT_YES, subjec t, newsgroups); post_postponed_article(func == PROMPT_YES, subjec t, newsgroups);
Raw(TRUE); Raw(TRUE);
break; break;
case PROMPT_NO: case PROMPT_NO:
case GLOBAL_QUIT: case GLOBAL_QUIT:
case GLOBAL_ABORT: case GLOBAL_ABORT:
if (!append_mail(article_name, userid, postponed_ if ((errno = append_mail(article_name, userid, po
articles_file)) { stponed_articles_file)))
/* TODO: error handling */ perror_message(_(txt_cannot_open_for_savi
} ng), postponed_articles_file);
unlink(article_name); unlink(article_name);
if (func != PROMPT_NO) if (func != PROMPT_NO)
return TRUE; return TRUE;
break; break;
default: default:
break; break;
} }
} }
return TRUE; return TRUE;
} }
static void static void
postpone_article( postpone_article(
const char *the_article) const char *the_article)
{ {
wait_message(3, _(txt_info_do_postpone)); wait_message(3, _(txt_info_do_postpone));
if (!append_mail(the_article, userid, postponed_articles_file)) { if ((errno = append_mail(the_article, userid, postponed_articles_file)))
/* TODO: error handling */ perror_message(_(txt_cannot_open_for_saving), postponed_articles_
} file);
} }
/* /*
* Post an original article (not a followup) * Post an original article (not a followup)
*/ */
t_bool t_bool
post_article( post_article(
const char *groupname) const char *groupname)
{ {
int art_type = GROUP_TYPE_NEWS; int art_type = GROUP_TYPE_NEWS;
skipping to change at line 2933 skipping to change at line 2959
default: default:
break; break;
} }
} }
if ((fp = fopen(article_name, "w")) == NULL) { if ((fp = fopen(article_name, "w")) == NULL) {
perror_message(_(txt_cannot_open), article_name); perror_message(_(txt_cannot_open), article_name);
return ret_code; return ret_code;
} }
#ifdef HAVE_FCHMOD
fchmod(fileno(fp), (mode_t) (S_IRUSR|S_IWUSR)); fchmod(fileno(fp), (mode_t) (S_IRUSR|S_IWUSR));
#else
# ifdef HAVE_CHMOD
chmod(article_name, (mode_t) (S_IRUSR|S_IWUSR));
# endif /* HAVE_CHMOD */
#endif /* HAVE_FCHMOD */
group = group_find(groupname, FALSE); group = group_find(groupname, FALSE);
get_from_name(from_name, group); get_from_name(from_name, group);
#ifdef FORGERY #ifdef FORGERY
make_path_header(line); make_path_header(line);
msg_add_header("Path", line); msg_add_header("Path", line);
#endif /* FORGERY */ #endif /* FORGERY */
msg_add_header("From", from_name); msg_add_header("From", from_name);
ptr = my_strdup(note_h.subj); ptr = my_strdup(note_h.subj);
skipping to change at line 3104 skipping to change at line 3136
#ifdef APPEND_PID #ifdef APPEND_PID
snprintf(filename + strlen(filename), filename_len - strlen(filename), ". %ld", (long) process_id); snprintf(filename + strlen(filename), filename_len - strlen(filename), ". %ld", (long) process_id);
#endif /* APPEND_PID */ #endif /* APPEND_PID */
if ((fp = fopen(filename, "w")) == NULL) { if ((fp = fopen(filename, "w")) == NULL) {
perror_message(_(txt_cannot_open), filename); perror_message(_(txt_cannot_open), filename);
return NULL; return NULL;
} }
#ifdef HAVE_FCHMOD
fchmod(fileno(fp), (mode_t) (S_IRUSR|S_IWUSR)); fchmod(fileno(fp), (mode_t) (S_IRUSR|S_IWUSR));
#else
# ifdef HAVE_CHMOD
chmod(filename, (mode_t) (S_IRUSR|S_IWUSR));
# endif /* HAVE_CHMOD */
#endif /* HAVE_FCHMOD */
if ((INTERACTIVE_NONE == tinrc.interactive_mailer) || (INTERACTIVE_WITH_H EADERS == tinrc.interactive_mailer)) { /* tin should include headers for editing */ if ((INTERACTIVE_NONE == tinrc.interactive_mailer) || (INTERACTIVE_WITH_H EADERS == tinrc.interactive_mailer)) { /* tin should include headers for editing */
char from_buf[HEADER_LEN]; char from_buf[HEADER_LEN];
char *from_address; char *from_address;
if (curr_group && curr_group->attribute && curr_group->attribute- >from && strlen(curr_group->attribute->from)) if (curr_group && curr_group->attribute && curr_group->attribute- >from && strlen(curr_group->attribute->from))
from_address = curr_group->attribute->from; from_address = curr_group->attribute->from;
else /* i.e. called from select.c without any groups */ else /* i.e. called from select.c without any groups */
from_address = tinrc.mail_address; from_address = tinrc.mail_address;
skipping to change at line 3810 skipping to change at line 3848
joinpath(cancel, sizeof(cancel), homedir, TIN_CANCEL_NAME); joinpath(cancel, sizeof(cancel), homedir, TIN_CANCEL_NAME);
#ifdef APPEND_PID #ifdef APPEND_PID
snprintf(cancel + strlen(cancel), sizeof(cancel) - strlen(cancel), ".%ld" , (long) process_id); snprintf(cancel + strlen(cancel), sizeof(cancel) - strlen(cancel), ".%ld" , (long) process_id);
#endif /* APPEND_PID */ #endif /* APPEND_PID */
if ((fp = fopen(cancel, "w")) == NULL) { if ((fp = fopen(cancel, "w")) == NULL) {
perror_message(_(txt_cannot_open), cancel); perror_message(_(txt_cannot_open), cancel);
return redraw_screen; return redraw_screen;
} }
#ifdef HAVE_FCHMOD
fchmod(fileno(fp), (mode_t) (S_IRUSR|S_IWUSR)); fchmod(fileno(fp), (mode_t) (S_IRUSR|S_IWUSR));
#else
# ifdef HAVE_CHMOD
chmod(cancel, (mode_t) (S_IRUSR|S_IWUSR));
# endif /* HAVE_CHMOD */
#endif /* HAVE_FCHMOD */
#ifdef FORGERY #ifdef FORGERY
if (!author) { if (!author) {
char line2[HEADER_LEN]; char line2[HEADER_LEN];
snprintf(line2, sizeof(line2), "cyberspam!%s", line); snprintf(line2, sizeof(line2), "cyberspam!%s", line);
msg_add_header("Path", line2); msg_add_header("Path", line2);
msg_add_header("From", from_name); msg_add_header("From", from_name);
msg_add_header("Sender", note_h.from); msg_add_header("Sender", note_h.from);
snprintf(line, sizeof(line), "<cancel.%s", note_h.messageid + 1); snprintf(line, sizeof(line), "<cancel.%s", note_h.messageid + 1);
skipping to change at line 4035 skipping to change at line 4079
if (art_type == GROUP_TYPE_MAIL && supersede) { if (art_type == GROUP_TYPE_MAIL && supersede) {
error_message(3, _("Can't supersede in mailgroups, try repost ins tead.")); /* TODO: -> lang.c */ error_message(3, _("Can't supersede in mailgroups, try repost ins tead.")); /* TODO: -> lang.c */
return ret_code; return ret_code;
} }
if ((fp = fopen(article_name, "w")) == NULL) { if ((fp = fopen(article_name, "w")) == NULL) {
perror_message(_(txt_cannot_open), article_name); perror_message(_(txt_cannot_open), article_name);
return ret_code; return ret_code;
} }
#ifdef HAVE_FCHMOD
fchmod(fileno(fp), (mode_t) (S_IRUSR|S_IWUSR)); fchmod(fileno(fp), (mode_t) (S_IRUSR|S_IWUSR));
#else
# ifdef HAVE_CHMOD
chmod(article_name, (mode_t) (S_IRUSR|S_IWUSR));
# endif /* HAVE_CHMOD */
#endif /* HAVE_FCHMOD */
get_from_name(from_name, group); get_from_name(from_name, group);
get_user_info(user_name, full_name); get_user_info(user_name, full_name);
if (Superseding) { if (Superseding) {
# ifdef FORGERY # ifdef FORGERY
make_path_header(line); make_path_header(line);
msg_add_header("Path", line); msg_add_header("Path", line);
skipping to change at line 4424 skipping to change at line 4474
} }
} /* end of headers */ } /* end of headers */
if ((group && group->attribute->advertising) || (!group && tinrc.advertis ing)) { /* Add after other headers */ if ((group && group->attribute->advertising) || (!group && tinrc.advertis ing)) { /* Add after other headers */
char suffix[HEADER_LEN]; char suffix[HEADER_LEN];
suffix[0] = '\0'; suffix[0] = '\0';
#if defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME) #if defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME)
if (*system_info.release) { if (*system_info.release) {
# ifdef _AIX # ifdef _AIX
snprintf(suffix, sizeof(suffix), " (%s/%s.%s)", snprintf(suffix, sizeof(suffix), "(%s/%s.%s)",
system_info.sysname, system_info.version, system_info.rel ease); system_info.sysname, system_info.version, system_info.rel ease);
# else # else
# if defined(SEIUX) || defined(__riscos) # if defined(SEIUX) || defined(__riscos)
snprintf(suffix, sizeof(suffix), " (%s/%s)", snprintf(suffix, sizeof(suffix), "(%s/%s)",
system_info.version, system_info.release); system_info.version, system_info.release);
# else # else
snprintf(suffix, sizeof(suffix), " (%s/%s (%s))", snprintf(suffix, sizeof(suffix), "(%s/%s (%s))",
system_info.sysname, system_info.release, system_ info.machine); system_info.sysname, system_info.release, system_ info.machine);
# endif /* SEIUX || __riscos */ # endif /* SEIUX || __riscos */
# endif /* _AIX */ # endif /* _AIX */
} }
#endif /* HAVE_SYS_UTSNAME_H && HAVE_UNAME */ #endif /* HAVE_SYS_UTSNAME_H && HAVE_UNAME */
#ifdef SYSTEM_NAME #ifdef SYSTEM_NAME
if (!*suffix && strlen(SYSTEM_NAME)) if (!*suffix && strlen(SYSTEM_NAME))
snprintf(suffix, sizeof(suffix), " (%s)", SYSTEM_ NAME); snprintf(suffix, sizeof(suffix), "(%s)", SYSTEM_N AME);
#endif /* SYSTEM_NAME */ #endif /* SYSTEM_NAME */
fprintf(fp_out, "User-Agent: %s/%s-%s (\"%s\") %s\n", fprintf(fp_out, "User-Agent: %s/%s-%s (\"%s\") %s\n",
PRODUCT, VERSION, RELEASEDATE, RELEASENAME, suffix); PRODUCT, VERSION, RELEASEDATE, RELEASENAME, suffix);
} }
fputs("\n", fp_out); /* header/body separator */ fputs("\n", fp_out); /* header/body separator */
while ((l = tin_fgets(fp_in, FALSE)) != NULL) while ((l = tin_fgets(fp_in, FALSE)) != NULL)
fprintf(fp_out, "%s\n", l); fprintf(fp_out, "%s\n", l);
skipping to change at line 4466 skipping to change at line 4516
static t_bool static t_bool
insert_from_header( insert_from_header(
const char *infile) const char *infile)
{ {
FILE *fp_in, *fp_out; FILE *fp_in, *fp_out;
char *line; char *line;
char *p; char *p;
char from_name[HEADER_LEN]; char from_name[HEADER_LEN];
char outfile[PATH_LEN]; char outfile[PATH_LEN];
int r;
t_bool from_found = FALSE; t_bool from_found = FALSE;
t_bool in_header = TRUE; t_bool in_header = TRUE;
if ((fp_in = fopen(infile, "r")) != NULL) { if ((fp_in = fopen(infile, "r")) != NULL) {
snprintf(outfile, sizeof(outfile), "%s.%ld", infile, (long) proce ss_id); snprintf(outfile, sizeof(outfile), "%s.%ld", infile, (long) proce ss_id);
if ((fp_out = fopen(outfile, "w")) != NULL) { if ((fp_out = fopen(outfile, "w")) != NULL) {
strcpy(from_name, "From: "); strcpy(from_name, "From: ");
if (*tinrc.mail_address) if (*tinrc.mail_address)
snprintf(from_name + 6, sizeof(from_name) - 7, "% s", tinrc.mail_address); snprintf(from_name + 6, sizeof(from_name) - 7, "% s", tinrc.mail_address);
else else
skipping to change at line 4502 skipping to change at line 4553
/* /*
* insert_from_header() is only called * insert_from_header() is only called
* from submit_mail_file() so the 3rd * from submit_mail_file() so the 3rd
* arg is TRUE * arg is TRUE
*/ */
# ifdef CHARSET_CONVERSION # ifdef CHARSET_CONVERSION
p = rfc1522_encode(from_buff, txt_mime_ch arsets[tinrc.mm_network_charset], TRUE); p = rfc1522_encode(from_buff, txt_mime_ch arsets[tinrc.mm_network_charset], TRUE);
# else # else
p = rfc1522_encode(from_buff, tinrc.mm_ch arset, TRUE); p = rfc1522_encode(from_buff, tinrc.mm_ch arset, TRUE);
# endif /* CHARSET_CONVERSION */ # endif /* CHARSET_CONVERSION */
if (gnksa_check_from(p) != GNKSA_OK) { /* r = gnksa_check_from(p);
error in address */ if (r > GNKSA_OK && r < GNKSA_MISSING_REA
LNAME) { /* error in address */
error_message(2, _(txt_invalid_fr om), from_buff); error_message(2, _(txt_invalid_fr om), from_buff);
free(p); free(p);
unlink(outfile); unlink(outfile);
fclose(fp_out); fclose(fp_out);
fclose(fp_in); fclose(fp_in);
return FALSE; return FALSE;
} }
free(p); free(p);
} }
if (*line == '\0' && in_header) { if (*line == '\0' && in_header) {
if (!from_found) { if (!from_found) {
/* Check the From: line */ /* Check the From: line */
# ifdef CHARSET_CONVERSION # ifdef CHARSET_CONVERSION
p = rfc1522_encode(from_name, txt _mime_charsets[tinrc.mm_network_charset], FALSE); p = rfc1522_encode(from_name, txt _mime_charsets[tinrc.mm_network_charset], FALSE);
# else # else
p = rfc1522_encode(from_name, tin rc.mm_charset, FALSE); p = rfc1522_encode(from_name, tin rc.mm_charset, FALSE);
# endif /* CHARSET_CONVERSION */ # endif /* CHARSET_CONVERSION */
if (gnksa_check_from(p + 6) != GN r = gnksa_check_from(p + 6);
KSA_OK) { /* error in address */ if (r > GNKSA_OK && r < GNKSA_MIS
SING_REALNAME) { /* error in address */
error_message(2, _(txt_in valid_from), from_name + 6); error_message(2, _(txt_in valid_from), from_name + 6);
free(p); free(p);
unlink(outfile); unlink(outfile);
fclose(fp_out); fclose(fp_out);
fclose(fp_in); fclose(fp_in);
return FALSE; return FALSE;
} }
free(p); free(p);
fprintf(fp_out, "%s\n", from_name ); fprintf(fp_out, "%s\n", from_name );
} }
skipping to change at line 4724 skipping to change at line 4777
error_message(2, _(txt_error_header_line_missing) , "To"); error_message(2, _(txt_error_header_line_missing) , "To");
free_and_init_header(&hdr); free_and_init_header(&hdr);
} }
} }
if (fcc != NULL) { if (fcc != NULL) {
if (mailed && strlen(fcc)) { if (mailed && strlen(fcc)) {
char a_mailbox[PATH_LEN]; char a_mailbox[PATH_LEN];
if (!strfpath(fcc, a_mailbox, sizeof(a_mailbox), group, T RUE)) if (!strfpath(fcc, a_mailbox, sizeof(a_mailbox), group, T RUE))
STRCPY(a_mailbox, fcc); STRCPY(a_mailbox, fcc);
if (!append_mail(file, userid, a_mailbox)) { if ((errno = append_mail(file, userid, a_mailbox)))
/* TODO: error handling */ perror_message(_(txt_cannot_open_for_saving), a_m
} ailbox);
} }
FreeIfNeeded(fcc); FreeIfNeeded(fcc);
} }
return mailed; return mailed;
} }
#ifdef FORGERY #ifdef FORGERY
static void static void
make_path_header( make_path_header(
char *line) char *line)
skipping to change at line 5177 skipping to change at line 5229
} }
if (fstat(fd, &statbuf) == -1) { if (fstat(fd, &statbuf) == -1) {
fclose(fp_secret); fclose(fp_secret);
return NULL; return NULL;
} }
# ifndef FILE_MODE_BROKEN # ifndef FILE_MODE_BROKEN
if ((S_ISREG(statbuf.st_mode)) && ((statbuf.st_mode|S_IRUSR|S_IWU SR) != (S_IRUSR|S_IWUSR|S_IFREG)) && (statbuf.st_size > 0)) { if ((S_ISREG(statbuf.st_mode)) && ((statbuf.st_mode|S_IRUSR|S_IWU SR) != (S_IRUSR|S_IWUSR|S_IFREG)) && (statbuf.st_size > 0)) {
# ifdef DEBUG # ifdef DEBUG
error_message(4, _(txt_error_insecure_permissions), path_ secret, statbuf.st_mode); error_message(4, _(txt_error_insecure_permissions), path_ secret, statbuf.st_mode);
# else # else
# ifdef HAVE_FCHMOD
fchmod(fd, S_IRUSR|S_IWUSR); fchmod(fd, S_IRUSR|S_IWUSR);
# else
# ifdef HAVE_CHMOD
chmod(path_secret, S_IRUSR|S_IWUSR);
# endif /* HAVE_CHMOD */
# endif /* HAVE_FCHMOD */
# endif /* DEBUG */ # endif /* DEBUG */
} }
# endif /* !FILE_MODE_BROKEN */ # endif /* !FILE_MODE_BROKEN */
(void) fread(cancel_secret, HEADER_LEN - 1, 1, fp_secret); (void) fread(cancel_secret, HEADER_LEN - 1, 1, fp_secret);
fclose(fp_secret); fclose(fp_secret);
} }
cancel_secret[HEADER_LEN - 1] = '\0'; cancel_secret[HEADER_LEN - 1] = '\0';
if ((ptr = strchr(cancel_secret, '\n'))) if ((ptr = strchr(cancel_secret, '\n')))
*ptr = '\0'; *ptr = '\0';
return cancel_secret; return cancel_secret;
} }
#endif /* USE_CANLOCK */ #endif /* USE_CANLOCK */
/* /*
* adds Message-ID- and Date-Header to infile, removes empty headers * adds Message-ID- and Date-header to infile, removes empty headers
*/ */
static void static void
add_headers( add_headers(
const char *infile, const char *infile,
const char *a_message_id) const char *a_message_id)
{ {
FILE *fp_in; FILE *fp_in;
char *line; char *line;
char outfile[PATH_LEN]; char outfile[PATH_LEN];
int fd_out; int fd_out;
 End of changes. 50 change blocks. 
50 lines changed or deleted 114 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)