Skip to content

Instantly share code, notes, and snippets.

@turkerali
Created February 17, 2023 11:52
Show Gist options
  • Save turkerali/6f701001426470bbe728f32670fd3abe to your computer and use it in GitHub Desktop.
Save turkerali/6f701001426470bbe728f32670fd3abe to your computer and use it in GitHub Desktop.
Various vpopmail fixes
diff -ruN vpopmail-5.4.33-original/vdelivermail.c vpopmail-5.4.33/vdelivermail.c
--- vpopmail-5.4.33-original/vdelivermail.c 2011-02-28 19:00:45.000000000 +0200
+++ vpopmail-5.4.33/vdelivermail.c 2023-02-17 14:10:02.573403715 +0300
@@ -644,7 +644,7 @@
parse_email(maildir_to_email(address), TheUser, TheDomain, AUTH_SIZE);
vpw=vauth_getpw(TheUser, TheDomain);
}
- if ( vpw!=NULL && (limits.disable_spamassassin==1 ||
+ if ( vpw!=NULL && (limits.disable_maildrop==1 ||
(vpw->pw_gid & NO_MAILDROP)) ) {
#endif
if ( strncmp(quota, "NOQUOTA", 2) != 0 ) {
diff -ruN vpopmail-5.4.33-original/vmysql.c vpopmail-5.4.33/vmysql.c
--- vpopmail-5.4.33-original/vmysql.c 2023-02-17 14:09:09.872130173 +0300
+++ vpopmail-5.4.33/vmysql.c 2023-02-17 14:24:01.305747105 +0300
@@ -913,8 +913,8 @@
if ( ipaddr == NULL ) {
return 0;
}
-
- if ( (err=vauth_open_update()) != 0 ) return 0;
+ // open_smtp_relay() expects "-1" on database errors. "0" means duplicate record. (See vpopmail.c)
+ if ( (err=vauth_open_update()) != 0 ) return (-1);
qnprintf( SqlBufUpdate, SQL_BUF_SIZE,
"replace into relay ( ip_addr, timestamp ) values ( '%s', %d )",
@@ -1863,6 +1863,11 @@
/************************************************************************/
int vdel_limits(const char *domain)
{
+ int err;
+
+ // CHECKS IF A DATABASE CONNECTION IS AVAILABLE, CONNECTS IF NOT.
+ // THIS CHECK PREVENTS "CORE-DUMP" OF vqadmin.cgi.
+ if ( (err=vauth_open_update()) != 0 ) return (err);
qnprintf(SqlBufUpdate, SQL_BUF_SIZE, "DELETE FROM limits WHERE domain = '%s'", domain);
if (mysql_query(&mysql_update,SqlBufUpdate))
diff -ruN vpopmail-5.4.33-original/voracle.pc vpopmail-5.4.33/voracle.pc
--- vpopmail-5.4.33-original/voracle.pc 2011-02-28 19:00:45.000000000 +0200
+++ vpopmail-5.4.33/voracle.pc 2023-02-17 14:18:27.347078902 +0300
@@ -779,7 +779,8 @@
++ipaddr;
}
- if ( (err=vauth_open_update()) != 0 ) return;
+ // open_smtp_relay() expects "-1" on database errors. "0" means duplicate record. (See vpopmail.c)
+ if ( (err=vauth_open_update()) != 0 ) return (-1);
qnprintf( SqlBufUpdate, SQL_BUF_SIZE,
"insert into relay ( ip_addr, timestamp ) values ( '%s', %d )",
@@ -1442,6 +1443,11 @@
int vdel_limits( char *domain )
{
+ int err;
+
+ // CHECKS IF A DATABASE CONNECTION IS AVAILABLE, CONNECTS IF NOT.
+ // THIS CHECK PREVENTS "CORE-DUMP" OF vqadmin.cgi.
+ if ( (err=vauth_open_update()) != 0 ) return(err);
qnprintf( SqlBufUpdate, SQL_BUF_SIZE, "DELETE FROM limits WHERE domain = '%s'",
domain);
EXEC SQL PREPARE S FROM :SqlBufUpdate;
diff -ruN vpopmail-5.4.33-original/vpgsql.c vpopmail-5.4.33/vpgsql.c
--- vpopmail-5.4.33-original/vpgsql.c 2023-02-17 14:09:09.872130173 +0300
+++ vpopmail-5.4.33/vpgsql.c 2023-02-17 14:14:40.686873149 +0300
@@ -772,7 +772,8 @@
time_t delete_time;
int err;
- if ( (err=vauth_open(1)) != 0 ) return;
+ // open_smtp_relay() expects "-1" on database errors. "0" means duplicate record. (See vpopmail.c)
+ if ( (err=vauth_open(1)) != 0 ) return (-1);
delete_time = mytime - clear_minutes;
snprintf( SqlBufUpdate, SQL_BUF_SIZE,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment