Created
June 10, 2014 22:40
-
-
Save pudquick/b1188a35a47c314e42b6 to your computer and use it in GitHub Desktop.
Check Security context flags
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
from ctypes import CDLL, byref, c_uint32 | |
Security = CDLL('/System/Library/Frameworks/Security.framework/Versions/Current/Security') | |
kcallerSecuritySession = c_uint32(-1) | |
my_session = c_uint32(0) | |
session_bits = c_uint32(0) | |
result = Security.SessionGetInfo(kcallerSecuritySession, byref(my_session), byref(session_bits)) | |
flags = session_bits.value | |
print "sessionIsRoot:", bool(flags & 0x0001) | |
print "sessionHasGraphicAccess:", bool(flags & 0x0010) | |
print "sessionHasTTY:", bool(flags & 0x0020) | |
print "sessionIsRemote:", bool(flags & 0x1000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment