use base 'Exporter';
use URI::Escape;
use Encode;
+use Digest::SHA1;
our @EXPORT_OK = qw(
lock_file
my $orig_pid = $$;
eval {
- local $ENV{LANG} = $lang;
+ local $ENV{LC_ALL} = $lang;
# suppress LVM warnings like: "File descriptor 3 left open";
local $ENV{LVM_SUPPRESS_FD_WARNINGS} = "1";
return Encode::decode("utf8", uri_unescape($data));
}
+sub random_ether_addr {
+
+ my $rand = Digest::SHA1::sha1_hex(rand(), time());
+
+ my $mac = '';
+ for (my $i = 0; $i < 6; $i++) {
+ my $ss = hex(substr($rand, $i*2, 2));
+ if (!$i) {
+ $ss &= 0xfe; # clear multicast
+ $ss |= 2; # set local id
+ }
+ $ss = sprintf("%02X", $ss);
+
+ if (!$i) {
+ $mac .= "$ss";
+ } else {
+ $mac .= ":$ss";
+ }
+ }
+
+ return $mac;
+}
1;