Repository navigation
Conversation
|
Thanks, I reviewed this and ran the tests locally: 55 passed (30 on Target branch. As you say in the description, this can't go into a release on its own: without the migration, a non-default school's clients get the forced-netboot grub cfg.
Before merging, please change these in the commits:
Optional hardening, as a separate small PR. The ids are unambiguous only because group names never contain |
b84811e to
8f46af1
Compare
On a multi-school server every LINBO hardware group is server-wide: two schools with a group raum101 share one start.conf.raum101. As agreed in linuxmuster-linbo7#178, every school other than default-school gets the school-qualified group id <school>+<group> for the LINBO artefacts derived from the group. default-school keeps the plain group, so single-school installations see no change. getLinboGroupId(school, group) builds the id, splitLinboGroupId() reverses it: no '+' means default-school, otherwise split on the first '+'. Neither part can contain '+' (sophomorix restricts group names to [A-Za-z0-9_-], the school is part of every hostname that isValidHostname() checks), so the id round-trips without the school list. Both are re-exported from linuxmuster_base7.functions so that linbo_mkgrubimg.py (linbo7) and linuxmuster-tools can reuse the naming rule instead of duplicating it. Added tests/test_functions_linbo.py. Refs linuxmuster#206 Signed-off-by: Tom Lehmann <tom.lehmann@netzint.de> Assisted-by: Claude
Use getLinboGroupId() wherever import-devices derives a LINBO name from the device group: - processDevicesForSubnet(): the group passed to buildDhcpHostDeclaration() for option extensions-path/nis-domain - doPxeGroupsBySchool(): the start.conf.<id> and ../<id>.cfg link sources and the returned pxe_groups, which carry the id on to doLinboStartconf() (start.conf.<id>) and doGrubCfg() (<id>.cfg) The id is built right after unpacking each device row, where the school is already known, so no function signature changes. default-school output (DHCP config, link csv, file names) stays byte for byte the same. The group is deliberately not qualified in validateDeviceRow()/ getDevicesArray(), where the hostname gets its school prefix: linbo_remote_lib.py (linbo7) compares that group column to the plain group given to linbo-remote -g <group> -s <school>. Freshly created unconfigured start.conf copies keep their Group = line; rewriting it belongs to the migration. Added tests/test_import_devices.py. The default-school cases also pass against the previous import_devices.py. Refs linuxmuster#206 Signed-off-by: Tom Lehmann <tom.lehmann@netzint.de> Assisted-by: Claude
8f46af1 to
4b962a3
Compare
|
Thanks for the review. All points are in:
The optional hardening is #209: |
First of the small PRs for #206 (design in linuxmuster/linuxmuster-linbo7#178): the LINBO group id helper pair and its use in
import_devices.py.What
functions/linbo.py, re-exported fromlinuxmuster_base7.functionsin the import list and in__all__:getLinboGroupId(school, group)returnsgroupfordefault-schooland<school>+<group>for every other school.splitLinboGroupId(group_id)returns('default-school', group_id)when there is no+, otherwise it splits on the first+.Neither part can contain
+: sophomorix restricts group names to[A-Za-z0-9_-], and the school is part of every hostname thatisValidHostname()checks. So the id round-trips without the school list. The helpers do no validation of their own.cli/import_devices.py: the id is built right after each device row is unpacked, whereschoolis already known. No function signature changes.processDevicesForSubnet()→buildDhcpHostDeclaration():option extensions-path/option nis-domaindoPxeGroupsBySchool(): thestart.conf.<id>link source (start.conf-<ip|mac>), the../<id>.cfglink source (hostcfg/<host>.cfg) and the returnedpxe_groupspxe_groups:doLinboStartconf()(start.conf.<id>, including the unconfigured copy) anddoGrubCfg()(<id>.cfg, and@@group@@in the generated cfg, which only appears inecholines)The group column in
devices.csvstays unqualified; the id is only derived.Default-school stays identical
For
default-school,getLinboGroupId()returns the group unchanged, so the DHCP config, the link csv, the symlinks and the file names are byte-for-byte the same as before. This is covered by tests that compare the exact output. Those default-school tests also pass against the unmodifiedimport_devices.pyfrom7.4, and the non-default-school tests fail there as expected.Deliberate non-changes
validateDeviceRow()/getDevicesArray()still return the plain group, although that's where the hostname gets its school prefix. linbo7'slinbo_remote_lib.py(hostsInGroup(),linbo-remote -g <group> -s <school>) compares that column to the plain group the user types, and qualifying it there would break that.Group =in a freshly created unconfigured start.conf copy is not rewritten. That belongs to the migration (next PR) and to linuxmuster-tools.src/andshare/, includingdhcpd-update-samba-dns.pyand the dhcpd templates.Not releasable on its own
Without the migration, the next import of a non-default school finds no
start.conf.<school>+<group>and copies the unconfigured template, so that school's clients get a forced-netboot grub cfg. This PR should only go into a tagged release together with the migration PR (and the linbo7linbo_syncfallback, linuxmuster/linuxmuster-linbo7#181). The proposal for where the migration runs is in #206.Tests
tests/test_functions_linbo.py: both helpers, round-trips, group and school names with-/_, and thea+b-xvs.a-b+xcollision case that ruled out-tests/test_import_devices.py:processDevicesForSubnet()output, the link csv andpxe_groupsfromdoPxeGroupsBySchool(), and an end-to-end run ofgenerateGrubConfigsForGroups()(start.conf, grub cfg, symlinks), each fordefault-schooland a non-default school.getDevicesArray()is stubbed, and theenvironmentLINBO paths are monkeypatched totmp_path.pytest testswith linuxmuster-common'senvironment.pyonsys.path: 55 passed (30 before). flake8 (--max-line-length=100, per the black config) reports nothing new in the changed files.Refs #206, linuxmuster/linuxmuster-linbo7#178