On Thu, Sep 18, 2003 at 11:44:38AM +0100, Brian Candler wrote:
> But it looks like it's unable to write a config file, which I don't
> understand; the files sqwebmail-* and their enclosing directory are all
> owned by the right user.

Sorted. It was one of the *folders* which had wrong permissions.

The attached patch should improve some of the messages returned in this case
though.

I did find another error though: if you enter a space after the login name,
it authenticates but sqwebmail says

  "Unable to access your mailbox, sqwebmail permissions may be wrong."

which is confusing to say the least, because all you need to do is take out
the space after the login name. It's a bit strange though. I'm using
authldap if that makes any difference.

Regards,

Brian.
diff -uNr sqwebmail-3.6.0.orig/sqwebmail/maildir.c sqwebmail-3.6.0/sqwebmail/maildir.c
--- sqwebmail-3.6.0.orig/sqwebmail/maildir.c    Thu May  8 16:10:36 2003
+++ sqwebmail-3.6.0/sqwebmail/maildir.c Thu Sep 18 12:17:59 2003
@@ -867,22 +867,26 @@
 
                if ((fromfd=maildir_semisafeopen(file, O_RDONLY, 0)) < 0)
                {
+                       int terrno = errno;
                        free(destdir);
                        close(tofd);
                        unlink(createInfo.tmpname);
                        maildir_tmpcreate_free(&createInfo);
-                       enomem();
+                       error3(__FILE__, __LINE__, "Failed to open for read:",
+                               file, terrno);
                }
 
                umask (0077);
                if (msgcopy(fromfd, tofd))
                {
+                       int terrno = errno;
                        close(fromfd);
                        close(tofd);
                        free(destdir);
                        unlink(createInfo.tmpname);
                        maildir_tmpcreate_free(&createInfo);
-                       enomem();
+                       error3(__FILE__, __LINE__, "Failed to copy message",
+                               "", terrno);
                }
                close(fromfd);
                close(tofd);
@@ -1474,7 +1478,7 @@
        sprintf(cntbuf, "%u %u", *new_cnt, *other_cnt);
        write_sqconfig(dir, MAILDIRCOUNTCACHE, cntbuf);
        if ( read_sqconfig(dir, MAILDIRCOUNTCACHE, &cntmtime) == 0)
-               enomem();
+               emsg("Failed to read",MAILDIRCOUNTCACHE);
        if (cntmtime != cur_stat.st_mtime)
        {
                struct stat stat2;
diff -uNr sqwebmail-3.6.0.orig/sqwebmail/sqconfig.c 
sqwebmail-3.6.0/sqwebmail/sqconfig.c
--- sqwebmail-3.6.0.orig/sqwebmail/sqconfig.c   Wed Dec  8 06:00:38 1999
+++ sqwebmail-3.6.0/sqwebmail/sqconfig.c        Thu Sep 18 11:54:06 2003
@@ -60,10 +60,10 @@
        else
        {
                f=fopen(p, "w");
-               if (!f) enomem();
+               if (!f) eio("Unable to open for write:",p);
                fprintf(f, "%s\n", val);
                fflush(f);
-               if (ferror(f))  enomem();
+               if (ferror(f))  eio("Error after write:",p);
                fclose(f);
 
                /* Note - umask should already turn off the 077 bits, but
diff -uNr sqwebmail-3.6.0.orig/sqwebmail/sqwebmail.c 
sqwebmail-3.6.0/sqwebmail/sqwebmail.c
--- sqwebmail-3.6.0.orig/sqwebmail/sqwebmail.c  Sun Aug 10 00:11:09 2003
+++ sqwebmail-3.6.0/sqwebmail/sqwebmail.c       Thu Sep 18 12:36:46 2003
@@ -405,6 +405,20 @@
        fake_exit(1);
 }
 
+void error3(const char *file, int line, const char *msg1, const char *msg2, int err)
+{
+       cginocache();
+       if (err == -1) err = errno;
+       printf("Content-Type: text/html; charset=us-ascii\n\n"
+               "<html><head><title>Internal error</title></head><body>"
+               "<h1>Internal error (module %s, line %d) - contact system 
administrator</h1>"
+               "<pre>%s\n%s\n%s</pre>"
+               "</body></html>\n",
+               file, line, msg1?msg1:"", msg2?msg2:"", err?strerror(err):"");
+       cleanup();
+       fake_exit(1);
+}
+
 
 char *get_templatedir()
 {
@@ -2458,8 +2472,7 @@
                                ((rm=getenv("CONTENT_TYPE")) != 0 &&
                                strncasecmp(rm,"multipart/form-data;", 20)
                                        == 0)))
-                       enomem();       /* multipart/formdata posts not allowed
-                                       */
+                       emsg("multipart/formdata posts not allowed","");
 
                /* Some additional safety checks */
 
diff -uNr sqwebmail-3.6.0.orig/sqwebmail/sqwebmail.h 
sqwebmail-3.6.0/sqwebmail/sqwebmail.h
--- sqwebmail-3.6.0.orig/sqwebmail/sqwebmail.h  Wed Jul  9 20:19:16 2003
+++ sqwebmail-3.6.0/sqwebmail/sqwebmail.h       Thu Sep 18 12:25:23 2003
@@ -17,8 +17,11 @@
 #endif
 
 extern void error(const char *), error2(const char *, int);
+extern void error3(const char *, int, const char *, const char *, int);
 
 #define        enomem()        error2(__FILE__,__LINE__)
+#define eio(x,y)       error3(__FILE__,__LINE__,x,y,-1)
+#define emsg(x,y)      error3(__FILE__,__LINE__,x,y,0)
 
 /* Location of the user's Maildir */
 

Reply via email to