Newsgroups: comp.lang.pascal
Subject: Re: Securing Directories
From: khill@vax1.umkc.edu
Date: 15 Apr 92 09:53:09 CST
Organization: University of Missouri-Kansas City

In article <1992Apr7.173354.24275@oucsace.cs.ohiou.edu>, rsandfor@oucsace.cs.ohiou.edu (Robert L. Sandford) writes:
> Just for curiosity, I was wondering if anyone has ever written a
> program or know how to write a program that will ask you for a 
> password when you try to enter a directory (cd tmp). I would like
> to make some of my directories on my 386 to have passwords on them
> to keep people from erasing files... For example my batch, data and
> config directory has been wiped out several times. I do have backups
> on diskettes, but with a password directory it would solve my 
> problems.
> 
> 		   Thanks in advance
> 	           Robert Sandford
> 

	Have you tried making all of the files in your subdirectory read-only.
This would prevent the DEL command from removing the files, however it would
leave the files visible in the directory.  You can also make the files hidden
or system.  Hidden files can be used by other programs, through DOS, but
if you type DIR you will not see them, and DEL does not work either.  Setting
the system attribute also makes the files invisible to DIR and DEL, but they
are also invisible to DOS, in general (I did not say completely, just not
easily).  A side effect of setting the system attribute is that some HD
defragers will not defrag a file that has the system file set -- this is for
use with lower versions of DOS that required the IO.SYS and MSDOS.SYS files
to be at the start of the disk in contiguous sectors, DOS 5.0 no longer has
this restriction.  Using the ATTRIB command should solve your problem of
accidental file deletion, since you would have to purposely turn off the 
attributes to make the files deletable. 
	If you wish some added security, remember you can set attributes
on subdirectorys just like you can on files.  Just use /D with the ATTRIB
command and it will set subdirectory attributes instead of file attributes.
For example, you can say ATTRIB +hr /D TOPSCRT.  This will make the TOPSCRT
subdirectory hidden and read-only.  When you type DIR you will not see
	TOPSCRT		<DIR>	01-01-92  14:31
in the listing.  If somebody is looking through your HD they will never know
about that subdirectory.  This subdirectory is still perfectly usable.
Programs can access it, you can access it, and every file in it.  However,
you just do not see it in your DIR listing.
	Lastly if you have ever deleted important files because of a missed
placed DEL *.* try using the following instead:
	
	4DOS only  -- 
             alias dab=attrib +r %1 %2 %3 %4 ^ del *.* ^ attrib -r %1 %2 %3 %4

	MSDOS -- [c:\dos must be in your path]
	     copy con c:\dos\dab.bat
	     attrib +r %1 %2 %3 %4 %5 %6 %7 %8 %9
             del *.*
             attrib -r %1 %2 %3 %4 %5 %6 %7 %8 %9
             ^Z

	DAB means Delete All But.  I use this command without parameters
instead of DEL *.*.  This forces me to consciously think -- "is there anything
here I want to keep?"  This has saved me many times!

 	Example : to keep all .ZIP files, .ZOO files and PKUNZIP.EXE and
		  BOOZ.EXE but delete all the rest type:
			 'DAB *.ZIP *.ZOO PKUNZIP.EXE BOOZ.EXE'
-- 
================================================================================
| Ken Hill              | The opinions in this letter are not mine.  They were |
| Amateur Mathematician | created by an evil computer with a mind of its own!  |
| Professional Paper boy|                                                      |
| KHILL@VAX1.UMKC.EDU   |   :)<-<   "HELP, I've fallen and I can't get up!"    |
================================================================================
Newsgroups: comp.lang.pascal