Make it so users must exist to address them in local mail
This commit is contained in:
@@ -314,6 +314,8 @@ extern void gen_salt(char **s);
|
||||
extern char *hash_sha256(char *pass, char *salt);
|
||||
extern int save_user(struct user_record *user);
|
||||
extern int check_user(char *loginname);
|
||||
extern int check_fullname_j(char *firstandlastname);
|
||||
extern int check_fullname(char *firstname, char *lastname);
|
||||
extern struct user_record *new_user();
|
||||
extern struct user_record *check_user_pass(char *loginname, char *password);
|
||||
extern void list_users(struct user_record *user);
|
||||
|
@@ -1594,6 +1594,16 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
|
||||
s_printf(get_string(114));
|
||||
s_readstring_inject(buffer, 32, msghs->msgs[mailno]->from);
|
||||
to = strdup(buffer);
|
||||
if (ma->type == TYPE_LOCAL_AREA && (strcasecmp(to, "all") != 0 && check_user(to) && check_fullname_j(to))) {
|
||||
s_printf(get_string(55));
|
||||
free(body);
|
||||
free(subject);
|
||||
free(to);
|
||||
free(from);
|
||||
ptr_vector_apply(&msg_lines, free);
|
||||
destroy_ptr_vector(&msg_lines);
|
||||
return 0;
|
||||
}
|
||||
s_printf(get_string(115));
|
||||
s_readstring_inject(buffer, 64, subject);
|
||||
free(subject);
|
||||
@@ -2026,6 +2036,11 @@ void post_message(struct user_record *user) {
|
||||
strlcpy(buffer, "ALL", sizeof(buffer));
|
||||
}
|
||||
|
||||
if (ma->type == TYPE_LOCAL_AREA && (strcasecmp(buffer, "all") != 0 && check_user(buffer) && check_fullname_j(buffer))) {
|
||||
s_printf(get_string(55));
|
||||
return;
|
||||
}
|
||||
|
||||
if (ma->type == TYPE_NETMAIL_AREA) {
|
||||
s_printf(get_string(121));
|
||||
s_readstring(buffer2, 32);
|
||||
|
25
src/users.c
25
src/users.c
@@ -540,6 +540,27 @@ void list_users(struct user_record *user) {
|
||||
s_getc();
|
||||
}
|
||||
|
||||
int check_fullname_j(char *firstandlastname) {
|
||||
char *firstname = strdup(firstandlastname);
|
||||
|
||||
if (!firstname) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *lastname = strchr(firstname, ' ');
|
||||
int ret;
|
||||
|
||||
if (lastname == NULL) {
|
||||
return 0;
|
||||
}
|
||||
*lastname = '\0';
|
||||
lastname++;
|
||||
ret = check_fullname(firstname, lastname);
|
||||
|
||||
free(firstname);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int check_fullname(char *firstname, char *lastname) {
|
||||
sqlite3 *db = NULL;
|
||||
sqlite3_stmt *res = NULL;
|
||||
@@ -561,7 +582,7 @@ int check_fullname(char *firstname, char *lastname) {
|
||||
sqlite3_finalize(res);
|
||||
sqlite3_close(db);
|
||||
|
||||
return (!(step == SQLITE_ROW));
|
||||
return (step != SQLITE_ROW);
|
||||
}
|
||||
|
||||
int check_user(char *loginname) {
|
||||
@@ -576,7 +597,7 @@ int check_user(char *loginname) {
|
||||
if (rc != SQLITE_OK) {
|
||||
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
||||
sqlite3_close(db);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
sqlite3_bind_text(res, 1, loginname, -1, 0);
|
||||
int step = sqlite3_step(res);
|
||||
|
@@ -964,6 +964,10 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
||||
return 0;
|
||||
struct mail_area *ma = get_area(conference, area);
|
||||
|
||||
if (ma->type == TYPE_LOCAL_AREA && (strcasecmp(to, "all") != 0 && check_user(to) && check_fullname_j(to))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ma->write_sec_level <= user->sec_level && ma->type != TYPE_NETMAIL_AREA) {
|
||||
jb = open_jam_base(ma->path);
|
||||
if (!jb) {
|
||||
|
Reference in New Issue
Block a user