echo "immudex-crypt - script used for listing, open and close crypt_LUKS ppartitions";
echo "@ 2023 morketsmerke.org";
+ echo "Superuser (root) privileges are required.";
echo "Options:";
echo " list - displaing list of opened and available crypt_LUKS devices";
echo " create - formatting device for crypt_LUKS";
echo " open - opening crypt_LUKS device, after this device is ready to mount";
echo " close - unmount and closing crypt_LUKS devices";
echo "Using:";
- echo "$ immudex-crypt list";
- echo "$ immudex-crypt create <disk partition>";
- echo "$ immudex-crypt open <crypt_LUKS device>";
- echo "$ immudex-crypt close immudex-crypt[0-9] | ic[0-9] | [0-9]";
+ echo "# immudex-crypt list";
+ echo "# immudex-crypt create <disk partition>";
+ echo "# immudex-crypt open <crypt_LUKS device>";
+ echo "# immudex-crypt close immudex-crypt[0-9] | ic[0-9] | [0-9]";
}
function list() {
else
mountPoint=$(list | grep "$USER" | grep "$1" | awk '{printf $3}')
owner=$(stat -c %u $mountPoint);
- if [ $owner -eq $UID ]; then
- if id $USER | grep -q $UID; then
+ if [ $owner -eq $RUID ]; then
+ if id $USER | grep -q $RUID; then
echo "User $USER is already owner of $mountPoint";
fi
else
if [ "$1" ]; then
+ if [ $UID -ne 0 ]; then
+ echo "Permission denied!";
+ help;
+ exit 1;
+ fi
+
+ immudexCryptPID=$$;
+ parentProcessPID=$((immudexCryptPID - 1));
+ #immudex-crypt RUID is EUID of sudo, which spawning immudex-crypt
+ export RUID=$(grep '^Uid:' /proc/${parentProcessPID}/status | awk '{printf $2}');
+ export USER=$(grep "$RUID" /etc/passwd | cut -d ":" -f1);
+
case $1 in
"list") list;;
"open") if [ "$2" ]; then open $2;