improve error messages -- avoid "Error 0" syndrome
[unix-history] / usr / src / usr.sbin / sendmail / src / recipient.c
index 6fc0268..77eb62f 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)recipient.c        8.27 (Berkeley) %G%";
+static char sccsid[] = "@(#)recipient.c        8.28 (Berkeley) %G%";
 #endif /* not lint */
 
 # include "sendmail.h"
 #endif /* not lint */
 
 # include "sendmail.h"
@@ -647,16 +647,15 @@ writable(filename, flags)
                /* file does not exist -- see if directory is safe */
                p = strrchr(filename, '/');
                if (p == NULL)
                /* file does not exist -- see if directory is safe */
                p = strrchr(filename, '/');
                if (p == NULL)
-                       return FALSE;
-               *p = '\0';
-               if (safefile(filename, RealUid, RealGid, RealUserName,
-                            SFF_MUSTOWN, S_IWRITE|S_IEXEC) != 0)
                {
                {
-                       *p = '/';
+                       errno = ENOTDIR;
                        return FALSE;
                }
                        return FALSE;
                }
+               *p = '\0';
+               errno = safefile(filename, RealUid, RealGid, RealUserName,
+                                SFF_MUSTOWN, S_IWRITE|S_IEXEC);
                *p = '/';
                *p = '/';
-               return TRUE;
+               return errno == 0;
        }
 
        /*
        }
 
        /*
@@ -667,6 +666,7 @@ writable(filename, flags)
        {
                if (tTd(29, 5))
                        printf("failed (mode %o: x bits)\n", stb.st_mode);
        {
                if (tTd(29, 5))
                        printf("failed (mode %o: x bits)\n", stb.st_mode);
+               errno = EPERM;
                return (FALSE);
        }
 
                return (FALSE);
        }
 
@@ -695,7 +695,8 @@ writable(filename, flags)
                printf("\teu/gid=%d/%d, st_u/gid=%d/%d\n",
                        euid, egid, stb.st_uid, stb.st_gid);
 
                printf("\teu/gid=%d/%d, st_u/gid=%d/%d\n",
                        euid, egid, stb.st_uid, stb.st_gid);
 
-       return safefile(filename, euid, egid, uname, flags, S_IWRITE) == 0;
+       errno = safefile(filename, euid, egid, uname, flags, S_IWRITE);
+       return errno == 0;
 }
 \f/*
 **  INCLUDE -- handle :include: specification.
 }
 \f/*
 **  INCLUDE -- handle :include: specification.