Beispiel #1
0
    def set_user_passwd(self, userid, passwd):
        """ Sets password for uerid. This method will guess whether
        the password is already md5 hashed or not (in which case it
        will hash it) """

        print 'Setting password for %s' % userid

        if passwd[0:3] == '$1$' and len(passwd) > 30:
            # this is a password hash (most likely)
            pass
        else:
            passwd = util.hash_passwd(passwd, md5=1)

        cmd = "%s %s /usr/sbin/usermod -p '%s' %s" % \
              (cfg.CHROOT, self.vpsroot, passwd, userid)
        s = commands.getoutput(cmd)
Beispiel #2
0
    def set_user_passwd(self, userid, passwd):
        """ Sets password for uerid. This method will guess whether
        the password is already md5 hashed or not (in which case it
        will hash it) """

        print 'Setting password for %s' % userid

        if passwd[0:3] == '$1$' and len(passwd) > 30:
            # this is a password hash (most likely)
            pass
        else:
            passwd = util.hash_passwd(passwd, md5=1)

        cmd = "%s %s /usr/sbin/usermod -p '%s' %s" % \
              (cfg.CHROOT, self.vpsroot, passwd, userid)
        s = commands.getoutput(cmd)
Beispiel #3
0
    def add_user(self, userid, passwd):
        """ Add a user. This method will guess whether
        the password is already md5 hashed or not (in which
        case it will hash it) """

        print 'Adding user %s' % userid

        comment = 'User %s' % userid

        if passwd[0:3] == '$1$' and len(passwd) > 30:
            # this is a password hash (most likely)
            pass
        else:
            passwd = util.hash_passwd(passwd, md5=1)

        cmd = "%s %s /usr/sbin/adduser -c '%s' -G wheel -p '%s' %s" % \
              (cfg.CHROOT, self.vpsroot, comment, passwd, userid)
        s = commands.getoutput(cmd)
Beispiel #4
0
    def add_user(self, userid, passwd):
        """ Add a user. This method will guess whether
        the password is already md5 hashed or not (in which
        case it will hash it) """

        print 'Adding user %s' % userid

        comment = 'User %s' % userid

        if passwd[0:3] == '$1$' and len(passwd) > 30:
            # this is a password hash (most likely)
            pass
        else:
            passwd = util.hash_passwd(passwd, md5=1)

        cmd = "%s %s /usr/sbin/adduser -c '%s' -G wheel -p '%s' %s" % \
              (cfg.CHROOT, self.vpsroot, comment, passwd, userid)
        s = commands.getoutput(cmd)