diff options
author | Mathieu Parent <math.parent@gmail.com> | 2008-11-26 22:26:44 (GMT) |
---|---|---|
committer | Mathieu Parent <math.parent@gmail.com> | 2008-11-26 22:26:44 (GMT) |
commit | a7e5aa9f8cade88465bfb6470212df0ff4a1d02a (patch) | |
tree | b66d1eea7b74844e350e0e976ee5ae3c0af74887 | |
parent | 2fd88adc88e36dafb4c08f9df13b74d0f298d2a0 (diff) | |
download | perl-Kolab-a7e5aa9f8cade88465bfb6470212df0ff4a1d02a.tar.gz |
- defaults syncrepl_cookie_file to '/tmp/kolab_syncrepl_cookie_file'
- create if it doesn't exists
-rw-r--r-- | lib/Kolab/LDAP/Backend/syncrepl.pm | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/Kolab/LDAP/Backend/syncrepl.pm b/lib/Kolab/LDAP/Backend/syncrepl.pm index 0e38bb9..b4d1e27 100644 --- a/lib/Kolab/LDAP/Backend/syncrepl.pm +++ b/lib/Kolab/LDAP/Backend/syncrepl.pm @@ -60,10 +60,11 @@ sub mode { # giving an argument means: set sub cookie { my($cookie) = @_; + my $syncrepl_cookie_file = $Kolab::config{'syncrepl_cookie_file'} || '/tmp/kolab_syncrepl_cookie_file'; if(defined($cookie)) { - if(!open(COOKIE_FILE, '>', $Kolab::config{'syncrepl_cookie_file'})) { - Kolab::log("SYNCREPL', 'Cannot open file `".$Kolab::config{'syncrepl_cookie_file'}. - "' for writing", KOLAB_DEBUG); + if(!open(COOKIE_FILE, '>', $syncrepl_cookie_file)) { + Kolab::log("SYNCREPL', 'Cannot open file `".$syncrepl_cookie_file. + "' for writing: $!", KOLAB_DEBUG); &abort; } Kolab::log("SYNCREPL', 'Writing cookie to file: ".$cookie, KOLAB_DEBUG); @@ -71,9 +72,14 @@ sub cookie { close(COOKIE_FILE); return $cookie; } else { - if(!open(COOKIE_FILE, '+<', $Kolab::config{'syncrepl_cookie_file'})) { - Kolab::log("SYNCREPL', 'Cannot open file `".$Kolab::config{'syncrepl_cookie_file'}. - "' for reading", KOLAB_DEBUG); + #create if it doesn't exists + if(! -f $syncrepl_cookie_file) { + open COOKIE_FILE, '>', $syncrepl_cookie_file; + close COOKIE_FILE; + } + if(!open(COOKIE_FILE, '+<', $syncrepl_cookie_file)) { + Kolab::log("SYNCREPL', 'Cannot open file `".$syncrepl_cookie_file. + "' for reading: $!", KOLAB_DEBUG); &abort; } read COOKIE_FILE, $cookie, 1024, 0; |