Skip to content

Instantly share code, notes, and snippets.

@spheromak
Last active November 25, 2015 21:30
Show Gist options
  • Save spheromak/6f35955856389fbe7e70 to your computer and use it in GitHub Desktop.
Save spheromak/6f35955856389fbe7e70 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# build cap_fake if it doesn't exist
#
if [ -z "$CIRCLECI" ]; then
echo "Nothing to do for cap fake unless we are are on Circle"
exit 1
fi
if [ -f ~/bin/set_cap_file.so ] ; then
echo "Cap fake lib already installed"
exit 1
fi
# wheee!
cap_code=<<EOF
#include <stdio.h>
#include <sys/capability.h>
int cap_set_file(const char *path_p, cap_t cap_p) {
printf("*** Intercepting cap_set_file() call and returning SUCCESS ***\n");
return 0;
}
EOF
echo $cap_code | gcc -Wall -fPIC -shared -o ~/bin/set_cap_file.so -xc -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment