def sync(self): found_names = [] users = self.__search() for u in users: username = u[1]['sAMAccountName'][0] found_names.append(username) if not username in ajenti.config.tree.users: u = UserData() u.name = username ajenti.config.tree.users[username] = u for user in list(ajenti.config.tree.users.values()): if not user.name in found_names and user.name != 'root': ajenti.config.tree.users.pop(user.name) ajenti.config.save()
def init(self): self.title = 'Configure' self.icon = 'wrench' self.category = '' self.order = 50 self.append(self.ui.inflate('configurator:main')) self.binder = Binder(ajenti.config.tree, self.find('ajenti-config')) self.ccmgr = ClassConfigManager.get() self.classconfig_binding = Binder(self.ccmgr, self.find('classconfigs')) self.classconfig_rows = {} def post_classconfig_bind(object, collection, item, ui): self.classconfig_rows[item] = ui editor = item.classconfig_editor.new(self.ui) ui.find('container').append(editor) binder = DictAutoBinding(item, 'classconfig', editor.find('bind')) binder.populate() def save(): binder.update() item.save_classconfig() self.context.notify('info', 'Saved') ui.find('save').on('click', save) self.find('classconfigs').find( 'classes').post_item_bind = post_classconfig_bind self.find('users').new_item = lambda c: UserData() def post_user_bind(object, collection, item, ui): box = ui.find('permissions') box.empty() for prov in PermissionProvider.get_all(): line = self.ui.create('tab', title=prov.get_name()) box.append(line) for perm in prov.get_permissions(): line.append(self.ui.create('checkbox', id=perm[0], text=perm[1], \ value=(perm[0] in item.permissions))) self.find('users').post_item_bind = post_user_bind def post_user_update(object, collection, item, ui): box = ui.find('permissions') for prov in PermissionProvider.get_all(): for perm in prov.get_permissions(): has = box.find(perm[0]).value if has and not perm[0] in item.permissions: item.permissions.append(perm[0]) if not has and perm[0] in item.permissions: item.permissions.remove(perm[0]) self.find('users').post_item_update = post_user_update self.refresh()
def sync(self): found_names = [] for l in open('/etc/shadow').read().splitlines(): l = l.split(':') if len(l) >= 2: username, pwd = l[:2] if len(pwd) > 2: found_names.append(username) if not username in ajenti.config.tree.users: u = UserData() u.name = username ajenti.config.tree.users[username] = u for user in list(ajenti.config.tree.users.values()): if not user.name in found_names and user.name != 'root': ajenti.config.tree.users.pop(user.name) ajenti.config.save()
def sync(self): found_names = [] for l in subprocess.check_output(['passwd', '-Sa']).splitlines(): l = l.split() if len(l) >= 2: username, state = l[:2] if state == 'P': found_names.append(username) if not username in ajenti.config.tree.users: u = UserData() u.name = username ajenti.config.tree.users[username] = u for user in list(ajenti.config.tree.users.values()): if not user.name in found_names and user.name != 'root': ajenti.config.tree.users.pop(user.name) ajenti.config.save()
def sync(self): found_names = [] l = self.__get_ldap() users = l.search_s( self.classconfig['auth_dn'], ldap.SCOPE_SUBTREE, '(|(objectClass=user)(objectClass=simpleSecurityObject))', ['cn']) for u in users: username = u[1]['cn'][0] found_names.append(username) if not username in ajenti.config.tree.users: u = UserData() u.name = username ajenti.config.tree.users[username] = u for user in list(ajenti.config.tree.users.values()): if not user.name in found_names and user.name != 'root': ajenti.config.tree.users.pop(user.name) ajenti.config.save()
def sync(self): found_names = [] l = self.__get_ldap() users = l.search_s( self.classconfig['auth_dn'], ldap.SCOPE_SUBTREE, '(|(objectClass=user)(objectClass=simpleSecurityObject))', ['cn'] ) for u in users: username = u[1]['cn'][0] found_names.append(username) if not username in ajenti.config.tree.users: u = UserData() u.name = username ajenti.config.tree.users[username] = u for user in list(ajenti.config.tree.users.values()): if not user.name in found_names and user.name != 'root': ajenti.config.tree.users.pop(user.name) ajenti.config.save()
def init(self): self.title = _('Configure') self.icon = 'wrench' self.category = '' self.order = 50 self.append(self.ui.inflate('configurator:main')) self.binder = Binder(ajenti.config.tree, self.find('ajenti-config')) self.ccmgr = ClassConfigManager.get() self.classconfig_binding = Binder(self.ccmgr, self.find('classconfigs')) def post_classconfig_bind(object, collection, item, ui): def configure(): self.configure_plugin(item, notify=False) ui.find('configure').on('click', configure) self.find('classconfigs').find('classes').post_item_bind = post_classconfig_bind self.find('users').new_item = lambda c: UserData() def post_user_bind(object, collection, item, ui): box = ui.find('permissions') box.empty() ui.find('name-edit').visible = item.name != 'root' ui.find('name-label').visible = item.name == 'root' for prov in PermissionProvider.get_all(): line = self.ui.create('tab', title=prov.get_name()) box.append(line) for perm in prov.get_permissions(): line.append( self.ui.create('checkbox', id=perm[0], text=perm[1], value=(perm[0] in item.permissions)) ) self.find('users').post_item_bind = post_user_bind def post_user_update(object, collection, item, ui): box = ui.find('permissions') for prov in PermissionProvider.get_all(): for perm in prov.get_permissions(): has = box.find(perm[0]).value if has and not perm[0] in item.permissions: item.permissions.append(perm[0]) if not has and perm[0] in item.permissions: item.permissions.remove(perm[0]) if ui.find('password').value: item.password = ui.find('password').value self.find('users').post_item_update = post_user_update
def init(self): self.title = _('Configure') self.icon = 'wrench' self.category = '' self.order = 50 self.append(self.ui.inflate('configurator:main')) self.binder = Binder(ajenti.config.tree, self.find('ajenti-config')) self.ccmgr = ClassConfigManager.get() if Licensing.licensing_active: self.find('licensing').append(LicensingUI.new(self.ui)) else: self.find('licensing').delete() self.classconfig_binding = Binder(self.ccmgr, self.find('classconfigs')) def post_classconfig_bind(object, collection, item, ui): def configure(): self.configure_plugin(item, notify=False) ui.find('configure').on('click', configure) self.find('classconfigs').find('classes') \ .post_item_bind = post_classconfig_bind self.find('users').new_item = lambda c: UserData() def post_user_bind(object, collection, item, ui): provider = UserManager.get().get_sync_provider() editable = item.name != 'root' renameable = editable and provider.allows_renaming deletable = renameable ui.find('name-edit').visible = renameable ui.find('name-label').visible = not renameable ui.find('delete').visible = deletable box = ui.find('permissions') box.empty() p = PermissionProvider.get_all() for prov in p: line = self.ui.create('tab', title=prov.get_name()) box.append(line) for perm in prov.get_permissions(): line.append( self.ui.create('checkbox', id=perm[0], text=perm[1], value=(perm[0] in item.permissions))) def copy(): self.save() newuser = deepcopy(item) newuser.name += '_' collection[newuser.name] = newuser self.refresh() ui.find('copy').on('click', copy) self.find('users').post_item_bind = post_user_bind def post_user_update(object, collection, item, ui): box = ui.find('permissions') for prov in PermissionProvider.get_all(): for perm in prov.get_permissions(): has = box.find(perm[0]).value if has and not perm[0] in item.permissions: item.permissions.append(perm[0]) if not has and perm[0] in item.permissions: item.permissions.remove(perm[0]) if ui.find('password').value: item.password = ui.find('password').value self.find('users').post_item_update = post_user_update