Skip to content

Instantly share code, notes, and snippets.

@othiym23
Created August 17, 2011 23:40
Show Gist options
  • Save othiym23/1152936 to your computer and use it in GitHub Desktop.
Save othiym23/1152936 to your computer and use it in GitHub Desktop.
Example of using TAP with tap-functions in /bin/bash
#!/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