mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 22:17:14 +00:00
Add ownership inspection to mount tester image
This commit is contained in:
parent
b896a66679
commit
2ff043e75f
@ -3,6 +3,7 @@ concurrent_rc_syncs
|
||||
etcd_mutation_timeout
|
||||
file_content
|
||||
file_mode
|
||||
file_owner
|
||||
file_perm
|
||||
fs_type
|
||||
gke_context
|
||||
@ -12,6 +13,7 @@ kube_master_url
|
||||
max_in_flight
|
||||
max_par
|
||||
new_file_0644
|
||||
new_file_0660
|
||||
new_file_0666
|
||||
new_file_0777
|
||||
pods_per_node
|
||||
|
@ -12,5 +12,5 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM gcr.io/google_containers/mounttest:0.4
|
||||
FROM gcr.io/google_containers/mounttest:0.5
|
||||
USER 1001
|
||||
|
@ -1,6 +1,6 @@
|
||||
all: push
|
||||
|
||||
TAG = 0.2
|
||||
TAG = 0.3
|
||||
|
||||
image:
|
||||
sudo docker build -t gcr.io/google_containers/mounttest-user:$(TAG) .
|
||||
|
@ -1,6 +1,6 @@
|
||||
all: push
|
||||
|
||||
TAG = 0.4
|
||||
TAG = 0.5
|
||||
|
||||
mt: mt.go
|
||||
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-w' ./mt.go
|
||||
|
@ -29,8 +29,10 @@ var (
|
||||
fsTypePath = ""
|
||||
fileModePath = ""
|
||||
filePermPath = ""
|
||||
fileOwnerPath = ""
|
||||
newFilePath0644 = ""
|
||||
newFilePath0666 = ""
|
||||
newFilePath0660 = ""
|
||||
newFilePath0777 = ""
|
||||
readFileContentPath = ""
|
||||
readFileContentInLoopPath = ""
|
||||
@ -41,8 +43,10 @@ func init() {
|
||||
flag.StringVar(&fsTypePath, "fs_type", "", "Path to print the fs type for")
|
||||
flag.StringVar(&fileModePath, "file_mode", "", "Path to print the mode bits of")
|
||||
flag.StringVar(&filePermPath, "file_perm", "", "Path to print the perms of")
|
||||
flag.StringVar(&fileOwnerPath, "file_owner", "", "Path to print the owning UID and GID of")
|
||||
flag.StringVar(&newFilePath0644, "new_file_0644", "", "Path to write to and read from with perm 0644")
|
||||
flag.StringVar(&newFilePath0666, "new_file_0666", "", "Path to write to and read from with perm 0666")
|
||||
flag.StringVar(&newFilePath0660, "new_file_0660", "", "Path to write to and read from with perm 0660")
|
||||
flag.StringVar(&newFilePath0777, "new_file_0777", "", "Path to write to and read from with perm 0777")
|
||||
flag.StringVar(&readFileContentPath, "file_content", "", "Path to read the file content from")
|
||||
flag.StringVar(&readFileContentInLoopPath, "file_content_in_loop", "", "Path to read the file content in loop from")
|
||||
@ -86,6 +90,11 @@ func main() {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
err = readWriteNewFile(newFilePath0660, 0660)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
err = readWriteNewFile(newFilePath0777, 0777)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
@ -101,6 +110,11 @@ func main() {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
err = fileOwner(fileOwnerPath)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
err = readFileContent(readFileContentPath)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
@ -171,6 +185,22 @@ func filePerm(path string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func fileOwner(path string) error {
|
||||
if path == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
buf := syscall.Stat_t{}
|
||||
if err := syscall.Stat(path, &buf); err != nil {
|
||||
fmt.Printf("error from stat(%q): %v\n", path, err)
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("owner UID of %q: %v\n", path, buf.Uid)
|
||||
fmt.Printf("owner GID of %q: %v\n", path, buf.Gid)
|
||||
return nil
|
||||
}
|
||||
|
||||
func readFileContent(path string) error {
|
||||
if path == "" {
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user