Last active
August 29, 2015 14:01
-
-
Save vbatts/136be45931e7ebc9e25e to your computer and use it in GitHub Desktop.
get support capability
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
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") | |
} | |
} |
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
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 | |
} |
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
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