1*19c3b8c2SApple OSS Distributions""" Please make sure you read the README file COMPLETELY BEFORE reading anything below. 2*19c3b8c2SApple OSS Distributions It is very critical that you read coding guidelines in Section E in README file. 3*19c3b8c2SApple OSS Distributions""" 4*19c3b8c2SApple OSS Distributionsfrom __future__ import absolute_import, print_function 5*19c3b8c2SApple OSS Distributions 6*19c3b8c2SApple OSS Distributionsfrom builtins import range 7*19c3b8c2SApple OSS Distributions 8*19c3b8c2SApple OSS Distributionsfrom xnu import * 9*19c3b8c2SApple OSS Distributionsfrom utils import * 10*19c3b8c2SApple OSS Distributions 11*19c3b8c2SApple OSS Distributions# Macro: walkkauthcache 12*19c3b8c2SApple OSS Distributions@lldb_command('walkkauthcache') 13*19c3b8c2SApple OSS Distributionsdef WalkKauthCache(cmd_args=None): 14*19c3b8c2SApple OSS Distributions """ Walks the bins of the kauth credential hash cache and prints out the 15*19c3b8c2SApple OSS Distributions number of bins and bin usage information. 16*19c3b8c2SApple OSS Distributions """ 17*19c3b8c2SApple OSS Distributions PrintKauthCache() 18*19c3b8c2SApple OSS Distributions# EndMacro: walkkauthcache 19*19c3b8c2SApple OSS Distributions 20*19c3b8c2SApple OSS Distributionsdef PrintKauthCache(cmd_args=None): 21*19c3b8c2SApple OSS Distributions """ Routine to determine the size of the kauth cache, walk the bins 22*19c3b8c2SApple OSS Distributions and print out usage information. 23*19c3b8c2SApple OSS Distributions """ 24*19c3b8c2SApple OSS Distributions anchor = unsigned(kern.globals.kauth_cred_table_anchor) 25*19c3b8c2SApple OSS Distributions table_entries = 128 # KAUTH_CRED_TABLE_SIZE 26*19c3b8c2SApple OSS Distributions anchor = kern.globals.kauth_cred_table_anchor 27*19c3b8c2SApple OSS Distributions print("Cred cache has: " + str(table_entries) + " buckets\n") 28*19c3b8c2SApple OSS Distributions print("Number of items in each bucket ... \n") 29*19c3b8c2SApple OSS Distributions for i in range(0, table_entries): 30*19c3b8c2SApple OSS Distributions numinbucket = 0 31*19c3b8c2SApple OSS Distributions for kauth_cred in IterateListEntry(anchor[i], 'struct ucred_rw *', "crw_link"): 32*19c3b8c2SApple OSS Distributions numinbucket += 1 33*19c3b8c2SApple OSS Distributions #print str(kauth_cred.cr_posix) 34*19c3b8c2SApple OSS Distributions #print str(kauth_cred.cr_ref) 35*19c3b8c2SApple OSS Distributions print(str(numinbucket) + "\n") 36