Bug #5344
openNLSR should not write nlsrSeqNo.txt in the home directory
0%
Description
It's bad etiquette. FHS defines /var/lib as the directory to hold application state information. Furthermore, XDG defines $XDG_STATE_HOME for similar purposes, with a default value of $HOME/.local/state. When running as a systemd service, we should also consider honoring the $STATE_DIRECTORY env variable.
Updated by Davide Pesavento 9 months ago
I just remembered that nlsr.conf has a mandatory state-dir setting. So I guess the $HOME logic is only used as a fallback? But what's the point of a fallback if the setting is mandatory?
That being said, this bug is still valid because when I run the unit tests, a nlsrSeqNo.txt file appears in my home directory. That should not happen.
Updated by Alexander Lane 9 months ago
Davide Pesavento wrote in #note-1:
I just remembered that
nlsr.confhas a mandatorystate-dirsetting. So I guess the$HOMElogic is only used as a fallback? But what's the point of a fallback if the setting is mandatory?That being said, this bug is still valid because when I run the unit tests, a
nlsrSeqNo.txtfile appears in my home directory. That should not happen.
From looking at the tests, my understanding is that ConfParam objects will default the state directory value to a null string, ergo failing over to $HOME and leaving stray files. I think the question then arises of if we should default to the home directory at all, or instead use /tmp like the unit tests for the SequencingManager tests.
Updated by Davide Pesavento 9 months ago
Alexander Lane wrote in #note-2:
I think the question then arises of if we should default to the home directory at all
I don't see the point of having a default value/fallback at all. But if there is one, it definitely shouldn't be the home dir.
or instead use
/tmplike the unit tests for the SequencingManager tests.
NFD uses a temporary dir in the build dir (https://github.com/named-data/NFD/blob/2b43d675e3fba37b5362fab0001ba542bb07b43b/tests/wscript#L31), but a unique subdir of /tmp is fine too.