[darcs-users] `darcs record` leaves emacs backup files in top directory

Thomas Zander zander at planescape.com
Thu Apr 7 13:08:09 UTC 2005


On Thu, Apr 07, 2005 at 08:08:35AM -0400, David Roundy wrote:
> On Thu, Apr 07, 2005 at 09:01:24AM +0200, Thomas Zander wrote:
> > On Wed, Apr 06, 2005 at 09:31:10PM +0000, Karl O. Pinc wrote:
> > > In unix setting the sticky bit on the directory
> > > might help.
> > > 
> > >  3. save the program's text image on the swap device so it will load
> > >     more quickly when run (called the "sticky bit").  For directories
> > >     on some systems, prevent users from removing or renaming a file in
> > >     a directory unless they own the file or the directory; this is
> > >     called the "restricted deletion flag" for the directory.
> > 
> > Which is normal for /tmp on all unix I know (solaris/linux-debian)
> 
> Ah, I wasn't aware of that.  So it should be safe then to create temp files
> in /tmp to be edited with $EDITOR then?

Yes;  just about all programs I know do that.  Do an ls /tmp while you
are typing a new email in mutt, for example.
I have a
'-rw-------    1 zander   users        1067 Apr  7 14:59 mutt-namlook-5628-5'.

So as long as you make sure $EDITOR is started with an umask of 077;
its perfectly save.

The only thing you may want to check is that the file actually is (still) from the
right user.  This to make sure that no prediction script (where the script can
predict the filename you are going to generate) can create a file before your
editor can and alter its protection and contents.

Simplest way is a
    a) generate new filename
    b) umask 077 && touch /tmp/$tmpfile
    c) check if /tmp/$tmpfile is of current uid, if not goto (a)
    d) start $EDITOR with /tmp/$tmpfile

naturally b) can be replaced with writing the default file-contents instead, just
make sure you do this using the umask idea; and not create a file and afterwards
set the protections.

Just some ideas.
-- 
Thomas Zander




More information about the darcs-users mailing list