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;