[77] in Info-AFS_Redistribution

home help back first fref pref prev next nref lref last post

Re: A question on protection semantics.

daemon@ATHENA.MIT.EDU (daemon@ATHENA.MIT.EDU)
Tue Feb 12 13:50:50 1991

Date: Tue, 12 Feb 1991 12:47:17 -0500 (EST)
From: Phil_Hirsch@transarc.com
To: Tony_Mauro@transarc.com, Carol Kamm <cak@ifs.umich.edu>
Cc: Info-AFS@transarc.com, Christer Bernerus <bernerus@cs.chalmers.se>,
In-Reply-To: <Added.sbi1Rv30Bi8107EE9B@transarc.com>


The "known bug" I referred to in an earlier post can be observed with the
following program:

-------------------------------------------------------------------------------
/*
 * This program illustrates different behavior amongst systems running AFS 3
   when they try to open a file with O_WRONLY|O_CREAT, and the file already
   exists and has Unix mode 0222. Note that ALL of these conditions are
   necessary in order to observe the differing behavior.
*/

#include <stdio.h>
#include <errno.h>
#include <fcntl.h>

extern char *sys_errlist[];
extern int errno;

main()
{
char buf[80];
int fd,l,rf;

system("rm -rf tempfile;  echo 'original contents' > tempfile; cat tempfile");
system("chmod 222 tempfile; ls -l tempfile");

fd = open("tempfile",O_WRONLY|O_CREAT,0666);
/* This open will fail (errno 13, EACCES) under SunOS, HP/UX, and IBM-RT AOS.
   It succeeds on RS/6000's running AIX 3.1 and on DEC Pmaxes. */
printf("   results of open: fd = %d; errno = %d (%s).\n",
   fd,(fd<0)? errno:0,(fd<0)? sys_errlist[errno]:"success");

if(fd >= 0)
   {
   strcpy(buf,"modified tempfile\n");
   l = strlen(buf)+1;
   rf = write(fd,buf,l);
   printf("   results of write: rf = %d; errno = %d (%s).\n",
      rf,(rf!=l)? errno:0, (rf!=l)? sys_errlist[errno]:"success");
   close(fd);
   }

system("chmod 666 tempfile; cat tempfile");
printf("\n");
exit(0);
}
-------------------------------------------------------------------------------

I can't explain the behavior you saw with the "date" command from the shell;
I tried it myself on both a Sun and an RS/6000 and saw the same results you
did. I would have guessed that the command   "date >> aa"   would fail on the
Sun but not on the RS/6000.



home help back first fref pref prev next nref lref last post