Created
February 3, 2016 04:08
-
-
Save jessepeterson/b1380009b2b2e9e3bd3f to your computer and use it in GitHub Desktop.
Print files that have a specific length ACL text presentation
This file contains hidden or 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
#!/usr/bin/python | |
"""Print files that have a specific length ACL text presentation | |
Used to debug a backup tool that may have been having problems with files | |
with this precise ACL representation. | |
Created by Jesse Peterson on 2/2/16 | |
""" | |
import sys | |
import os | |
from ctypes import * | |
from ctypes.util import find_library | |
libc = cdll.LoadLibrary(find_library('c')) | |
# from <sys/acl.h> | |
ACL_TYPE_EXTENDED = 0x00000100 | |
acl_get_file = libc.acl_get_file | |
acl_get_file.argtypes = [c_char_p, c_int] | |
acl_get_file.restype = c_void_p | |
acl_to_text = libc.acl_to_text | |
# note the second ulong here is actually a pointer, | |
# havn't looked into how to provide a ptr arg yet | |
acl_to_text.argtypes = [c_void_p, c_ulong] | |
acl_to_text.restype = c_char_p | |
acl_free = libc.acl_free | |
acl_free.argtypes = [c_void_p] | |
acl_free.restype = c_int | |
for stdinline in sys.stdin: | |
if stdinline[-1] == '\n': | |
filename = stdinline[:-1] | |
if os.path.exists(filename): | |
acl = acl_get_file(filename, ACL_TYPE_EXTENDED) | |
if acl: | |
textacl = acl_to_text(acl, 0) | |
modded = len(textacl) % 1024 | |
if modded <= 5 or modded >= 1018: | |
print len(textacl), modded, filename | |
acl_free(acl) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment