def test_gpt_version(self): global gpt_data local_path = self.lp.cache_path('gpo_cache') guid = '{31B2F340-016D-11D2-945F-00C04FB984F9}' gpo_path = os.path.join(local_path, policies, guid) old_vers = gpo.gpo_get_sysvol_gpt_version(gpo_path)[1] with open(os.path.join(gpo_path, 'GPT.INI'), 'w') as gpt: gpt.write(gpt_data % 42) self.assertEqual(gpo.gpo_get_sysvol_gpt_version(gpo_path)[1], 42, 'gpo_get_sysvol_gpt_version() did not return the expected version') with open(os.path.join(gpo_path, 'GPT.INI'), 'w') as gpt: gpt.write(gpt_data % old_vers) self.assertEqual(gpo.gpo_get_sysvol_gpt_version(gpo_path)[1], old_vers, 'gpo_get_sysvol_gpt_version() did not return the expected version')
def test_gpt_version(self): global gpt_data local_path = self.lp.get("path", "sysvol") policies = 'addom.samba.example.com/Policies' guid = '{31B2F340-016D-11D2-945F-00C04FB984F9}' gpo_path = os.path.join(local_path, policies, guid) old_vers = gpo.gpo_get_sysvol_gpt_version(gpo_path)[1] with open(os.path.join(gpo_path, 'GPT.INI'), 'w') as gpt: gpt.write(gpt_data % 42) assert gpo.gpo_get_sysvol_gpt_version(gpo_path)[1] == 42, \ 'gpo_get_sysvol_gpt_version() did not return the expected version' with open(os.path.join(gpo_path, 'GPT.INI'), 'w') as gpt: gpt.write(gpt_data % old_vers) assert gpo.gpo_get_sysvol_gpt_version(gpo_path)[1] == old_vers, \ 'gpo_get_sysvol_gpt_version() did not return the expected version'
def gpo_version(lp, path): # gpo.gpo_get_sysvol_gpt_version() reads the GPT.INI from a local file, # read from the gpo client cache. gpt_path = lp.cache_path(os.path.join('gpo_cache', path)) return int(gpo.gpo_get_sysvol_gpt_version(gpt_path)[1])
#!/usr/bin/env python # Copyright Matthieu Patou <*****@*****.**> 2013 import sys sys.path.insert(0, "bin/python") import samba.gpo as gpo #get unix path #Send LDAP Request - Have a place to receive it #Use the information to fill up some structures. Get the info. name_version = gpo.gpo_get_sysvol_gpt_version( "/home/lukem/sambas/gsoc.samba.org/state/sysvol/gsoc.samba.org/Policies/{31B2F340-016D-11D2-945F-00C04FB984F9}" ) print name_version p = ads_parse_gp_ext("string") #Have info, then use that information to fill up a group policy structure, #use that structure to then identify importance #after some basic arithmetic evaluation is done (C wrapper for *importance_to_samba(ADS_STRUCT *ads, GROUP_POLICY_OBJECT *gpo) returns true or false #if it is NOT ignore here, continue next iteration, get the next GPO #if it is important, let us update the samba database, in terms of importance. #The rest will be inotify because it will maybe use the bash $ terminal to just call this script repeatedly