本文整理汇总了Python中GLIUtility.hash_password方法的典型用法代码示例。如果您正苦于以下问题:Python GLIUtility.hash_password方法的具体用法?Python GLIUtility.hash_password怎么用?Python GLIUtility.hash_password使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLIUtility
的用法示例。
在下文中一共展示了GLIUtility.hash_password方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_treeview_data
# 需要导入模块: import GLIUtility [as 别名]
# 或者: from GLIUtility import hash_password [as 别名]
def get_treeview_data(self):
data = []
treeiter = self.treedata.get_iter_first()
while treeiter !=None:
user = self.treedata.get_value(treeiter,1)
passwd = self.treedata.get_value(treeiter,0)
# if the user was loaded from a profile, do NOT
# hash the password, but carry it through
if user not in self.users_from_profile:
pass_hash = GLIUtility.hash_password(passwd)
else:
pass_hash = passwd
groups = self.treedata.get_value(treeiter,2)
shell = self.treedata.get_value(treeiter,3)
homedir = self.treedata.get_value(treeiter,4)
userid = self.treedata.get_value(treeiter,5)
comment = self.treedata.get_value(treeiter,6)
try:
group_tuple = tuple(groups.split(","))
except:
# must be only 1 group
group_tuple = (groups)
data.append([user,pass_hash,group_tuple,shell,homedir,userid,comment])
treeiter = self.treedata.iter_next(treeiter)
return data
示例2: deactivate
# 需要导入模块: import GLIUtility [as 别名]
# 或者: from GLIUtility import hash_password [as 别名]
def deactivate(self):
# store everything
if (self.root_verified):
if self.is_root_pass_set():
# don't hash the password, just store it
root_hash = self.root1.get_text()
else:
# hash the password
root_hash = GLIUtility.hash_password(self.root1.get_text())
# store the root password
self.controller.install_profile.set_root_pass_hash(None,root_hash,None)
# now store all the entered users
#( <user name>, <password hash>, (<tuple of groups>), <shell>,
# <home directory>, <user id>, <user comment> )
# retrieve everything
data = self.get_treeview_data()
stored_users = []
# get the array of stored usernames
for item in list(self.controller.install_profile.get_users()):
stored_users.append(item[0])
for user in data:
if user[0] not in self.current_users and user[0] not in stored_users:
# user is not in stored profile, and hasn't been previously added
self.controller.install_profile.add_user(None, (user[0], user[1], user[2], user[3], user[4], user[5], user[6]), None)
#self.current_users.append(user[0])
elif user[0] in stored_users:
# user is in stored profile, need to remove, then readd the user
self.controller.install_profile.remove_user(user[0])
self.controller.install_profile.add_user(None, (user[0], user[1], user[2], user[3], user[4], user[5], user[6]), None)
#self.current_users.append(user[0])
return True
else:
msgbox=Widgets().error_Box("Error","You have not verified your root password!")
msgbox.run()
msgbox.destroy()