Skip to content

Use TMPDIR when downloading state - #202

Open
Hellzy wants to merge 1 commit into
dusk-network:mainfrom
Hellzy:download_stake_TMPDIR
Open

Use TMPDIR when downloading state#202
Hellzy wants to merge 1 commit into
dusk-network:mainfrom
Hellzy:download_stake_TMPDIR

Conversation

@Hellzy

@Hellzy Hellzy commented Jul 22, 2026

Copy link
Copy Markdown

This is a small QOL update to the bin/download_state.sh script.

Change

Use TMPDIR (default to /tmp if not set) to get rid of hardcoded /tmp path when invoking mktemp

Motivation

Some users may have a tmpfs located somewhere else, or too small to accommodate for the state file, in which case being able to relocate the download folder is handy to avoid jumping through hoops to update the node state.

Related issue: #201

@Neotamandua

Copy link
Copy Markdown
Member

I suggest using an explicit --tmpdir DIR option instead of inheriting TMPDIR.

That solves:

  1. TMPDIR being stripped by sudo, so the current change may silently fall back to /tmp.
  2. This script runs as root, so accepting an arbitrary temp directory from the environment introduces a pathname-race risk if that directory or one of its parents is writable by an unprivileged user.

So having something like:
sudo download_state --tmpdir /mnt/dusk-tmp

& then validate that the resolved directory and its parents are root-owned (and reject group/world-writable directories unless they have protections like /tmp that prevent other users from replacing files).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants