1/* umode.c 2 Get the Unix file mode of a file using the user's permissions. */ 3 4#include "uucp.h" 5 6#include "uudefs.h" 7#include "sysdep.h" 8#include "system.h" 9 10#include <errno.h> 11 12unsigned int 13ixsysdep_user_file_mode (zfile) 14 const char *zfile; 15{ 16 uid_t ieuid; 17 gid_t iegid; 18 int iret; 19 struct stat s; 20 21 if (! fsuser_perms (&ieuid, &iegid)) 22 return 0; 23 24 iret = stat ((char *) zfile, &s); 25 26 if (! fsuucp_perms ((long) ieuid, (long) iegid)) 27 return 0; 28 29 if (iret != 0) 30 { 31 ulog (LOG_ERROR, "stat (%s): %s", zfile, strerror (errno)); 32 return 0; 33 } 34 35 /* We can't return 0, since that indicates an error. */ 36 if ((s.st_mode & 0777) == 0) 37 return 0400; 38 39 return s.st_mode & 0777; 40} 41