Merge pull request #1286 from mslacken/IgnoreNis

ignore +:: style lines in passwd/group
This commit is contained in:
Jonathon Anderson
2024-07-05 01:03:17 -06:00
committed by GitHub
3 changed files with 26 additions and 2 deletions

View File

@@ -52,6 +52,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fix the issue that new files created with wwctl overlay edit have 755 permissions. #1236
- Mount `/sys` and `/run` during `wwctl container exec`. #1287
### Changed
- Explicitly ignore compat-style NIS lines in passwd/group during syncuser. #1286
## v4.5.4, 2024-06-12
### Fixed

View File

@@ -176,13 +176,16 @@ func (db syncDB) read(fileName string, fromContainer bool) error {
if name == "" {
continue
}
// ignore ldap/nis/sssd line
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])
if err != nil {
wwlog.Warn("Ignoring line %s (parse error)", line)
continue
}
entry, ok := db[name]
if !ok {
entry = syncInfo{HostID: -1, ContainerID: -1}

View File

@@ -1,10 +1,12 @@
package container
import (
"bytes"
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/warewulf/warewulf/internal/pkg/wwlog"
)
func writeTempFile(t *testing.T, input string) string {
@@ -268,3 +270,18 @@ func Test_malformed_passwd(t *testing.T) {
err := db.readFromHost(hostFileName)
assert.NoError(t, err)
}
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)
}