Issues with apt-cacher-ng

Forum logistics

Thank you @Sven

1 Like
Forum logistics

Done

Forum logistics

Sorry I was bamboozled by the fork.

I wanted the General Discussion to be ā€œIssues with apt-cacher-ngā€
and the User Support thread to be ā€œCaching updates for non-templates using
apt-cacher-ngā€

2 Likes
Forum logistics

It shall be so. :wink:

@Insurgo, @unman,

In /etc/apt/apt.conf.d/90whonix I found this:

Summary
## apt caching proxy:
## apt-cacher-ng
##
## If you want to use apt-cacher-ng,
## you have to disable the apt-get uwt wrapper:
##     create a file /etc/uwt.d/50_user.conf with
##     uwtwrapper["/usr/bin/apt-get"]="0"
##

So I did it.

In the same file I have found this

Summary
## Please do not edit 90whonix file! This is because with next
## Whonix update, this file may get replaced with an improved version.
## That is why you created your own file /etc/apt/apt.conf.d/50user instead.

So I created it with these options enabled

Summary
## Working.
Acquire::http { Proxy "http://127.0.0.1:8082"; };
##
## Untested.
Acquire::http::Proxy "http://127.0.0.1:8082/";
Acquire::https::Proxy "http://127.0.0.1:8082/";
Acquire::ftp::Proxy "ftp://127.0.0.1:8082/";
Acquire::tor::Proxy "http://127.0.0.1:8082/";

According to /etc/uwt.d/30_uwt_default.conf I created 50_uwt_user.conf and specifically disabled

Summary
uwtwrapper["/usr/bin/apt"]="0"
uwtwrapper["/usr/bin/apt-get"]="0"

I have changed all sources lists in Whonix to point to cacher adding http://HTTPS/// to the each link. Onion addresses arenā€™t working because Iā€™m point to cacher anyway and from there to tor via sys-whonix, so I commented them in.

In dom0, in my 30_user.policy I have changed whonix vm to point to cacher:

# Upgrade Whonix TemplateVMs through sys-whonix.
qubes.UpdatesProxy      *   @tag:whonix-updatevm    @default    allow target=cacher
# Deny Whonix TemplateVMs using UpdatesProxy of any other VM.
qubes.UpdatesProxy      *   @tag:whonix-updatevm    @anyvm      deny
qubes.UpdatesProxy	* vault @anyvm deny
...
...

Started update in whonix template

Summary
user@host:~$ sudo apt update
Hit:1 tor+http://HTTPS///deb.debian.org/debian bullseye InRelease
Hit:2 http://HTTPS///contrib.qubes-os.org/deb/r4.1/vm bullseye InRelease
Get:3 tor+http://HTTPS///deb.debian.org/debian bullseye-updates InRelease [44.1 kB]
Hit:4 tor+http://HTTPS///deb.debian.org/debian-security bullseye-security InRelease
Hit:5 http://HTTPS///contrib.qubes-os.org/deb/r4.1/vm bullseye-testing InRelease
Get:6 tor+http://HTTPS///deb.debian.org/debian bullseye-backports InRelease [49.0 kB]
Hit:7 http://HTTPS///deb.qubes-os.org/r4.1/vm bullseye-testing InRelease
Hit:8 tor+http://HTTPS///fasttrack.debian.net/debian bullseye-fasttrack InRelease
Hit:9 http://HTTPS///deb.qubes-os.org/r4.1/vm bullseye-securitytesting InRelease
Hit:10 tor+http://HTTPS///deb.whonix.org bullseye InRelease                    
Get:11 tor+http://HTTPS///deb.debian.org/debian bullseye-updates/main amd64 Packages.diff/Index [12.8 kB]
Get:12 tor+http://HTTPS///deb.debian.org/debian bullseye-backports/main amd64 Packages.diff/Index [63.3 kB]
Get:13 tor+http://HTTPS///deb.debian.org/debian bullseye-updates/main amd64 Packages T-2022-10-15-2035.13-F-2022-10-15-2035.13.pdiff [286 B]
Get:13 tor+http://HTTPS///deb.debian.org/debian bullseye-updates/main amd64 Packages T-2022-10-15-2035.13-F-2022-10-15-2035.13.pdiff [286 B]
Get:14 tor+http://HTTPS///deb.debian.org/debian bullseye-backports/main amd64 Packages T-2022-10-15-2035.13-F-2022-10-15-2035.13.pdiff [387 B]
Get:14 tor+http://HTTPS///deb.debian.org/debian bullseye-backports/main amd64 Packages T-2022-10-15-2035.13-F-2022-10-15-2035.13.pdiff [387 B]
Fetched 170 kB in 1min 10s (2,420 B/s)                                         
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
1 package can be upgraded. Run 'apt list --upgradable' to see it.
user@host:~$

Can someone please confirm this as well as if thereā€™s some security unwise actions in this?

Hmm.

I guess this is under whonix templates.

My understanding is that it is another way of disabling whonix check for torrified update proxy.

For the moment I have no opinion on this, which implementation discussion is happening under shaker at

@unman : I am still confused on some of the internals.

Wanting to reply on a forum thread, and not having installed anything under my disp sys-net for a while, I wanted to install wireshark there in current session to install additional tools I needed just for that sessionā€¦

And fell into another rabbit hole.

First, as I normally am able to do with current setup on other qubes:

[user@sys-net ~]$ sudo dnf update
Fedora 36 - x86_64                                                                                                                       11  B/s | 547  B     00:48    
Errors during downloading metadata for repository 'fedora':
  - Status code: 500 for http://HTTPS///mirrors.fedoraproject.org/metalink?repo=fedora-36&arch=x86_64&protocol=http&protocol=http (IP: 127.0.0.1)
Error: Failed to download metadata for repo 'fedora': Cannot prepare internal mirrorlist: Status code: 500 for http://HTTPS///mirrors.fedoraproject.org/metalink?repo=fedora-36&arch=x86_64&protocol=http&protocol=http (IP: 127.0.0.1)

Hmm?

[user@dom0 ~]$ qvm-service sys-net 
clocksync            on
qubes-update-check   on
updates-proxy-setup  on

Okā€¦
Letā€™s compare with sys-firewall, which works:

[user@sys-firewall ~]$ sudo dnf update
Fedora 36 openh264 (From Cisco) - x86_64                                                                                                0.0  B/s |   0  B     00:00    
Errors during downloading metadata for repository 'fedora-cisco-openh264':
  - Curl error (56): Failure when receiving data from the peer for https://codecs.fedoraproject.org/openh264/36/x86_64/os/repodata/repomd.xml [Received HTTP code 403 from proxy after CONNECT]
Error: Failed to download metadata for repo 'fedora-cisco-openh264': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
Fedora 36 - x86_64 - Updates                                                                                                             15 MB/s |  28 MB     00:01    
^C^C^C^C^C^C^C^C^C^CKeyboardInterrupt: Terminated.
[user@dom0 ~]$ qvm-service sys-firewall
qubes-update-check   on
updates-proxy-setup  on

Any explanation on this?

[user@dom0 ~]$ sudo cat /etc/qubes/policy.d/30-user.policy 
qubes.UpdatesProxy  *  @anyvm  @default  allow target=cacher
#qubes.UpdatesProxy  *  @tag:whonix-updatevm    @default    allow target=sys-whonix
#qubes.UpdatesProxy  *  @type:AppVM  @default  allow target=cacher
#qubes.UpdatesProxy  *  @type:TemplateVM  @default  allow target=cacher
[user@sys-net ~]$ wget 127.0.0.1:8082
--2022-10-17 14:03:14--  http://127.0.0.1:8082/
Connecting to 127.0.0.1:8082... connected.
HTTP request sent, awaiting response... 403 Filtered
2022-10-17 14:03:14 ERROR 403: Filtered.
[user@sys-firewall ~]$ wget 127.0.0.1:8082
--2022-10-17 14:03:42--  http://127.0.0.1:8082/
Connecting to 127.0.0.1:8082... connected.
HTTP request sent, awaiting response... 406 Usage Information
2022-10-17 14:03:42 ERROR 406: Usage Information.

I would have expected to have the same behavior between sys-firewall and sys-net.

Another question: how to change the default of a qvm-service? I recently created a new qube, and that qube doesnā€™t have updates-proxy-setup by default.
As we discussed before, I do not really see how a qube having qubes-update-check service on, depending on cacher to be able to provide package list to notify dom0 could be able to do so without having updates-proxy-setup also enabled.

Consequently, for the usage I do of cacher, permitting me to install softwares I can sporadically need to have into sys-net or other disposable, I want my qubes to be able to report for templates available updates when I use them, as well as being able to have any qube I use be able to install software in them, since I am well aware, from my use case, that those wonā€™t survive reboot as well. And for that, I would love to have updates-proxy-setup enabled by default unless I deactivate those manually.

How to accomplish this?

From https://dev.qubes-os.org/projects/core-admin-client/en/latest/manpages/qvm-service.html:

`--default` `` `, ` `-D` `` `, ` `--delete` `` `, ` `--unset` ``
Reset service to its default state (remove from the list). Default state means ā€œlets VM chooseā€ and can depend on VM type (NetVM, AppVM etc).

@unman : I understand that updates-proxy-setup would need to be enabled by default in the templates/dispvm templates?

Iā€™m getting this here

user@cacher:~$ wget 127.0.0.1:8082
--2022-10-18 14:06:33--  http://127.0.0.1:8082/
Connecting to 127.0.0.1:8082... connected.
HTTP request sent, awaiting response... 406 Usage Information
2022-10-18 14:06:33 ERROR 406: Usage Information.

Your here is linked to something unsupported, from what i quickly surveyed on that post. I would suggest using shaker/cacher so that project can improve from its deployed settings instead of @unman or the community trying to figure out errors that would not occur by following known to work recipes.

I wonā€™t comment on that own thread content, whike this off topic comment referring to that thread of inppace upgrade gone wrong will be misleading in this thread.

In other circumstances, receiving usage information in a working setup would be a good news. This means the web service is ready to receive direct connection and permits the user to deal with the cache settings from a web browser. Under correct circumstances, if cacher is setuped to be netvm of a qube, that qube couod connect directly to cacherā€™s ip addressā€™ port or if proxy-enable-setup service is activated for a qube, to talk to 127.0.0.1:8082 to access cache configuration settihgs directly.

Offtopic

The fix was trivial, or rather quick. I linked to the other topic not knowing if itā€™s something about apt-caher-ng started not to work, regardless of the template, especially getting 403ā€™s. I hope I clarified my reasoning now.