Extend new syncuser handling for +/- entries

Since these lines are being omitted in the final sync'd passwd/group
file, a new message indicates that the line is being skipped; but it is
no longer denoted as a parse error.

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2024-07-02 14:34:19 -06:00
parent ba3c24e1c3
commit 0b765d242a
3 changed files with 6 additions and 3 deletions

View File

@@ -54,7 +54,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Changed
- Ignore +:::: lines in passwd/group during syncuser. #1286
- Explicitly ignore compat-style NIS lines in passwd/group during syncuser. #1286
## v4.5.4, 2024-06-12

View File

@@ -177,7 +177,8 @@ func (db syncDB) read(fileName string, fromContainer bool) error {
continue
}
// ignore ldap/nis/sssd line
if fields[0] == "+" {
if strings.HasPrefix(fields[0], "+") || strings.HasPrefix(fields[0], "-") {
wwlog.Verbose("Ignoring line %s (unhandled compat-style NIS reference)", line)
continue
}
id, err := strconv.Atoi(fields[2])

View File

@@ -275,11 +275,13 @@ func Test_network_passwd(t *testing.T) {
buf := new(bytes.Buffer)
wwlog.SetLogWriter(buf)
hostInput := `testuser1:x:1001:1001::/home/testuser:/bin/bash
+::::::`
+::::::
-::::::`
hostFileName := writeTempFile(t, hostInput)
defer os.Remove(hostFileName)
db := make(syncDB)
err := db.readFromHost(hostFileName)
assert.NotContains(t, buf.String(), "parse error")
assert.Contains(t, buf.String(), "Ignoring line")
assert.NoError(t, err)
}