|
| 1 | +# Copyright 2020-2024 VyOS maintainers and contributors <maintainers@vyos.io> |
| 2 | +# |
| 3 | +# This library is free software; you can redistribute it and/or |
| 4 | +# modify it under the terms of the GNU Lesser General Public |
| 5 | +# License as published by the Free Software Foundation; either |
| 6 | +# version 2.1 of the License, or (at your option) any later version. |
| 7 | +# |
| 8 | +# This library is distributed in the hope that it will be useful, |
| 9 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | +# Lesser General Public License for more details. |
| 12 | +# |
| 13 | +# You should have received a copy of the GNU Lesser General Public License |
| 14 | +# along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 15 | + |
| 16 | +# T7557: OpenSSH on Trixie does not support DSS keys |
| 17 | +# https://www.debian.org/releases/trixie/release-notes/issues.en.html#openssh-no-longer-supports-dsa-keys |
| 18 | + |
| 19 | + |
| 20 | +from vyos.configtree import ConfigTree |
| 21 | + |
| 22 | +base = ['service', 'ssh'] |
| 23 | + |
| 24 | +def migrate(config: ConfigTree) -> None: |
| 25 | + if not config.exists(base): |
| 26 | + # Nothing to do |
| 27 | + return |
| 28 | + |
| 29 | + dss_algo = [ |
| 30 | + 'ssh-dss', |
| 31 | + 'ssh-dss-cert-v01@openssh.com', |
| 32 | + ] |
| 33 | + |
| 34 | + path_hostkey = base + ['hostkey-algorithm'] |
| 35 | + if config.exists(path_hostkey): |
| 36 | + values = config.return_values(path_hostkey) |
| 37 | + for algo in dss_algo: |
| 38 | + if algo in values: |
| 39 | + config.delete_value(path_hostkey, algo) |
| 40 | + |
| 41 | + path_pubkey = base + ['pubkey-accepted-algorithm'] |
| 42 | + if config.exists(path_pubkey): |
| 43 | + values = config.return_values(path_pubkey) |
| 44 | + for algo in dss_algo: |
| 45 | + if algo in values: |
| 46 | + config.delete_value(path_pubkey, algo) |
0 commit comments