OK, after spending MANY hours getting instructions from a Linux veteran friend of mine, I managed to get an example working.
The only problem is that in my example I use sudo.
The thing is that sadly openSUSE doesn’t use the sudo command to it’s fullest potential, ie it asks for the root password instead of the user’s password (who is allowed to run apps as the root user).
This can be changed by modifying /etc/sudoers, but be warned that is quite a dangerous thing to do, and you really should ask for advice from someone who is much wiser than I am before you attempt it!
So anyway, using the sudo command, this is how I created, formatted, mounted, and unmounted an encrypted file -
------------------------------------------------------------------------
How to create an encrypted file and get it mounted into a folder -
1. Create the file - dd if=/dev/zero of=/home/growbag/test.crypt count=3000 bs=1024 (3gig-ish)
2. losetup - sudo losetup /dev/loop0 /home/growbag/test.crypt
3. cryptsetup create - sudo cryptsetup create growbagstest /dev/loop0 (enter passphrase)
4. cryptsetup luksformat - sudo cryptsetup luksFormat /dev/mapper/growbagstest
5. Format - sudo mkreiserfs --format=3.6 --label=growbagstest /dev/mapper/growbagstest
6. Mount - sudo mount -t auto /dev/mapper/growbagstest /home/growbag/zzz/
To unmount it again -
1. unmount - sudo umount /dev/mapper/growbagstest
2. cryptsetup remove - sudo cryptsetup remove growbagstest
3. losetup - sudo losetup -d /dev/loop0
4. Done :)
------------------------------------------------------------------------
Of course you don’t need to create or format the file, so just ignore those extra steps. I decided to post them here just in case I lost the instructions I just spent nearly 4 hours creating!
Now, if you can’t get sudo working properly, an alternative is to tell it to allow certain users to run certain commands without asking for a password!
It’s something like adding the relevent lines into /etc/sudoers (through visudo obviously!).
You would need a line something like the following for each user -
patti ALL = (ALL) /sbin/cryptsetup, /bin/mount, /bin/umount
user2 ALL = (ALL) /sbin/cryptsetup, /bin/mount, /bin/umount
etc.....
I am not 100% sure of those lines, and playing with visudo or /etc/sudoers is VERY dangerous, so please research it further before attempting it.
Plus doing the above will also allow those users to potentially do nasty things to the system and create a rather large security hole.
If you have got that working, that should allow the selected users to create the mapping devices, and mount their encrypted files.
BUT it could also allow those users to mount and unmount ANY device on the entire system and possibly read/write to it or do other horrid things!!!
I would then put the following into /etc/boot.local so that the encrypted files get assigned to loop devices on boot without it asking for a password -
losetup /dev/loop0 /SCRATCH-RAID10/Dirs/00Patti.001
and so on for each user....
The next step is to make 2 shell scripts, one to mount the encrypted file, and another to unmount it. Put them in ~/bin/ and then they can simply be linked to a menu or desktop icon so the user simply has to click to mount their file, and click another to unmount it again when finished -
# ~/bin/mount-encrypted.sh
# It should ask for both the user's (sudo) password
# and also the encrypted file's password
#
sudo cryptsetup create patti /dev/loop0
sudo mount /dev/mapper/patti /home/patti/MyShares/flames/
# ~/bin/unmount-encrypted.sh
# unmounts an encrypted file
#
sudo umount /dev/mapper/patti
sudo cryptsetup remove patti
Give those a try and see how it goes.