Skip to content

Commit 3ebb30f

Browse files
committed
Store the log file in $TMPDIR instead of /tmp
Instead of using `/tmp` as the base we now use the value of `$TMPDIR` which is user-scoped. This means that the path of the log file is no longer `/tmp/pinentry-touchid.log` but `$TMPDIR/pinentry-touchid.log`. This is particularly important in multiuser environments where the first user would get ownership of the file and actions from other users would fail. Fixes #13
1 parent 6173b1d commit 3ebb30f

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ Add/attach the relevant section of the log to this issue (feel free to redact yo
4545

4646
**`pinentry-touchid`:**
4747

48-
`pinentry-touchid` also generates its own log which you can find in `/tmp/pinentry-touchid.log`.
48+
`pinentry-touchid` also generates its own log which you can find in `$TMPDIR/pinentry-touchid.log`.

main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ const (
4545
)
4646

4747
var (
48+
// DefaultLogLocation is the location of the log file
49+
DefaultLogLocation = filepath.Join(filepath.Clean(os.TempDir()), DefaultLogFilename)
50+
4851
emailRegex = regexp.MustCompile(`\"(?P<name>.*<(?P<email>.*)>)\"`)
4952
keyIDRegex = regexp.MustCompile(`ID (?P<keyId>.*),`) // keyID should be of exactly 8 or 16 characters
50-
// DefaultLogLocation is the location of the log file
51-
DefaultLogLocation = filepath.Join(filepath.Clean("/tmp"), DefaultLogFilename)
5253

5354
errEmptyResults = errors.New("no matching entry was found")
5455
errMultipleMatches = errors.New("multiple entries matched the query")

0 commit comments

Comments
 (0)