Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not discard changes in hosts file #14

Closed
eksperimental opened this issue Oct 29, 2020 · 9 comments · Fixed by #15
Closed

Do not discard changes in hosts file #14

eksperimental opened this issue Oct 29, 2020 · 9 comments · Fixed by #15

Comments

@eksperimental
Copy link
Contributor

Besides the comment, I think AdSorber should not discard changes in /etc/hosts.
What it should, I think, is make the block of hosts delimited with a start and end comment. Leave a comment saying this block will be overwritten in the next update, but only delete these chunk and preserve the rest of the file as is

@stablestud
Copy link
Owner

Hi @eksperimental,

You can make your changes to the hosts file persistent by adding them to /etc/hosts.original instead of /etc/hosts.

Background info:

  • Adsorber creates /etc/hosts.original as the backup of the original /etc/hosts and it'll be used as the base when its updating the hosts file.
  • Also when you remove adsorber from the system or when you disable it with adsorber disable the hosts file will be restored to its original form by moving /etc/hosts.original to /etc/hosts leaving it like adsorber has never been there.

@stablestud
Copy link
Owner

But I've to admit, the documentation does not give any information how to add persistent values. Will add it later today.

@eksperimental
Copy link
Contributor Author

Hi @eksperimental,

You can make your changes to the hosts file persistent by adding them to /etc/hosts.original instead of /etc/hosts.

Background info:

* Adsorber creates `/etc/hosts.original` as the backup of the original `/etc/hosts` and it'll be used as the base when its updating the hosts file.

* Also when you remove adsorber from the system or when you disable it with `adsorber disable` the hosts file will be restored to its original form by moving `/etc/hosts.original` to `/etc/hosts` leaving it like adsorber has never been there.

thank you for your answer.
Yes, I know that. but it just happened to me that I edited the files and when I upgraded my system, I realized the changes were lost.
From a usability point of view if the software can mark the edited section and only modify that, It is less overhead for the user. Also, what happens when there is another software that also edit /etc/hosts ?

@stablestud
Copy link
Owner

stablestud commented Oct 29, 2020

When another application is writing to /etc/hosts the changes are gone.
I never thought about that.

Is there any application that does write to /etc/hosts? To my knowledge Docker does that but only inside a container.

@eksperimental
Copy link
Contributor Author

another software like adsorber, or maybe command line instructions, or custom bash functions such as https://gist.github.com/irazasyed/a7b0a079e7727a4315b9

It should not be expected that someone will open up the file and read the initial comment saying it should not be edited.
Well, those are my two cents

@stablestud
Copy link
Owner

Ok I see, you are right. I'll see what I can do.

Thanks for reporting.

@eksperimental
Copy link
Contributor Author

eksperimental commented Oct 29, 2020

Awesome and thank you.
perl seems like the right tool for the job. Let me know if I can help with anything.
But any tool that can use a regex and replace will do

@stablestud
Copy link
Owner

I would like to stick to sed. It's already being used, and perl would be another dependency. Expect a new version somewhere around the weekend.

@eksperimental
Copy link
Contributor Author

Thank you @stablestud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants