Shell tools TMPDIR may break

Bug #945079 reported by Baron Schwartz
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Toolkit moved to https://jira.percona.com/projects/PT
Fix Released
Low
Brian Fraser

Bug Description

The tmpdir shell library uses the following:

   else
      local tool=`basename $0`
      local pid="$$"
      TMPDIR=`mktemp -d /tmp/${tool}.${pid}.XXXXX` \
         || die "Cannot make secure tmpdir"
   fi

This can break if $0 is "-bash", which I've seen. In this case basename will complain because of an unknown option -b. It could also happen if $0 is something like "/path/to/directory -withspace/pt-toolname"

In addition, I wonder if we should use $TEMP instead of hard-coding /tmp/. On my Mac, for example, $TEMP is not set to /tmp/. If $TEMP isn't set for some reason, we could fall back to /tmp/ as a default.

Related branches

Changed in percona-toolkit:
status: Confirmed → In Progress
assignee: nobody → Brian Fraser (fraserbn)
milestone: none → 2.1.2
tags: added: shell-tools sys-cmd
summary: - tmpdir library has potential bugs
+ Shell tools TMPDIR may break
Changed in percona-toolkit:
status: In Progress → Fix Committed
Changed in percona-toolkit:
status: Fix Committed → Fix Released
Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PT-769

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.