Skip to content

Commit

Permalink
rollback to 1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Emman committed Dec 3, 2021
1 parent f472607 commit 54ee9c6
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions smx509/root_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package smx509

import (
"io/fs"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -34,7 +34,7 @@ func loadSystemRoots() (*CertPool, error) {

var firstErr error
for _, file := range files {
data, err := os.ReadFile(file)
data, err := ioutil.ReadFile(file)
if err == nil {
roots.AppendCertsFromPEM(data)
break
Expand Down Expand Up @@ -62,7 +62,7 @@ func loadSystemRoots() (*CertPool, error) {
continue
}
for _, fi := range fis {
data, err := os.ReadFile(directory + "/" + fi.Name())
data, err := ioutil.ReadFile(directory + "/" + fi.Name())
if err == nil {
roots.AppendCertsFromPEM(data)
}
Expand All @@ -76,28 +76,28 @@ func loadSystemRoots() (*CertPool, error) {
return nil, firstErr
}

// readUniqueDirectoryEntries is like os.ReadDir but omits
// readUniqueDirectoryEntries is like ioutil.ReadDir but omits
// symlinks that point within the directory.
func readUniqueDirectoryEntries(dir string) ([]fs.DirEntry, error) {
files, err := os.ReadDir(dir)
func readUniqueDirectoryEntries(dir string) ([]os.FileInfo, error) {
fis, err := ioutil.ReadDir(dir)
if err != nil {
return nil, err
}
uniq := files[:0]
for _, f := range files {
if !isSameDirSymlink(f, dir) {
uniq = append(uniq, f)
uniq := fis[:0]
for _, fi := range fis {
if !isSameDirSymlink(fi, dir) {
uniq = append(uniq, fi)
}
}
return uniq, nil
}

// isSameDirSymlink reports whether fi in dir is a symlink with a
// target not containing a slash.
func isSameDirSymlink(f fs.DirEntry, dir string) bool {
if f.Type()&fs.ModeSymlink == 0 {
func isSameDirSymlink(fi os.FileInfo, dir string) bool {
if fi.Mode()&os.ModeSymlink == 0 {
return false
}
target, err := os.Readlink(filepath.Join(dir, f.Name()))
target, err := os.Readlink(filepath.Join(dir, fi.Name()))
return err == nil && !strings.Contains(target, "/")
}
}

0 comments on commit 54ee9c6

Please sign in to comment.