Finita la parte sulle capabilities.
[gapil.git] / listati / getcap.c
diff --git a/listati/getcap.c b/listati/getcap.c
new file mode 100644 (file)
index 0000000..fc2fd3c
--- /dev/null
@@ -0,0 +1,21 @@
+    if (!pid) {
+       capab = cap_get_proc();
+       if (capab == NULL) {
+           perror("cannot get current process capabilities");
+           return 1;
+       }
+    } else {
+       capab = cap_init();
+       res = capgetp(pid, capab);
+       if (res) {
+           perror("cannot get process capabilities");
+           return 1;
+       }
+    }
+
+    string = cap_to_text(capab, NULL);
+    printf("Capability: %s\n", string);
+
+    cap_free(capab);
+    cap_free(string);
+    return 0;