]> arthur.barton.de Git - netatalk.git/commitdiff
Automatically detect the temp directory. The tmpdir() code is taken from
authorjmarcus <jmarcus>
Thu, 7 Feb 2002 21:45:07 +0000 (21:45 +0000)
committerjmarcus <jmarcus>
Thu, 7 Feb 2002 21:45:07 +0000 (21:45 +0000)
File::Spec, and brought to my attention by MacMan One <power2themacs@yahoo.com>.

bin/cnid/cnid_maint.in

index 2a84f75840a80cef25867bb0c11dc543d8a32d8b..8ace02b486c907a272e5540e026fe7d8922c5bda 100755 (executable)
@@ -3,7 +3,7 @@
 #
 # cnid_maint: A script to maintain the consistency of CNID databases.
 #
-# $Id: cnid_maint.in,v 1.3 2002-02-07 16:10:29 jmarcus Exp $
+# $Id: cnid_maint.in,v 1.4 2002-02-07 21:45:07 jmarcus Exp $
 #
 
 use strict;
@@ -41,7 +41,7 @@ $APPLE_VOLUMES_FILE = '@PKGCONFDIR@/AppleVolumes.default';
 $VERSION = '1.0';
 $GREP           = '@GREP@';
 $START_NETATALK = 0;
-$LOCK_FILE      = '/tmp/cnid_maint.LOCK';
+$LOCK_FILE      = tmpdir() . 'cnid_maint.LOCK';
 $HOLDING_LOCK   = 0;
 
 sub LOCK_SH { 1 }
@@ -257,6 +257,18 @@ foreach $path (@paths) {
 
 end();
 
+sub tmpdir {
+    my $tmpdir;
+
+    foreach ( $ENV{TMPDIR}, "/tmp" ) {
+        next unless defined && -d && -w _;
+        $tmpdir = $_;
+        last;
+    }
+    $tmpdir = '' unless defined $tmpdir;
+    return $tmpdir;
+}
+
 sub error {
     my ( $code, $msg ) = @_;