now makes the temporary editing file mode 0400 if in readonly
authorKurt A. Schoens <kas@ucbvax.Berkeley.EDU>
Fri, 17 Oct 1980 09:27:09 +0000 (01:27 -0800)
committerKurt A. Schoens <kas@ucbvax.Berkeley.EDU>
Fri, 17 Oct 1980 09:27:09 +0000 (01:27 -0800)
mode so that you can't easily change it.  also, will not read back in the
new version in read only mode.

SCCS-vsn: usr.bin/mail/edit.c 1.2

usr/src/usr.bin/mail/edit.c

index f08f7aa..c88b642 100644 (file)
@@ -10,7 +10,7 @@
  * Perform message editing functions.
  */
 
  * Perform message editing functions.
  */
 
-static char *SccsId = "@(#)edit.c      1.1 %G%";
+static char *SccsId = "@(#)edit.c      1.2 %G%";
 
 /*
  * Edit a message list.
 
 /*
  * Edit a message list.
@@ -122,6 +122,14 @@ edit1(msgvec, ed)
                }
                fclose(obuf);
 
                }
                fclose(obuf);
 
+               /*
+                * If we are in read only mode, make the
+                * temporary message file readonly as well.
+                */
+
+               if (readonly)
+                       chmod(edname, 0400);
+
                /*
                 * Fork/execl the editor on the edit file.
                 */
                /*
                 * Fork/execl the editor on the edit file.
                 */
@@ -147,6 +155,16 @@ edit1(msgvec, ed)
                while (wait(&mesg) != pid)
                        ;
 
                while (wait(&mesg) != pid)
                        ;
 
+               /*
+                * If in read only mode, just remove the editor
+                * temporary and return.
+                */
+
+               if (readonly) {
+                       remove(edname);
+                       continue;
+               }
+
                /*
                 * Now copy the message to the end of the
                 * temp file.
                /*
                 * Now copy the message to the end of the
                 * temp file.