Skip to content

Instantly share code, notes, and snippets.

@vbatts
Last active August 29, 2015 14:01
Show Gist options
  • Save vbatts/136be45931e7ebc9e25e to your computer and use it in GitHub Desktop.
Save vbatts/136be45931e7ebc9e25e to your computer and use it in GitHub Desktop.
get support capability
package main
/*
#include <linux/capability.h>
int has_cap_syslog() {
int ret = 0;
#ifdef CAP_SYSLOG
ret = 1;
#endif
return ret;
}
*/
import "C"
func main() {
if C.has_cap_syslog() == 1 {
println("yay")
} else {
println("boo")
}
}
package main
/*
#include <sys/capability.h>
#cgo LDFLAGS: -lcap
int is_cap_supported(cap_value_t cap) {
if (!CAP_IS_SUPPORTED(cap)) {
return 0;
}
return 1;
}
*/
import "C"
import "github.com/syndtr/gocapability/capability"
func main() {
if isCapSupported(capability.CAP_SYSLOG) {
println("yay")
} else {
println("boo")
}
}
func isCapSupported(c capability.Cap) bool {
return C.is_cap_supported(C.cap_value_t(c)) == 0
}
package main
/*
#include <linux/capability.h>
*/
import "C"
func main() {
println(C.CAP_SYSLOG)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment