Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Create a ramfs drive to store
- # secure password temporarily
- # Terribly Linux specific
- targetdir=/tmp/ram_drive
- passfile=app_pass.txt
- my_user=$SUDO_USER
- check_mount() {
- if grep "$targetdir ramfs" /etc/mtab >/dev/null
- then
- # move on quietly.
- :
- else
- mkdir -p $targetdir
- mount -t ramfs none $targetdir
- # Make sure its really there now
- if grep "$targetdir ramfs" /etc/mtab >/dev/null
- then
- :
- else
- echo "$0: failed to mount ramdisk" 1>&2
- exit 1
- fi
- fi
- }
- ask_for_ad_pass() {
- if [ -f $targetdir/$passfile ];
- then
- # exit silently
- exit 0;
- fi
- old_settings=$(stty -g)
- stty -echo
- echo -n "Password: "
- read pass
- echo $pass > $targetdir/$passfile
- stty $old_settings
- chown "${my_user}" $targetdir/$passfile
- chmod 600 $targetdir/$passfile
- echo
- echo "Stored Password on RAM Drive"
- }
- check_mount
- ask_for_pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement