# Command Line unix stuff over my head: What am I doing wrong?

**URL:** https://boards.straightdope.com/t/command-line-unix-stuff-over-my-head-what-am-i-doing-wrong/962376
**Category:** Factual Questions
**Created:** [April 6, 2022, 5:20am UTC](https://boards.straightdope.com/t/command-line-unix-stuff-over-my-head-what-am-i-doing-wrong/962376 "2022-04-06T05:20:12Z")
**Posts on this page:** 1
**Page:** 2

<div class="post-metadata">

### Author: ![echoreply](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/echoreply/32/3641_2.png) [@echoreply](https://boards.straightdope.com/u/echoreply)
#### Post date: [April 11, 2022, 8:29pm UTC](https://boards.straightdope.com/t/command-line-unix-stuff-over-my-head-what-am-i-doing-wrong/962376/21 "2022-04-11T20:29:31Z")

</div>

> [@HMS\_Irruncible](#):
>
> The script expects to find your rootcert.pem file under a certain path name (where you put the file before you ran it). But on line 2 of the script, it composes a path name using the process ID of the script. That’s the $$ variable

That line has a different problem, mainly that the author has never heard of `mktemp -d`. The `DIR=${TMPDIR}/trustroot.$$` is just a lazy way of making a unique directory to put a bunch of certificates in. It should work fine assuming there are no malicious users on the system creating a bunch of `trustroot.12345` directories and filling them with evil certificates hoping they’ll get added the trust store when the sysadmin runs the script.

`TMPDIR` on the Mac might even be specific to each user, in which case I’m being overly cautious, but `mktemp` would be the far better solution on most Unix-likes, where TMPDIR is going to default to the 1777 `/tmp`.

The directory is being created because the `rootcerts.pem` file needs to be broken up into it’s individual certificates, and then each individually added to the trust store; which is what the loop does.

[Previous page](https://boards.straightdope.com/t/command-line-unix-stuff-over-my-head-what-am-i-doing-wrong/962376.md?page=1)
