I wrote a hosts-file switcher https://github.com/pbek/hswitch that generates an /etc/hosts file. It needs to be ran as root (which doesn’t seem to work with the snapped version of hswitch) and needs to write to the hosts file. Is that reason enough to apply for classic confinement in the snap store or is there an other way? (The name of the snap is “hswitch” in the store.)
I have a similar problem with https://github.com/pbek/lmdownload (a Linux Magazine PDF downloader for subscribers) where the user might want to download pdfs to other paths than the home directory…
Yes, interfaces will not change the file permissions, /etc/hosts as a file is only root writable, so you might need a little daemon that a userspace app can talk to or something like that to do the actual write operation as non-privileged user.