Page 1 of 1

How to password protect a folder?

Posted: Mon 22 Jun 2009, 20:23
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

Posted: Tue 23 Jun 2009, 10:50
by trapster
See Here for how I do it.

Posted: Tue 23 Jun 2009, 13:29
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.

Posted: Tue 23 Jun 2009, 14:25
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

Posted: Wed 24 Jun 2009, 00:02
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

Posted: Thu 25 Jun 2009, 20:46
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.

:?

Posted: Fri 26 Jun 2009, 01:43
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

Posted: Fri 26 Jun 2009, 11:07
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.