Created
August 17, 2011 23:40
-
-
Save othiym23/1152936 to your computer and use it in GitHub Desktop.
Example of using TAP with tap-functions in /bin/bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
. ./taps/tap-functions | |
plan_tests 7 | |
PASSPHRASE="HamxSnadwich" | |
PASSPHRASE_HASH="2cfd41c20096d148" | |
is ${USER} 'ubuntu' | |
[ -e /usr/bin/ecryptfs-add-passphrase ] | |
ok $? "Ecryptfs userland is available." | |
KEYLOAD_HASH=$(echo ${PASSPHRASE} | /usr/bin/ecryptfs-add-passphrase 2>&1 | sed '/^Inserted/!d; s/^Inserted.*\[\(.*\)\].*$/\1/') | |
ok $? "Loaded '${PASSPHRASE}' into the kernel keyring for ${USER}." | |
is ${PASSPHRASE_HASH} ${KEYLOAD_HASH} | |
keyctl list @u | grep -q ${PASSPHRASE_HASH} | |
ok $? "Passphrase found in ${USER}'s keyring." | |
KEYRING_ID=$(keyctl list @u | grep ${PASSPHRASE_HASH} | awk -F: '{ print $1 }') | |
keyctl unlink ${KEYRING_ID} @u | |
ok $? "Key unloaded from ${USER}'s keyring." | |
keyctl list @u | grep -q ${KEYLOAD_HASH} | |
[ $? != 0 ] | |
ok $? "Key no longer found in ${USER}'s keyring." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment