]> git.proxmox.com Git - pmg-api.git/commitdiff
PMG/LDAPConfig.pm: new helper lock_config
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 20 Feb 2017 11:13:47 +0000 (12:13 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 20 Feb 2017 11:13:47 +0000 (12:13 +0100)
PMG/LDAPConfig.pm

index e685243bcd63c8c67673563286c0f0dc1c7e5fd3..373f752d84c68c773e99d948d60b5169244bfacd 100644 (file)
@@ -67,7 +67,7 @@ my $defaultData = {
        },
        mailattr => {
            description => "List of mail attribute names.",
-           type => 'string-list',
+           type => 'string', format => 'string-list',
            pattern => '[a-zA-Z0-9]+',
            default => "mail, userPrincipalName, proxyAddresses, othermailbox",
        },
@@ -114,6 +114,17 @@ sub encode_value {
     return $value;
 }
 
+my $lockfile = "/var/lock/pmgldapconfig.lck";
+
+sub lock_config {
+    my ($code, $errmsg) = @_;
+
+    my $p = PVE::Tools::lock_file($lockfile, undef, $code);
+    if (my $err = $@) {
+       $errmsg ? die "$errmsg: $err" : die $err;
+    }
+}
+
 
 __PACKAGE__->register();
 __PACKAGE__->init();