From: jmarcus Date: Thu, 7 Feb 2002 21:45:07 +0000 (+0000) Subject: Automatically detect the temp directory. The tmpdir() code is taken from X-Git-Tag: point-backport-1-5-2~54 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=9c835ad611782e65d81afabd27fca5205da57e47;hp=e0acbbcf3dbe1951f520aa327e7912f8830cd5e7 Automatically detect the temp directory. The tmpdir() code is taken from File::Spec, and brought to my attention by MacMan One . --- diff --git a/bin/cnid/cnid_maint.in b/bin/cnid/cnid_maint.in index 2a84f758..8ace02b4 100755 --- a/bin/cnid/cnid_maint.in +++ b/bin/cnid/cnid_maint.in @@ -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 ) = @_;