]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/unix.c
replaced all #include <sys/syslog.h> with #include <syslog.h>
[netatalk.git] / etc / afpd / unix.c
index e56ba0078170c6a96ff6ade1adcc1eb79d7065b5..dbdb6ada828bd76fad2d1b4a5c8ce2c10790c893 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: unix.c,v 1.25 2001-12-03 05:03:38 jmarcus Exp $
+ * $Id: unix.c,v 1.27 2002-01-03 17:49:38 sibaz Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -16,7 +16,7 @@
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/stat.h>
-#include <sys/syslog.h>
+#include <syslog.h>
 #include <netatalk/endian.h>
 #include <dirent.h>
 #include <limits.h>
@@ -150,35 +150,22 @@ struct maccess    *ma;
 
 
 /*
- * Calculate the mode for a directory using Posix access() calls to
- * estimate permission, a la mdw.
+ * Calculate the mode for a directory using a stat() call to
+ * estimate permission.
+ *
+ * Note: the previous method, using access(), does not work correctly
+ * over NFS.
  */
 void accessmode( path, ma, dir )
 char           *path;
 struct maccess *ma;
 struct dir             *dir;
 {
-    if ( access( path, R_OK|W_OK|X_OK ) == 0 ) {
-        ma->ma_user = AR_UREAD|AR_UWRITE|AR_USEARCH|AR_UOWN;
-        ma->ma_owner = AR_UREAD|AR_UWRITE|AR_USEARCH;
-    } else if ( access( path, R_OK|X_OK ) == 0 ) {
-        ma->ma_user = AR_UREAD|AR_USEARCH;
-        ma->ma_owner = AR_UREAD|AR_USEARCH;
-    } else {
-        ma->ma_user = ma->ma_owner = 0;
-        if ( access( path, R_OK ) == 0 ) {
-            ma->ma_user |= AR_UREAD;
-            ma->ma_owner |= AR_UREAD;
-        }
-        if ( access( path, X_OK ) == 0 ) {
-            ma->ma_user |= AR_USEARCH;
-            ma->ma_owner |= AR_USEARCH;
-        }
-        if ( access( path, W_OK ) == 0 ) {
-            ma->ma_user |= AR_UWRITE|AR_UOWN;
-            ma->ma_owner |= AR_UWRITE;
-        }
-    }
+    struct stat sb;
+    ma->ma_user = ma->ma_owner = 0;
+    if ( stat( path, &sb ) == 0 )
+        utommode( &sb, ma );
+    return;
 }
 
 int gmem( gid )