*** usermount.c.orig	Sat Feb  2 23:03:40 1991
--- usermount.c	Thu Feb  7 09:04:54 1991
***************
*** 103,108 ****
--- 103,117 ----
  			whoami(),ent.mnt_fsname);
  		exit (1);
  	    }
+ 	    if ( rw && hasmntopt(&ent, "ro" ))
+ 	    {
+ 	    	errno = 13;
+ 	    	perror ("Attempt to mount a readonly file system read write");
+ 	    	syslog(LOG_NOTICE,
+ 	    	   "%s: Attempt to mount %s readonly file system read write",
+ 	    	   whoami(),ent.mnt_fsname);
+ 	    	exit(1);
+ 	    }
  	    if (eject)
  	    {
  		ejectdisk(ent.mnt_fsname);
***************
*** 115,121 ****
  		    int i;
  
  		    i= errno;
! 		    syslog(LOG_NOTICE,"%s: Mount request failed for %s %m",whoami(),ent.mnt_fsname);
  		    errno = i;
  		    perror ("mount");
  		    continue;
--- 124,131 ----
  		    int i;
  
  		    i= errno;
! 		    syslog(LOG_NOTICE,"%s: Mount request failed for %s %m",
! 			whoami(),ent.mnt_fsname);
  		    errno = i;
  		    perror ("mount");
  		    continue;
***************
*** 166,172 ****
--- 176,185 ----
  {
      FILE *mtab;
      char temp[1024];
+     char *s;
  
+     bzero(temp,1024);
+ 
      if ((mtab = setmntent ("/etc/mtab","a")) == NULL )
      {
  	perror ("open mtab");
***************
*** 174,184 ****
      }
  
      if ( rw )
! 	(void)sprintf(temp,"%s,%s",fsent->mnt_opts,"rw");
!     else
! 	(void)sprintf(temp,"%s,%s",fsent->mnt_opts,"ro");
  
!     if (!hasmntopt(fsent,"suid"))
  	(void)sprintf(temp,"%s,%s",temp,"nosuid");
  
      fsent->mnt_opts = temp;
--- 187,214 ----
      }
  
      if ( rw )
!     {
!     	if (( s = hasmntopt(fsent,"ro")) != 0 ) {
!     		*(++s) = 'w';
!     	}
!     	if (( s = hasmntopt(fsent,"rw")) == 0 ) {	
!     		(void)sprintf(temp,"%s,%s",fsent->mnt_opts,"rw");
!     	} else
!     	    strcpy(temp,fsent->mnt_opts);
  
!     }
!     else 
!     {
!     if (( s = hasmntopt(fsent,"rw")) != 0 ) {
!     		*(++s) = 'o';
!     	} 
!     	if (( s = hasmntopt(fsent,"ro")) == 0 ) {	
! 		(void)sprintf(temp,"%s,%s",fsent->mnt_opts,"ro");
! 	} else
!     	    strcpy(temp,fsent->mnt_opts);
!      }
! 
!     if (!hasmntopt(fsent,"suid") && !hasmntopt(fsent,"nosuid"))
  	(void)sprintf(temp,"%s,%s",temp,"nosuid");
  
      fsent->mnt_opts = temp;
***************
*** 229,234 ****
--- 259,266 ----
  	option |= M_RDONLY;
  	ro = 1;
      }
+     else
+     	rw = 1;
      if (!hasmntopt (fsent, "bsd"))
  	option |= M_GRPID;
  
***************
*** 292,304 ****
  
      if ((pid = fork ()) == 0)
      {
! 	(void)sprintf (newpath, "PATH=/usr/etc:%s", getenv("PATH"));
! 	if (putenv (newpath))
! 	{
! 		perror ("cannot set PATH");
! 		exit (1);
! 	}
! 	(void)execl ("/usr/bin/eject", device, (char *) 0);
  	perror ("exec");
  	exit (1);
      }
--- 324,336 ----
  
      if ((pid = fork ()) == 0)
      {
! 	 (void)sprintf (newpath, "PATH=/usr/etc:%s", getenv("PATH"));
! 	 if (putenv (newpath))
! 	 {
! 	     perror ("cannot set PATH");
! 	     exit (1);
! 	 }
! 	(void)execl ("/usr/bin/eject"," eject", device, (char *) 0);
  	perror ("exec");
  	exit (1);
      }
