Make it so users must exist to address them in local mail
This commit is contained in:
parent
60b7d0d874
commit
41b0e18ffc
2
dist/magicka.strings
vendored
2
dist/magicka.strings
vendored
@ -61,7 +61,7 @@ Non-STDIO door support on SSH is currently broken...\r\n
|
|||||||
\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n
|
\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n
|
||||||
\e[1;37mPress \e[1;36mR\e[1;37m to reply, \e[1;36mD\e[1;37m to delete \e[1;36mEnter\e[1;37m to quit...\e[0m\r\n
|
\e[1;37mPress \e[1;36mR\e[1;37m to reply, \e[1;36mD\e[1;37m to delete \e[1;36mEnter\e[1;37m to quit...\e[0m\r\n
|
||||||
\r\nYou have no email\r\n
|
\r\nYou have no email\r\n
|
||||||
\e[2J\e[1;1H\e[1;37;44m[MSG#] Subject From Date \r\n\e[0m
|
\e[1;37;44m[MSG#] Subject From Date \r\n\e[0m
|
||||||
\e[1;30m[\e[1;34m%4d\e[1;30m]\e[1;32m*\e[1;37m%-39.39s \e[1;32m%-16.16s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n
|
\e[1;30m[\e[1;34m%4d\e[1;30m]\e[1;32m*\e[1;37m%-39.39s \e[1;32m%-16.16s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n
|
||||||
\e[1;30m[\e[1;34m%4d\e[1;30m] \e[1;37m%-39.39s \e[1;32m%-16.16s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n
|
\e[1;30m[\e[1;34m%4d\e[1;30m] \e[1;37m%-39.39s \e[1;32m%-16.16s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n
|
||||||
\e[1;37mEnter \e[1;36m# \e[1;37mto read, \e[1;36mQ \e[1;37mto quit or \e[1;36mEnter\e[1;37m to continue\e[0m\r\n
|
\e[1;37mEnter \e[1;36m# \e[1;37mto read, \e[1;36mQ \e[1;37mto quit or \e[1;36mEnter\e[1;37m to continue\e[0m\r\n
|
||||||
|
@ -314,6 +314,8 @@ extern void gen_salt(char **s);
|
|||||||
extern char *hash_sha256(char *pass, char *salt);
|
extern char *hash_sha256(char *pass, char *salt);
|
||||||
extern int save_user(struct user_record *user);
|
extern int save_user(struct user_record *user);
|
||||||
extern int check_user(char *loginname);
|
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 *new_user();
|
||||||
extern struct user_record *check_user_pass(char *loginname, char *password);
|
extern struct user_record *check_user_pass(char *loginname, char *password);
|
||||||
extern void list_users(struct user_record *user);
|
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_printf(get_string(114));
|
||||||
s_readstring_inject(buffer, 32, msghs->msgs[mailno]->from);
|
s_readstring_inject(buffer, 32, msghs->msgs[mailno]->from);
|
||||||
to = strdup(buffer);
|
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_printf(get_string(115));
|
||||||
s_readstring_inject(buffer, 64, subject);
|
s_readstring_inject(buffer, 64, subject);
|
||||||
free(subject);
|
free(subject);
|
||||||
@ -2026,6 +2036,11 @@ void post_message(struct user_record *user) {
|
|||||||
strlcpy(buffer, "ALL", sizeof(buffer));
|
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) {
|
if (ma->type == TYPE_NETMAIL_AREA) {
|
||||||
s_printf(get_string(121));
|
s_printf(get_string(121));
|
||||||
s_readstring(buffer2, 32);
|
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();
|
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) {
|
int check_fullname(char *firstname, char *lastname) {
|
||||||
sqlite3 *db = NULL;
|
sqlite3 *db = NULL;
|
||||||
sqlite3_stmt *res = NULL;
|
sqlite3_stmt *res = NULL;
|
||||||
@ -561,7 +582,7 @@ int check_fullname(char *firstname, char *lastname) {
|
|||||||
sqlite3_finalize(res);
|
sqlite3_finalize(res);
|
||||||
sqlite3_close(db);
|
sqlite3_close(db);
|
||||||
|
|
||||||
return (!(step == SQLITE_ROW));
|
return (step != SQLITE_ROW);
|
||||||
}
|
}
|
||||||
|
|
||||||
int check_user(char *loginname) {
|
int check_user(char *loginname) {
|
||||||
@ -576,7 +597,7 @@ int check_user(char *loginname) {
|
|||||||
if (rc != SQLITE_OK) {
|
if (rc != SQLITE_OK) {
|
||||||
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
|
||||||
sqlite3_close(db);
|
sqlite3_close(db);
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
sqlite3_bind_text(res, 1, loginname, -1, 0);
|
sqlite3_bind_text(res, 1, loginname, -1, 0);
|
||||||
int step = sqlite3_step(res);
|
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;
|
return 0;
|
||||||
struct mail_area *ma = get_area(conference, area);
|
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) {
|
if (ma->write_sec_level <= user->sec_level && ma->type != TYPE_NETMAIL_AREA) {
|
||||||
jb = open_jam_base(ma->path);
|
jb = open_jam_base(ma->path);
|
||||||
if (!jb) {
|
if (!jb) {
|
||||||
|
Reference in New Issue
Block a user