Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use filepath instead of path #188

Merged
merged 1 commit into from
Oct 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions go-selinux/selinux_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"math/big"
"os"
"os/user"
"path"
"path/filepath"
"strconv"
"strings"
Expand Down Expand Up @@ -461,10 +460,10 @@ func attrPath(attr string) string {
})

if haveThreadSelf {
return path.Join(threadSelfPrefix, attr)
return filepath.Join(threadSelfPrefix, attr)
}

return path.Join("/proc/self/task/", strconv.Itoa(unix.Gettid()), "/attr/", attr)
return filepath.Join("/proc/self/task", strconv.Itoa(unix.Gettid()), "attr", attr)
}

func readAttr(attr string) (string, error) {
Expand Down Expand Up @@ -815,7 +814,7 @@ func reserveLabel(label string) {
}

func selinuxEnforcePath() string {
return path.Join(getSelinuxMountPoint(), "enforce")
return filepath.Join(getSelinuxMountPoint(), "enforce")
}

// enforceMode returns the current SELinux mode Enforcing, Permissive, Disabled
Expand Down Expand Up @@ -940,7 +939,7 @@ func openContextFile() (*os.File, error) {
if f, err := os.Open(contextFile); err == nil {
return f, nil
}
return os.Open(filepath.Join(policyRoot(), "/contexts/lxc_contexts"))
return os.Open(filepath.Join(policyRoot(), "contexts", "lxc_contexts"))
}

func loadLabels() {
Expand Down Expand Up @@ -1043,7 +1042,7 @@ func addMcs(processLabel, fileLabel string) (string, string) {

// securityCheckContext validates that the SELinux label is understood by the kernel
func securityCheckContext(val string) error {
return os.WriteFile(path.Join(getSelinuxMountPoint(), "context"), []byte(val), 0o644)
return os.WriteFile(filepath.Join(getSelinuxMountPoint(), "context"), []byte(val), 0o644)
}

// copyLevel returns a label with the MLS/MCS level from src label replaced on
Expand Down