mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #40673 from kolyshkin/scan
Simplify daemon.overlaySupportsSelinux(), fix use of bufio.Scanner.Err()
This commit is contained in:
commit
f6163d3f7a
2 changed files with 5 additions and 19 deletions
|
@ -839,25 +839,14 @@ func overlaySupportsSelinux() (bool, error) {
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
var symAddr, symType, symName, text string
|
|
||||||
|
|
||||||
s := bufio.NewScanner(f)
|
s := bufio.NewScanner(f)
|
||||||
for s.Scan() {
|
for s.Scan() {
|
||||||
if err := s.Err(); err != nil {
|
if strings.HasSuffix(s.Text(), " security_inode_copy_up") {
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
text = s.Text()
|
|
||||||
if _, err := fmt.Sscanf(text, "%s %s %s", &symAddr, &symType, &symName); err != nil {
|
|
||||||
return false, fmt.Errorf("Scanning '%s' failed: %s", text, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for presence of symbol security_inode_copy_up.
|
|
||||||
if symName == "security_inode_copy_up" {
|
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false, nil
|
|
||||||
|
return false, s.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
// configureKernelSecuritySupport configures and validates security support for the kernel
|
// configureKernelSecuritySupport configures and validates security support for the kernel
|
||||||
|
|
|
@ -236,10 +236,6 @@ func parseSubidFile(path, username string) (ranges, error) {
|
||||||
|
|
||||||
s := bufio.NewScanner(subidFile)
|
s := bufio.NewScanner(subidFile)
|
||||||
for s.Scan() {
|
for s.Scan() {
|
||||||
if err := s.Err(); err != nil {
|
|
||||||
return rangeList, err
|
|
||||||
}
|
|
||||||
|
|
||||||
text := strings.TrimSpace(s.Text())
|
text := strings.TrimSpace(s.Text())
|
||||||
if text == "" || strings.HasPrefix(text, "#") {
|
if text == "" || strings.HasPrefix(text, "#") {
|
||||||
continue
|
continue
|
||||||
|
@ -260,5 +256,6 @@ func parseSubidFile(path, username string) (ranges, error) {
|
||||||
rangeList = append(rangeList, subIDRange{startid, length})
|
rangeList = append(rangeList, subIDRange{startid, length})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rangeList, nil
|
|
||||||
|
return rangeList, s.Err()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue