def testKnownValues(self):
        """lmhash(...) gives known results"""
        cfg = config.loadConfig()
        for password, expected_result in self.knownValues:
            cfg.set('samba', 'use-lmhash', 'no')
            disabled = smbpassword.lmhash(password)
            self.assertEquals(disabled, 32 * 'X',
                              "Disabled lmhash must be X's: %r" % disabled)

            cfg.set('samba', 'use-lmhash', 'yes')
            result = smbpassword.lmhash(password)
            if result != expected_result:
                raise AssertionError, 'lmhash(%s)=%s, expected %s' \
                      % (repr(password), repr(result), repr(expected_result))
Beispiel #2
0
    def testKnownValues(self):
        """lmhash(...) gives known results"""
        cfg = config.loadConfig()
        for password, expected in self.knownValues:
            cfg.set('samba', 'use-lmhash', 'no')
            disabled = smbpassword.lmhash(password)
            self.assertEqual(disabled, 32 * 'X',
                             "Disabled lmhash must be X's: %r" % disabled)

            cfg.set('samba', 'use-lmhash', 'yes')

            result = smbpassword.lmhash(password)

            self.assertEqual(expected, result)
    def setPassword_Samba(self, newPasswd, style=None):
        """

        Set the Samba password on this object.

        @param newPasswd: A string containing the new password.

        @param style: one of 'sambaSamAccount', 'sambaAccount' or
        None. Specifies the style of samba accounts used. None is
        default and is the same as 'sambaSamAccount'.

        @return: A Deferred that will complete when the operation is
        done.

        """

        self._checkState()

        nthash = smbpassword.nthash(newPasswd)
        lmhash = smbpassword.lmhash(newPasswd)

        if style is None:
            style = 'sambaSamAccount'
        if style == 'sambaSamAccount':
            self['sambaNTPassword'] = [nthash]
            self['sambaLMPassword'] = [lmhash]
        elif style == 'sambaAccount':
            self['ntPassword'] = [nthash]
            self['lmPassword'] = [lmhash]
        else:
            raise RuntimeError("Unknown samba password style %r" % style)
        return self.commit()
Beispiel #4
0
    def setPassword_Samba(self, newPasswd, style=None):
        """

        Set the Samba password on this object.

        @param newPasswd: A string containing the new password.

        @param style: one of 'sambaSamAccount', 'sambaAccount' or
        None. Specifies the style of samba accounts used. None is
        default and is the same as 'sambaSamAccount'.

        @return: A Deferred that will complete when the operation is
        done.

        """

        self._checkState()

        nthash=smbpassword.nthash(newPasswd)
        lmhash=smbpassword.lmhash(newPasswd)

        if style is None:
            style = 'sambaSamAccount'
        if style == 'sambaSamAccount':
            self['sambaNTPassword'] = [nthash]
            self['sambaLMPassword'] = [lmhash]
        elif style == 'sambaAccount':
            self['ntPassword'] = [nthash]
            self['lmPassword'] = [lmhash]
        else:
            raise RuntimeError, "Unknown samba password style %r" % style
        return self.commit()
Beispiel #5
0
    def testKnownValues(self):
        """lmhash(...) gives known results"""
        cfg = config.loadConfig()
        for password, expected_result in self.knownValues:
            cfg.set("samba", "use-lmhash", "no")
            disabled = smbpassword.lmhash(password)
            self.assertEquals(disabled, 32 * "X", "Disabled lmhash must be X's: %r" % disabled)

            cfg.set("samba", "use-lmhash", "yes")
            result = smbpassword.lmhash(password)
            if result != expected_result:
                raise AssertionError, "lmhash(%s)=%s, expected %s" % (
                    repr(password),
                    repr(result),
                    repr(expected_result),
                )
 def testKnownValues(self):
     """
     When lanman password are enabled in the configuration, they will
     return
     """
     cfg = config.loadConfig()
     cfg.set('samba', 'use-lmhash', 'yes')
     self.assertEqual(self.knownValues, [(p, smbpassword.lmhash(p))
                                         for p, _ in self.knownValues])
    def testLMHashConfiguationDisabled(self):
        """
        When the lanman passwords are disabled from the configuration, it will
        return the disabled password.
        """
        cfg = config.loadConfig()
        cfg.set('samba', 'use-lmhash', 'no')

        result = smbpassword.lmhash(b'any-pass')

        self.assertEqual(32 * b'X', result)
    def testLMHashConfiguationDisabled(self):
        """
        When the lanman passwords are disabled from the configuration, it will
        return the disabled password.
        """
        cfg = config.loadConfig()
        cfg.set('samba', 'use-lmhash', 'no')

        result = smbpassword.lmhash(b'any-pass')

        self.assertEqual(32 * b'X', result)
Beispiel #9
0
    def testLMHashConfiguationDisabled(self):
        """
        When the lanman passwords are disabled from the configuration, it will
        return the disabled password.
        """
        cfg = config.loadConfig()
        cfg.set("samba", "use-lmhash", "no")

        result = smbpassword.lmhash(b"any-pass")

        self.assertEqual(32 * b"X", result)
Beispiel #10
0
 def testKnownValues(self):
     """
     When lanman password are enabled in the configuration, they will
     return
     """
     cfg = config.loadConfig()
     cfg.set('samba', 'use-lmhash', 'yes')
     self.assertEqual(
         self.knownValues,
         [(p, smbpassword.lmhash(p)) for p, _ in self.knownValues]
     )
Beispiel #11
0
    def testKnownValues(self):
        """
        When lanman password are enabled in the configuration, they will
        return
        """
        cfg = config.loadConfig()
        cfg.set('samba', 'use-lmhash', 'yes')
        for password, expected in self.knownValues:

            result = smbpassword.lmhash(password)

            self.assertEqual(expected, result)
Beispiel #12
0
    def testKnownValues(self):
        """
        When lanman password are enabled in the configuration, they will
        return
        """
        cfg = config.loadConfig()
        cfg.set('samba', 'use-lmhash', 'yes')
        for password, expected in self.knownValues:

            result = smbpassword.lmhash(password)

            self.assertEqual(expected, result)