[comp.unix.questions] Why am I getting this failure?

johnhi@teksce.SCE.TEK.COM (John Higley) (12/12/87)

Given the following code segment and two unrelated users:


---------------------------cut---------------------------------
#include <stdio.h>

extern int
  errno;
extern char
  *sys_errlist[];

main()
{
  FILE
    *testfile;

  if ((testfile=fopen("junkfile","r")) == NULL)
    fprintf(stderr,"Unable to open file - %s\n",sys_errlist[errno]);
}
---------------------------cut---------------------------------


User 1  owns the program  sets it up with the mode 4755 (-rwsr-xr-x)

User 2 creates a directory (junkdir) and a file (junkdir/junkfile)
The mode on junkdir is 700   junkfile is 644

User 2 goes into junkdir and executes the program.

The program should fail with Permission denied

User 2 changes mode on junkdir to 701 (o+x), and executes the program again.

The program fails with Permission denied.   (Why?)

User 2 changes mode on junkdir to 710 or 711 (g+x) and executes again.

The program succeeds.  (Why does fopen need group execute on the directory
when the two users are not in the same group????)


					John Higley
					johnhi@teksce.SCE.TEK.COM.UUCP