Skip to content

Instantly share code, notes, and snippets.

@iainlane
Created July 29, 2020 08:44
Show Gist options
  • Save iainlane/1277e2446e8503fc698f1a175fd4561f to your computer and use it in GitHub Desktop.
Save iainlane/1277e2446e8503fc698f1a175fd4561f to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <sys/capability.h>
#include <sys/types.h>
#include <unistd.h>
int
main ()
{
pid_t pid;
cap_t caps;
cap_flag_value_t cap_value;
pid = getpid ();
caps = cap_get_pid (pid);
if (!caps)
{
return 1;
}
if (cap_get_flag (caps,
CAP_SYS_TTY_CONFIG,
CAP_EFFECTIVE,
&cap_value) == -1)
{
return 1;
}
switch (cap_value)
{
case CAP_CLEAR:
printf ("CAP_SYS_TTY_CONFIG is unset\n");
break;
case CAP_SET:
printf ("CAP_SYS_TTY_CONFIG is set\n");
break;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment