-
Notifications
You must be signed in to change notification settings - Fork 930
Fix non-unique /tmp filenames in external library download scripts #3182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix non-unique /tmp filenames in external library download scripts #3182
Conversation
Resolves issue where multiple users compiling tflite-micro simultaneously would encounter permission conflicts due to fixed temporary filenames. Changes: - Create unique temporary directories using username, PID, and timestamp - Implement automatic cleanup on all exit conditions Scripts modified: - tensorflow/lite/micro/tools/make/ext_libs/cmsis_download.sh - tensorflow/lite/micro/tools/make/ext_libs/cmsis_nn_download.sh - tensorflow/lite/micro/tools/make/ext_libs/eyalroz_printf_download.sh Fixes tensorflow#3042
Please add the following line to your PR description: |
# Create unique temporary directory name with username for better isolation | ||
USERNAME=$(whoami 2>/dev/null || echo "unknown") | ||
TEMP_DIR="/tmp/cmsis_dld_${USERNAME}_$(date +%s)_$$" | ||
if ! mkdir -p "${TEMP_DIR}"; then | ||
echo "ERROR: Failed to create temporary directory ${TEMP_DIR}" >&2 | ||
exit 1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest something more akin to the following:
TEMP_DIR=$(mktemp -d /tmp/$(basename $0 .sh).XXXXXX)
# Create unique temporary directory name with username for better isolation | ||
USERNAME=$(whoami 2>/dev/null || echo "unknown") | ||
TEMP_DIR="/tmp/cmsis_nn_dld_${USERNAME}_$(date +%s)_$$" | ||
if ! mkdir -p "${TEMP_DIR}"; then | ||
echo "ERROR: Failed to create temporary directory ${TEMP_DIR}" >&2 | ||
exit 1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per previous comment.
# Create unique temporary directory name with username for better isolation | ||
USERNAME=$(whoami 2>/dev/null || echo "unknown") | ||
TEMP_DIR="/tmp/eyalroz_dld_${USERNAME}_$(date +%s)_$$" | ||
if ! mkdir -p "${TEMP_DIR}"; then | ||
echo "ERROR: Failed to create temporary directory ${TEMP_DIR}" >&2 | ||
exit 1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per previous comment.
@ilya-kupchenko Thank you for your interest in TFLM. It is greatly appreciated that you have submitted a PR for this issue. |
Description:
Fixes #3042
Problem
Multiple users or processes compiling tflite-micro simultaneously encounter permission conflicts due to fixed temporary filenames in
/tmp
.Solution
Files Modified
Testing
Tested with multiple concurrent users - no more /tmp conflicts.