How to password protect a folder?

Booting, installing, newbie
Post Reply
Message
Author
sidders
Posts: 464
Joined: Wed 23 Jul 2008, 18:47
Location: Bolton, uk

How to password protect a folder?

#1 Post by sidders »

Is there any way to password protect a folder?.

Or will i have to use an encryption tool. Its to protect the oneclick script, by making it available, with guide, so no one can go gung ho and wipe their HDD. Maybe create an admin folder.

Ta in advance

User avatar
trapster
Posts: 2117
Joined: Mon 28 Nov 2005, 23:14
Location: Maine, USA
Contact:

#2 Post by trapster »

See Here for how I do it.
trapster
Maine, USA

Asus eeepc 1005HA PU1X-BK
Frugal install: Slacko
Currently using full install: DebianDog

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#3 Post by Flash »

Be advised that password-protecting an unencrypted folder will not prevent accessing the folder from, say, a live CD. If all you want to do is prevent access by relatively unsophisticated users who may only have a casual interest in the contents of the folder, a password sounds sufficient.

sidders
Posts: 464
Joined: Wed 23 Jul 2008, 18:47
Location: Bolton, uk

#4 Post by sidders »

prevent access by relatively unsophisticated users who may only have a casual interest in the contents of the folder, a password sounds sufficient.
Thats what i'm after, an extra check before soneone wipes their hdd. Just batting ideas about.

Thanks Trapster and Flash

muggins
Posts: 6724
Joined: Fri 20 Jan 2006, 10:44
Location: hobart

#5 Post by muggins »

sidders,

another possibility is to use makeself to create a self-extracting archive of the directory. Because makeself uses a script, or executable, within the target directory, you can then create a target script that won't run, unless some particular password is entered. If the proper password is entered, the script can then run the one-click script.

http://megastep.org/makeself

sidders
Posts: 464
Joined: Wed 23 Jul 2008, 18:47
Location: Bolton, uk

#6 Post by sidders »

Thanks Muggins. I decided to go for your suggestion, however i was buggered if i could work it out. Couldnt even get it to work without a password. I will come back to it at some point and work it out.

:?

muggins
Posts: 6724
Joined: Fri 20 Jan 2006, 10:44
Location: hobart

#7 Post by muggins »

Hi Sidders,

say your target directory was called d1, and it contained a script called, for simplicity, run, then you could use makeself to create a self-extracting archive of this script like this:

Code: Select all

makeself --gzip --nox11 d1 archive_name "archive_name" ./run
This would create an archive, which would be extracted to /tmp directory, by executing ./archive_name, and then execute the script run.

You can replace "archive_name" with whatever, and save it to /usr/bin.

For run to test for a password, you could have something like this:

Code: Select all

#!/bin/sh

params=$#


if [ "$params" -eq 1 ];then
	
	echo && echo
	params=$1
	if [ "$params" == "qWerty" ];then #read the password
		./actual_target_program        #here run the real program
	
	else
	
		exit 1                                      #else exits
	fi
else
	#echo "wrong number of arguments!"
	exit 1
fi

sidders
Posts: 464
Joined: Wed 23 Jul 2008, 18:47
Location: Bolton, uk

#8 Post by sidders »

Brilliant Thx Muggins.

I did a simpler bash script for the password bit.

Code: Select all

#!/bin/sh
PASS="Wipehdd"

read -s -p "Password: " ans
echo
if [ "$PASS" == "$ans" ]; then
	./pinstall.sh

else
	echo "Wrong password, Installation stopped. close this window or try again"
fi
For the makeself

Code: Select all

# makeself.sh --gzip installer ./oneclick.run "oneclickinstaller" ./pwd
I just need to test it all out on a machine.

Post Reply