From 55704f6c8d8385273363edce92c469d0218f7dad Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Thu, 18 Mar 2010 14:02:12 +0000 Subject: [PATCH] -Provide missing password generation function git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@5519 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/dns.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/dns.pm b/xCAT-server/lib/xcat/plugins/dns.pm index 8dbc4630d..f55ea67f7 100644 --- a/xCAT-server/lib/xcat/plugins/dns.pm +++ b/xCAT-server/lib/xcat/plugins/dns.pm @@ -615,4 +615,19 @@ sub sendmsg { # waitforack($outfd); $callback->($msg); } +sub genpassword +{ + + #Generate a pseudo-random password of specified length + my $length = shift; + my $password = ''; + my $characters = + 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890'; + srand; #have to reseed, rand is not rand otherwise + while (length($password) < $length) + { + $password .= substr($characters, int(rand 63), 1); + } + return $password; +} 1;