Beispiel #1
0
def capabilities(pid):
    permitted = None

    capng.capng_setpid(pid)
    capng.capng_clear(capng.CAPNG_SELECT_BOTH)
    capng.capng_get_caps_process()
    caps = capng.capng_have_capabilities(capng.CAPNG_SELECT_CAPS)

    if caps > capng.CAPNG_NONE:
        if caps == capng.CAPNG_PARTIAL:
            permitted = capng.capng_print_caps_text(capng.CAPNG_PRINT_BUFFER,
                                                    capng.CAPNG_PERMITTED)
            if capng.capng_have_capabilities(
                    capng.CAPNG_SELECT_BOUNDS) == capng.CAPNG_FULL:
                permitted += "+"
        else:
            permitted = "full"
    return permitted
Beispiel #2
0
load_path = '../'
if False:
    sys.path.insert(0, load_path)

import capng

last = capng.CAP_LAST_CAP
try:
    with open('/proc/sys/kernel/cap_last_cap', 'r') as f:
        last = int(f.readline())
except IOError as e:
    print "Error opening /proc/sys/kernel/cap_last_cap: {0}".format(e.strerror)

print("Doing basic bit tests...")
capng.capng_clear(capng.CAPNG_SELECT_BOTH)
if capng.capng_have_capabilities(capng.CAPNG_SELECT_BOTH) != capng.CAPNG_NONE:
    print("Failed clearing capabilities\n")
    sys.exit(1)

capng.capng_fill(capng.CAPNG_SELECT_BOTH)
if capng.capng_have_capabilities(capng.CAPNG_SELECT_BOTH) != capng.CAPNG_FULL:
    print("Failed filling capabilities")
    sys.exit(1)

text = capng.capng_print_caps_numeric(capng.CAPNG_PRINT_BUFFER,
                                      capng.CAPNG_SELECT_CAPS)
len = len(text)
if len < 80 and last > 30:
    last = 30

print("Doing advanced bit tests for %d capabilities...\n" % (last))
Beispiel #3
0
load_path = '../'
if False:
    sys.path.insert(0, load_path)

import capng

last = capng.CAP_LAST_CAP
try:
	with open('/proc/sys/kernel/cap_last_cap', 'r') as f:
		last = int(f.readline())
except IOError as e:
	print "Error opening /proc/sys/kernel/cap_last_cap: {0}".format(e.strerror)

print("Doing basic bit tests...")
capng.capng_clear(capng.CAPNG_SELECT_BOTH)
if capng.capng_have_capabilities(capng.CAPNG_SELECT_BOTH) != capng.CAPNG_NONE:
	print("Failed clearing capabilities\n")
	sys.exit(1)

capng.capng_fill(capng.CAPNG_SELECT_BOTH)
if capng.capng_have_capabilities(capng.CAPNG_SELECT_BOTH) != capng.CAPNG_FULL:
	print("Failed filling capabilities")
	sys.exit(1)

text = capng.capng_print_caps_numeric(capng.CAPNG_PRINT_BUFFER, capng.CAPNG_SELECT_CAPS)
len = len(text)
if len < 80 and last > 30:
	last = 30

print("Doing advanced bit tests for %d capabilities...\n" % (last))
for i in range(last+1):