summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCHTEKK <CHTEKK@localhost>2007-04-13 20:02:15 +0000
committerCHTEKK <CHTEKK@localhost>2007-04-13 20:02:15 +0000
commitb0844572c4f3a5d99d716610732c4eeb73ef9252 (patch)
tree20e2230d6d93c9108897a2c7b964e1e469271774
parentEnsure those vars are always treated as longs, initialize n for mailbox funct... (diff)
downloadchtekk-b0844572c4f3a5d99d716610732c4eeb73ef9252.tar.gz
chtekk-b0844572c4f3a5d99d716610732c4eeb73ef9252.tar.bz2
chtekk-b0844572c4f3a5d99d716610732c4eeb73ef9252.zip
Misc cleanups, tighten file perms a little (I can't see why others should have any access to maildirsize/maildirfilter at all).
svn path=/; revision=29
-rw-r--r--vda/postfix-2.4.0-vda-e-chtekk.patch42
1 files changed, 22 insertions, 20 deletions
diff --git a/vda/postfix-2.4.0-vda-e-chtekk.patch b/vda/postfix-2.4.0-vda-e-chtekk.patch
index b27fece..e4c4644 100644
--- a/vda/postfix-2.4.0-vda-e-chtekk.patch
+++ b/vda/postfix-2.4.0-vda-e-chtekk.patch
@@ -77,7 +77,7 @@ diff -Nru postfix-2.4.0/src/util/file_limit.c postfix-2.4.0-vda/src/util/file_li
struct rlimit rlim;
- rlim.rlim_cur = rlim.rlim_max = limit;
-+ /* rlim_max can be changed only by root */
++ /* rlim_max can only be changed by root. */
+ if (getrlimit(RLIMIT_FSIZE, &rlim) < 0)
+ msg_fatal("getrlimit: %m");
+ rlim.rlim_cur = limit;
@@ -123,7 +123,7 @@ diff -Nru postfix-2.4.0/src/virtual/mailbox.c postfix-2.4.0-vda/src/virtual/mail
+ VAR_VIRT_MAILBOX_LIMIT);
+ }
+ else {
-+ set_file_limit((off_t)n);
++ set_file_limit((off_t) n);
+ status = YES;
+
+ if (msg_verbose)
@@ -284,8 +284,8 @@ diff -Nru postfix-2.4.0/src/virtual/maildir.c postfix-2.4.0-vda/src/virtual/mail
+ * Arguments:
+ * n: filename
+ *
-+ * Returns the size given in ",S=size" in the filename,
-+ * zero if it cannot find ",S=size" in the filename.
++ * Returns the size given in ",S=<size>" in the filename,
++ * zero if it cannot find ",S=<size>" in the filename.
+ */
+static long maildir_parsequota(const char *n)
+{
@@ -335,9 +335,9 @@ diff -Nru postfix-2.4.0/src/virtual/maildir.c postfix-2.4.0-vda/src/virtual/mail
+ * Arguments:
+ * dirname: the name of the directory
+ * countptr: where to add the file count (because this function recurses)
-+ * mailplus: if the check will make use of the Maildir++ extension
++ * mailplus: if the check will make use of the Maildir++ file extension
+ *
-+ * Returns the sum of the sizes of all stattable files,
++ * Returns the sum of the sizes of all measurable files,
+ * zero if the directory could not be opened.
+ */
+static long check_dir_size(char *dirname, long *countptr, bool mailplus)
@@ -353,7 +353,7 @@ diff -Nru postfix-2.4.0/src/virtual/maildir.c postfix-2.4.0-vda/src/virtual/mail
+ if (make_dirs(dirname, 0700) == 0) { /* Try to create the dirs. */
+ dir = opendir(dirname); /* Reopen the dir. */
+ if (dir == NULL) {
-+ msg_warn("%s: cannot open directory: %s, second try", myname, dirname);
++ msg_warn("%s: cannot reopen directory: %s", myname, dirname);
+ return 0;
+ }
+ }
@@ -377,7 +377,7 @@ diff -Nru postfix-2.4.0/src/virtual/maildir.c postfix-2.4.0-vda/src/virtual/mail
+ }
+
+ if (var_virt_maildir_extended && mailplus) {
-+ /* Using Maildir++ size information. */
++ /* Using Maildir++ file extension. */
+ sum += maildir_parsequota(name);
+ (*countptr)++;
+ }
@@ -432,6 +432,7 @@ diff -Nru postfix-2.4.0/src/virtual/maildir.c postfix-2.4.0-vda/src/virtual/mail
+ return(ret);
+}
+
++/* Check if maildirfilter file is up-to-date compared to SQL, (re)write it if not. */
+static long sql2file(char *filename, char *user)
+{
+ char *myname = "sql2file";
@@ -470,10 +471,10 @@ diff -Nru postfix-2.4.0/src/virtual/maildir.c postfix-2.4.0-vda/src/virtual/mail
+ }
+
+ if (msg_verbose)
-+ msg_info("%s: filter data: sql_size=%u sql_mtime=%ld file_mtime=%ld", myname, strlen(filter_sqlres), sqlmtime, filemtime);
++ msg_info("%s: filter data: sql_size=%d sql_mtime=%ld file_mtime=%ld", myname, strlen(filter_sqlres), sqlmtime, filemtime);
+ }
+ if (sqlmtime != filemtime && sqlmtime != 0) {
-+ if ((filterfile = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0660))) {
++ if ((filterfile = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0640))) {
+ if (msg_verbose)
+ msg_info("%s: updating filter file: %s", myname, filename);
+ write(filterfile, filter_sqlres, strlen(filter_sqlres));
@@ -525,7 +526,7 @@ diff -Nru postfix-2.4.0/src/virtual/maildir.c postfix-2.4.0-vda/src/virtual/mail
GETTIMEOFDAY(&starttime);
/*
-@@ -122,6 +375,80 @@
+@@ -122,6 +375,81 @@
curdir = concatenate(usr_attr.mailbox, "cur/", (char *) 0);
/*
@@ -573,7 +574,8 @@ diff -Nru postfix-2.4.0/src/virtual/maildir.c postfix-2.4.0-vda/src/virtual/mail
+ /* Invalid limit size (negative), or zero. Set n to 0. */
+ n = 0;
+ }
-+ } else {
++ }
++ else {
+ /* There is no limit in the maps. Set n to 0. */
+ n = 0;
+ }
@@ -648,7 +650,7 @@ diff -Nru postfix-2.4.0/src/virtual/maildir.c postfix-2.4.0-vda/src/virtual/mail
+ if (saved_size > n) {
+ mail_copy_status = MAIL_COPY_STAT_WRITE;
+ vstring_sprintf(why->reason, "%s", var_virt_maildir_limit_message);
-+ if ((statbuf.st_size > n) || (var_virt_overquota_bounce))
++ if (((long) statbuf.st_size > n) || (var_virt_overquota_bounce))
+ errno = EFBIG;
+ else
+ errno = EDQUOT;
@@ -828,7 +830,7 @@ diff -Nru postfix-2.4.0/src/virtual/maildir.c postfix-2.4.0-vda/src/virtual/mail
+ sizefilename = concatenate(sizefilename, "maildirsize", (char *) 0);
+ }
+
-+ /* Make sure the quota in the file is the same as in the maildirsize file. */
++ /* Check if the quota in the file is the same as the current one, if not, delete the file. */
+ sizefile = vstream_fopen(sizefilename, O_RDONLY, 0);
+ if (sizefile) {
+ filequota = vstring_alloc(128);
@@ -839,17 +841,17 @@ diff -Nru postfix-2.4.0/src/virtual/maildir.c postfix-2.4.0-vda/src/virtual/mail
+ }
+
+ /* Open maildirsize file to append this transaction. */
-+ sizefile = vstream_fopen(sizefilename, O_WRONLY | O_APPEND, 0644);
++ sizefile = vstream_fopen(sizefilename, O_WRONLY | O_APPEND, 0640);
+
+ /* If the open fails (maildirsize doesn't exist), or it's too large, overwrite it. */
-+ if(!sizefile || (stat(sizefilename, &sizefile_stat) != 0) || (int) sizefile_stat.st_size > 5120 || (int) sizefile_stat.st_mtime + 15*60 < tm) {
-+ /* If the file exists, sizefile has been opened above, so close it. */
++ if(!sizefile || (stat(sizefilename, &sizefile_stat) != 0) || (int) sizefile_stat.st_size > 5120 || (int) sizefile_stat.st_mtime + 10*60 < tm) {
++ /* If the file exists, sizefile has been opened above, so close it first. */
+ if (sizefile) {
+ vstream_fclose(sizefile);
-+ sizefile = vstream_fopen(sizefilename, O_WRONLY | O_TRUNC, 0644);
++ sizefile = vstream_fopen(sizefilename, O_WRONLY | O_TRUNC, 0640);
+ }
+ else {
-+ sizefile = vstream_fopen(sizefilename, O_WRONLY | O_CREAT, 0644);
++ sizefile = vstream_fopen(sizefilename, O_WRONLY | O_CREAT, 0640);
+ }
+
+ /* If the creation worked, write to the file, otherwise just give up. */
@@ -859,7 +861,7 @@ diff -Nru postfix-2.4.0/src/virtual/maildir.c postfix-2.4.0-vda/src/virtual/mail
+ }
+ }
+ else {
-+ /* We opened maildirsize, so let's append our transaction and close it. */
++ /* We opened maildirsize, so let's just append this transaction and close it. */
+ vstream_fprintf(sizefile, "%ld 1\n", (long) statbuf.st_size);
+ vstream_fclose(sizefile);
+ }