Temporarily remove or switch ad blocking hosts file

  • This topic has 7 replies, 4 voices, and was last updated Jan 12-9:41 am by ModdIt.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #33238
    Member
    dirkd

      Thread title changed with permission from original poster.
      Aim, keep ad blocking related posts in one thread.

      If I understand it well, the hosts file in /etc is used for ad blocking. I’m all in favour of ad blocking, but sometimes it interferes with login procedures. E.g., when I want to watch past television programs on our Belgian public television, I need to login with Google credentials and I get blocked in the process. Temporarily switching to an almost empty hosts file is a workaround: a cookie gets set which marks me as logged in, and afterwards I can switch back to the original hosts file.

      Now I doubt if that is the recommended way to go. Is there another, maybe more convenient, way to temporarily suspend ad blocking?

      Thanks

      • This topic was modified 1 year, 5 months ago by ModdIt. Reason: make search easier
      #33239
      Forum Admin
      anticapitalista
        Helpful
        Up
        0
        ::

        Via the adblock app? Choose UNBLOCK

        Philosophers have interpreted the world in many ways; the point is to change it.

        antiX with runit - leaner and meaner.

        #70885
        Member
        ModdIt
          Helpful
          Up
          0
          ::

          Need to work in antiX 21 too as that is our future standard.

          Fighting with the needs of family members, young kids to adult.

          AD block can be switched to unblock, think it might be feasible to adjust ad, tracker, porn etc blocking
          per user.

          Any ideas on how to do that very welcome, unfortunately my foggy old head is not really adapted to 21 Century scripting.

          Highest possible level for the youngest kids activated during login to their dedicated user.
          Older Kids, a school user and one where they are far less restricted, again activation as part of login process,
          that way they (hopefully) do not completely turn off the blocking feature or boot from live and delete the hosts file.
          Been there already. Kids learn fast.

          With accesscible multi user devices need to set a BIOS Password and block USB Boot where possible. Restrict sudo to selected
          persons.

          Found this but much beyond my understanding at present.
          https://unix.stackexchange.com/questions/10438/can-i-create-a-user-specific-hosts-file-to-complement-etc-hosts

          I do think this could be yet another argument for antiX adoption. Very family friendly and all the other multiple virtues on top.

          • This reply was modified 1 year, 5 months ago by ModdIt.
          • This reply was modified 1 year, 5 months ago by ModdIt.
          #70924
          Member
          sybok
            Helpful
            Up
            0
            ::

            Hi, sorry for potentially hijacking this thread

            @Moddit: Ad-block per user:
            This is a nasty manual hack for existing users, preserved across updates.

            1) Root-owned files per user ‘etc_hosts_<username>’ e.g. in ‘/opt/custom_hosts/’, system default stored in ‘/opt/custom_hosts/etc_hosts_advert-block-antix’.
            2) advert-block-antix
            A) Post-installation check

            opt_cus_ad='/opt/custom_hosts/etc_hosts_advert-block-antix'
            if [ -f "${opt_cus_ad}" ]; then
              cat "<new version of /etc/hosts file>" > "${opt_cus_ad}"
            fi

            No new file created, only update if existing (still fairly lean and mean).
            B) Corresponding update of the documentation.

            3) Force execution of this command during login of a user:
            cat /opt/custom_hosts/etc_hosts_<username> /opt/custom_hosts/etc_hosts_antix_system /etc/hosts
            Execute even if ‘/opt/custom_hosts/etc_hosts_<username>’ does not exist to re-set /etc/hosts after previous user.
            ‘cat’ will complain about non-existing file but updates the output since the default file exists (tested as standard user on GNU coreutils 8.32).
            Of course, the command can be extended to an if-else condition to avoid applying ‘cat’ to a non-existing file.

            Simplest way I can currently think of is to ‘sudo visudo’ and allow each user to run it without password.
            Then add it into their ‘~/.desktop_session/startup’.
            Not a foolproof solution since the user can edit the aforementioned file and thus completely skip it.

            Issues:
            1) Can be altered by anyone with sudo or able to write-mount ‘/’ e.g. using live-USB and/or in a multi-boot environment.
            3) Make the execution of this step safe/automated and “forced” to the user without ability to circumvent it.

            • This reply was modified 1 year, 5 months ago by sybok.
            • This reply was modified 1 year, 5 months ago by sybok. Reason: Actually, the solution is preserved after update; step 3) comment
            #71002
            Member
            ModdIt
              Helpful
              Up
              0
              ::

              Thanks sybok,
              still looking for a sensible solution to hosts switch.
              Make the execution of this step safe/automated and “forced” to the user without ability to circumvent it.
              would be ideal but determined kids from about 8 on will find a way around most anything. Including resetting BIOS
              to get back in charge.

              Actually something I love to see is getting duped. Shows kids are really learning.

              #71035
              Member
              sybok
                Helpful
                Up
                0
                ::

                Hi again,
                I did not mention it explicitly in my previous post, the ‘advert-block-antix’ item 2) was a *proposed*, not existing behavior.

                Regarding the step 3):
                You can modify permission of ‘~/.desktop-session/autostart’ (user can execute it but not read/write to it) that will source the usual “autostart” that must, of course, be renamed (e.g. to ‘~/.desktop-session/autostart_local’).
                That’s the best I can come up with except for creating a service to check if all locally (not to mess things up if someone connects remotely) logged-in users have ‘/etc/hosts’ that contains all the lines from ‘/opt/custom_hosts/etc_hosts_username’.

                I guess any further discussion should proceed elsewhere and not in this thread.

                • This reply was modified 1 year, 5 months ago by sybok. Reason: Further: elsewhere
                • This reply was modified 1 year, 5 months ago by sybok.
                #74875
                Member
                sybok
                  Helpful
                  Up
                  0
                  ::

                  If anyone is interested, I post 3 basic files and some test etc-hosts file that may provide the service-based solution.
                  I thought it could be nice exercise.
                  If you wish to test it, unpack and replace any occurrence of ‘/data/Scripts/EtcHostsAccordingToCurrentUser/’ by your test-folder.
                  Disclaimer:
                  There are few TODOs/things to clarify, the most crucial: which internet-related services need to be restarted (and how) after modifying ‘/etc/hosts’?
                  Not fully tested but seems to work OK with the some basic tests.
                  The scripts contain some debug-printing, mostly commented out to test the flow of the code.
                  Also, the service file may serve as a template for some other projects.

                  • This reply was modified 1 year, 4 months ago by sybok.
                  • This reply was modified 1 year, 4 months ago by sybok. Reason: Mention TODO(s)
                  #75079
                  Member
                  ModdIt
                    Helpful
                    Up
                    0
                    ::

                    Hallo sybok, thanks for the nudge,
                    I have downloaded the hosts change code, just busy on using up some rare wood
                    before it dries too hard to carve by hand.
                    Also been digging in to the way firefox is delivered by debian, Will checkout the user switcing hosts soon.
                    In /lib firefox-esr/defaults/preferences you have firefox.js which switches all the tracking and pinging crap on by default.

                    The illegal in eu settings should not come with a fresh download or install using distro tools.
                    Direct from Mozilla site is a user choice so I have no objections to that.

                    • This reply was modified 1 year, 3 months ago by ModdIt.
                  Viewing 8 posts - 1 through 8 (of 8 total)
                  • You must be logged in to reply to this topic.