Adds SetUserPassword plugin

Password management needs to be separated from the CreateUserPlugin.
This commit is contained in:
Alessandro Pilotti
2013-05-02 02:59:03 +03:00
parent 3e120de02a
commit af4e772137
5 changed files with 36 additions and 85 deletions

View File

@@ -14,6 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import base64
import os
import subprocess
@@ -24,6 +26,12 @@ class BaseOSUtils(object):
def user_exists(self, username):
pass
def generate_random_password(self, length):
# On Windows os.urandom() uses CryptGenRandom, which is a
# cryptographically secure pseudorandom number generator
b64_password = base64.b64encode(os.urandom(256))
return b64_password.replace('/', '').replace('+', '')[:length]
def execute_process(self, args, shell=True):
p = subprocess.Popen(args,
stdout=subprocess.PIPE,