Bug 209628 - freebsd-update upgrade broken in jail
Summary: freebsd-update upgrade broken in jail
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 10.3-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: Security Team
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-18 22:20 UTC by Leif Pedersen
Modified: 2024-01-03 18:41 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Leif Pedersen 2016-05-18 22:20:52 UTC
`freebsd-update upgrade` looks at `uname -r` instead of `freebsd-version`. When running in a jail, this results in the error "freebsd-update: Cannot upgrade from 10.3-RELEASE to itself".

This can be worked around by setting UNAME_r=`freebsd-version`. However, this is an unnecessary complication, and there's no clear path to discover this since one must look in the uname man page for problems with freebsd-update.
Comment 1 Gerald Aryeetey 2019-01-17 17:14:02 UTC
The "--currently-running" also exists so one could do "freebsd-update --currently-running `freebsd-version`" which is decently documented.
Comment 2 Leif Pedersen 2019-01-17 23:16:59 UTC
(In reply to Gerald Aryeetey from comment #1)
True, thanks, that's a better work-around. Still, it seems obvious that it should default to what's actually installed, which is easily determined by `freebsd-version`. `uname` is often not what's actually installed.
Comment 3 Michael Osipov freebsd_committer freebsd_triage 2024-01-03 11:09:12 UTC
I believe that the workaround is ugly. freebsd-update can detect whether it runs inside a jail and derive the version automatically.
Comment 4 Michael Osipov freebsd_committer freebsd_triage 2024-01-03 11:11:08 UTC
This could be used, I guess:

root@deblndw013x4v1j:~
# sysctl -a | grep jail
...
security.jail.jailed: 1
Comment 5 Leif Pedersen 2024-01-03 15:22:39 UTC
I guess I don't see the point of examining sysctl or branching differently when in a jail. There's actually no need for `freebsd-update` to be aware of jails at all, nor be aware of the currently running kernel. The whole point of `freebsd-version` is to indicate what is currently installed, be it in a jail or not, which is exactly what `freebsd-update` needs.

The command `UNAME_r=$(freebsd-version) freebsd-update` works in all cases I'm aware of. `freebsd-update` just needs to be changed to default to it.
Comment 6 Michael Osipov freebsd_committer freebsd_triage 2024-01-03 15:23:51 UTC
(In reply to Leif Pedersen from comment #5)

Agree, no reason to use uname here. freebsd-version everywhere.