|
84 | 84 | type = types.bool; |
85 | 85 | description = "Whether to turn on the VSOCK-based access to all VMs. This provides an unauthenticated access intended for debugging."; |
86 | 86 | }; |
| 87 | + vsockOffset = mkOption { |
| 88 | + default = 2; |
| 89 | + type = types.ints.between 2 4294967296; |
| 90 | + description = '' |
| 91 | + This field is only relevant when multiple users run the (interactive) |
| 92 | + driver outside the sandbox and with the SSH backdoor activated. |
| 93 | + The typical symptom for this being a problem are error messages like this: |
| 94 | + `vhost-vsock: unable to set guest cid: Address already in use` |
| 95 | +
|
| 96 | + This option allows to assign an offset to each vsock number to |
| 97 | + resolve this. |
| 98 | +
|
| 99 | + This is a 32bit number. The lowest possible vsock number is `3` |
| 100 | + (i.e. with the lowest node number being `1`, this is 2+1). |
| 101 | + ''; |
| 102 | + }; |
87 | 103 | }; |
88 | 104 |
|
89 | 105 | node.type = mkOption { |
|
182 | 198 | passthru.nodes = config.nodesCompat; |
183 | 199 |
|
184 | 200 | extraDriverArgs = mkIf config.sshBackdoor.enable [ |
185 | | - "--dump-vsocks" |
| 201 | + "--dump-vsocks=${toString config.sshBackdoor.vsockOffset}" |
186 | 202 | ]; |
187 | 203 |
|
188 | 204 | defaults = mkMerge [ |
189 | 205 | (mkIf config.node.pkgsReadOnly { |
190 | 206 | nixpkgs.pkgs = config.node.pkgs; |
191 | 207 | imports = [ ../../modules/misc/nixpkgs/read-only.nix ]; |
192 | 208 | }) |
193 | | - (mkIf config.sshBackdoor.enable { |
194 | | - testing.sshBackdoor.enable = true; |
195 | | - }) |
| 209 | + (mkIf config.sshBackdoor.enable ( |
| 210 | + let |
| 211 | + inherit (config.sshBackdoor) vsockOffset; |
| 212 | + in |
| 213 | + { config, ... }: |
| 214 | + { |
| 215 | + services.openssh = { |
| 216 | + enable = true; |
| 217 | + settings = { |
| 218 | + PermitRootLogin = "yes"; |
| 219 | + PermitEmptyPasswords = "yes"; |
| 220 | + }; |
| 221 | + }; |
| 222 | + |
| 223 | + security.pam.services.sshd = { |
| 224 | + allowNullPassword = true; |
| 225 | + }; |
| 226 | + |
| 227 | + virtualisation.qemu.options = [ |
| 228 | + "-device vhost-vsock-pci,guest-cid=${ |
| 229 | + toString (config.virtualisation.test.nodeNumber + vsockOffset) |
| 230 | + }" |
| 231 | + ]; |
| 232 | + } |
| 233 | + )) |
196 | 234 | ]; |
197 | 235 |
|
198 | 236 | }; |
|
0 commit comments