sbs20 / scanservjs

SANE scanner nodejs web ui
https://sbs20.github.io/scanservjs/
GNU General Public License v2.0
768 stars 146 forks source link

/usr/share must not be touched at runtime #695

Closed chayleaf closed 1 year ago

chayleaf commented 1 year ago

Describe the bug /usr/share is only for the package's bundled data that has to be shipped with it and doesn't change at runtime. /usr may well be immutable on many systems. /var should be used for persistent runtime data. I also recommend making preview/default.jpg fall back to the package's file, so it doesn't have to be in /var.

Expected behavior Only /var being used for storing outputs

sbs20 commented 1 year ago

Thanks for this. I am going to change this to /var/lib/scanservjs - is that compliant? I've struggled with interpreting the FHS and reconciling it with what other apps do.

chayleaf commented 1 year ago

yes, you may also use systemd's StateDirectory for this. Note that fs.mkdirSync(config.previewDirectory, { recursive: true }); will be needed in app-server/src/express-configurer.js.

Also, I can't tell how the config is loaded from /etc, could you point to me how it works?

sbs20 commented 1 year ago

Config is loaded here: https://github.com/sbs20/scanservjs/blob/f4b8bda4327e81e2c7d3f5b6fae578a9e57ab93d/app-server/src/application.js#L29

chayleaf commented 1 year ago

Config is loaded here:

https://github.com/sbs20/scanservjs/blob/f4b8bda4327e81e2c7d3f5b6fae578a9e57ab93d/app-server/src/application.js#L29

Yes, and I see no references to /etc here found it

chayleaf commented 1 year ago

@sbs20 also, the app should work with empty /var - anything else makes packaging extremely annoying (it's on the level of the maintainer having to manually patch the package). I.e. the package shouldn't put any files to /var.

It may create an empty directory there, but I'd recommend not doing that, using systemd's StateDirectory instead.

Sorry for not making this clear enough above. As I mentioned already, fs.mkdirSync(config.previewDirectory, { recursive: true }); will have to be added.