Пример #1
0
    def set(self,value):
        """
        Encrypt passwords
        """
        reCheck = re.compile("^\$[^$]+\$[^$]+\$.*$")
        encryptObj = encrypt()

        return map(lambda x:x if reCheck.match(x) or not x else \
                         encryptObj.getHashPasswd(x, "shadow_ssha256"),
               value)
Пример #2
0
    def set(self,value):
        """
        Encrypt password
        """
        reCheck = re.compile("^\$[^$]+\$[^$]+\$.*$")
        encryptObj = encrypt()

        if reCheck.match(value) or not value:
            return value
        else:
            return encryptObj.getHashPasswd(value, "shadow_ssha256")
Пример #3
0
 def createUserGuest(self):
     if filter(lambda x: int(x[2])>=self.minSysId, self.dataUsers):
         return True
     else:
         # add user guest
         pwd = "guest"
         encryptObj = encrypt()
         pwdHash = encryptObj.getHashPasswd(pwd, "shadow_ssha256")
         if pwdHash is False:
             return False
         if not self.addUser("guest", pwdHash):
             return False
         return True
Пример #4
0
 def addUsers(self,*users_passwd):
     """Added users and groups to current system"""
     if not self.checkPermFiles():
         return False
     getDataInFile = _shareData().getDataInFile
     self.dataUsers = getDataInFile(fileName=migrateUsers.filePasswd,
                                    lenData=7)
     self.dataGroups = getDataInFile(fileName=migrateGroups.fileGroups,
                                     lenData=4)
     self.dataShadow = getDataInFile(fileName=migrateShadow.fileShadow,
                                     lenData=9)
     getHash = encrypt().getHashPasswd
     for userName, pwd in zip(users_passwd[0::2],
                              users_passwd[1::2]):
         pwdHash = getHash(pwd,"shadow_ssha256")
         if not self.addUser(userName, pwdHash):
             return False
     self.saveNewFiles()
     return True