| | @@ -10,6 +10,10 @@ pub(super) fn check_extraction(case: &str, safe: bool) { |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | fn run_case(case: &str, safe: bool, extraction: bool) { |
| 13 | +추가: run_case_with_policy(case, safe, extraction, None); |
| 14 | +추가: } |
| 15 | +추가: |
| 16 | +추가: fn run_case_with_policy(case: &str, safe: bool, extraction: bool, policy: Option<&str>) { |
| 13 | 17 | let scratch = Scratch::new(); |
| 14 | 18 | let output = scratch.0.join("output"); |
| 15 | 19 | fs::create_dir(&output).unwrap(); |
| | @@ -64,8 +68,13 @@ fn run_case(case: &str, safe: bool, extraction: bool) { |
| 64 | 68 | } |
| 65 | 69 | _ => "# fixture\npasswd: files # local accounts\n", |
| 66 | 70 | }; |
| 71 | +추가: let nss = if case == "missing-policy" { |
| 72 | +추가: nss.to_owned() |
| 73 | +추가: } else { |
| 74 | +추가: format!("{nss}group: files\n") |
| 75 | +추가: }; |
| 67 | 76 | let nss_path = scratch.0.join("nsswitch.conf"); |
| 68 | | -삭제: fs::write(&nss_path, nss).unwrap(); |
| 77 | +추가: fs::write(&nss_path, policy.unwrap_or(&nss)).unwrap(); |
| 69 | 78 | if case == "nss-unavailable" { |
| 70 | 79 | fs::remove_file(&nss_path).unwrap(); |
| 71 | 80 | } |
| | @@ -125,7 +134,7 @@ fn run_case(case: &str, safe: bool, extraction: bool) { |
| 125 | 134 | .unwrap(); |
| 126 | 135 | assert!( |
| 127 | 136 | result.status.success(), |
| 128 | | -삭제: "{case}: {} {}", |
| 137 | +추가: "{case} policy={policy:?}: {} {}", |
| 129 | 138 | String::from_utf8_lossy(&result.stdout), |
| 130 | 139 | String::from_utf8_lossy(&result.stderr) |
| 131 | 140 | ); |
| | @@ -255,6 +264,82 @@ fn private_group_checks_varlink_records_and_completion() { |
| 255 | 264 | } |
| 256 | 265 | } |
| 257 | 266 | |
| 267 | +추가: #[test] |
| 268 | +추가: fn private_group_checks_systemd_in_group_and_initgroups_policies() { |
| 269 | +추가: for policy in [ |
| 270 | +추가: "passwd: files\ngroup: files systemd\n", |
| 271 | +추가: "passwd: files\ngroup: files systemd\ninitgroups: files\n", |
| 272 | +추가: "passwd: files\ngroup: files\ninitgroups: files systemd\n", |
| 273 | +추가: ] { |
| 274 | +추가: for case in ["systemd-personal", "systemd-unrelated"] { |
| 275 | +추가: run_case_with_policy(case, true, true, Some(policy)); |
| 276 | +추가: } |
| 277 | +추가: for case in [ |
| 278 | +추가: "systemd-dynamic-shared", |
| 279 | +추가: "systemd-group-member", |
| 280 | +추가: "systemd-membership-member", |
| 281 | +추가: "systemd-user-member", |
| 282 | +추가: "systemd-partial-error", |
| 283 | +추가: "userdb-d0", |
| 284 | +추가: ] { |
| 285 | +추가: run_case_with_policy(case, false, true, Some(policy)); |
| 286 | +추가: } |
| 287 | +추가: } |
| 288 | +추가: } |
| 289 | +추가: |
| 290 | +추가: #[test] |
| 291 | +추가: fn private_group_checks_sss_in_group_and_initgroups_policies() { |
| 292 | +추가: for policy in [ |
| 293 | +추가: "passwd: files\ngroup: files sss\n", |
| 294 | +추가: "passwd: files\ngroup: files sss\ninitgroups: files\n", |
| 295 | +추가: "passwd: files\ngroup: files\ninitgroups: files sss\n", |
| 296 | +추가: ] { |
| 297 | +추가: run_case_with_policy("sss-empty", true, true, Some(policy)); |
| 298 | +추가: for case in [ |
| 299 | +추가: "sss-socket", |
| 300 | +추가: "sss-passwd-cache", |
| 301 | +추가: "sss-group-cache", |
| 302 | +추가: "sss-initgr-cache", |
| 303 | +추가: "sss-probe-error", |
| 304 | +추가: ] { |
| 305 | +추가: run_case_with_policy(case, false, true, Some(policy)); |
| 306 | +추가: } |
| 307 | +추가: } |
| 308 | +추가: } |
| 309 | +추가: |
| 310 | +추가: #[test] |
| 311 | +추가: fn private_group_rejects_incomplete_group_and_initgroups_policies() { |
| 312 | +추가: for policy in [ |
| 313 | +추가: "passwd: files\n", |
| 314 | +추가: "passwd: files\ngroup: files\ngroup: files\n", |
| 315 | +추가: "passwd: files\ngroup: files\ninitgroups: files\ninitgroups: files\n", |
| 316 | +추가: ] { |
| 317 | +추가: run_case_with_policy("personal", false, true, Some(policy)); |
| 318 | +추가: } |
| 319 | +추가: for source in [ |
| 320 | +추가: "", |
| 321 | +추가: "files ldap", |
| 322 | +추가: "files winbind", |
| 323 | +추가: "files unknown", |
| 324 | +추가: "files [SUCCESS=return] systemd", |
| 325 | +추가: "files systemd [UNAVAIL=continue]", |
| 326 | +추가: "files files", |
| 327 | +추가: ] { |
| 328 | +추가: for policy in [ |
| 329 | +추가: format!("passwd: files\ngroup: {source}\n"), |
| 330 | +추가: format!("passwd: files\ngroup: files\ninitgroups: {source}\n"), |
| 331 | +추가: ] { |
| 332 | +추가: run_case_with_policy("personal", false, true, Some(&policy)); |
| 333 | +추가: } |
| 334 | +추가: } |
| 335 | +추가: run_case_with_policy( |
| 336 | +추가: "personal", |
| 337 | +추가: true, |
| 338 | +추가: true, |
| 339 | +추가: Some("passwd: files\ngroup: files\ninitgroups: files # local groups\n"), |
| 340 | +추가: ); |
| 341 | +추가: } |
| 342 | +추가: |
| 258 | 343 | #[test] |
| 259 | 344 | fn private_group_rejects_consumed_systemd_record_on_erange() { |
| 260 | 345 | // NSS 버퍼 재시도 대신 완전한 varlink 레코드를 직접 검사함. |