From a6c2189a9875987b5140390bcf5f5f5907ea6c96 Mon Sep 17 00:00:00 2001 From: Alexandre Ferreira Date: Tue, 18 May 2021 14:45:08 -0500 Subject: [PATCH] Fix opening /dev/ to see if it is a directory (dangerous and it can take too long) --- main.go | 9 +++++++++ smarter-device-management-pod-k3s-test-xavier.yaml | 2 +- smarter-device-management-pod-k3s.yaml | 2 +- smarter-device-management-pod.yaml | 2 +- smarter-device-manager-ds-k3s.yaml | 2 +- smarter-device-manager-ds-with-configmap-rpi-k3s.yaml | 2 +- smarter-device-manager-ds-with-configmap-rpi.yaml | 2 +- smarter-device-manager-ds-with-configmap-xavier-k3s.yaml | 2 +- smarter-device-manager-ds-with-configmap-xavier.yaml | 2 +- smarter-device-manager-ds.yaml | 2 +- 10 files changed, 18 insertions(+), 9 deletions(-) diff --git a/main.go b/main.go index 88ca27c..351ddb4 100644 --- a/main.go +++ b/main.go @@ -58,6 +58,15 @@ func init() { func readDevDirectory(dirToList string) (files []string, err error) { var foundFiles []string + fType, err := os.Stat(dirToList) + if err != nil { + return nil, err + } + + if !fType.IsDir() { + return nil, nil + } + f, err := os.Open(dirToList) if err != nil { return nil, err diff --git a/smarter-device-management-pod-k3s-test-xavier.yaml b/smarter-device-management-pod-k3s-test-xavier.yaml index 0ca9aab..3997689 100644 --- a/smarter-device-management-pod-k3s-test-xavier.yaml +++ b/smarter-device-management-pod-k3s-test-xavier.yaml @@ -15,7 +15,7 @@ spec: nodeName: smarter-jetson-xavier-4bcc2584 containers: - name: smarter-device-manager - image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.5 + image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.6 imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false diff --git a/smarter-device-management-pod-k3s.yaml b/smarter-device-management-pod-k3s.yaml index 7a32d8a..e9a15bd 100644 --- a/smarter-device-management-pod-k3s.yaml +++ b/smarter-device-management-pod-k3s.yaml @@ -15,7 +15,7 @@ spec: nodeName: containers: - name: smarter-device-manager - image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.5 + image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.6 imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false diff --git a/smarter-device-management-pod.yaml b/smarter-device-management-pod.yaml index 2e5642c..a5ff8ea 100644 --- a/smarter-device-management-pod.yaml +++ b/smarter-device-management-pod.yaml @@ -15,7 +15,7 @@ spec: nodeName: containers: - name: smarter-device-manager - image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.5 + image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.6 imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false diff --git a/smarter-device-manager-ds-k3s.yaml b/smarter-device-manager-ds-k3s.yaml index 787d3f2..034a377 100644 --- a/smarter-device-manager-ds-k3s.yaml +++ b/smarter-device-manager-ds-k3s.yaml @@ -34,7 +34,7 @@ spec: dnsPolicy: ClusterFirstWithHostNet containers: - name: smarter-device-manager - image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.5 + image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.6 imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false diff --git a/smarter-device-manager-ds-with-configmap-rpi-k3s.yaml b/smarter-device-manager-ds-with-configmap-rpi-k3s.yaml index bb4869b..64e4897 100644 --- a/smarter-device-manager-ds-with-configmap-rpi-k3s.yaml +++ b/smarter-device-manager-ds-with-configmap-rpi-k3s.yaml @@ -34,7 +34,7 @@ spec: dnsPolicy: ClusterFirstWithHostNet containers: - name: smarter-device-manager - image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.5 + image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.6 imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false diff --git a/smarter-device-manager-ds-with-configmap-rpi.yaml b/smarter-device-manager-ds-with-configmap-rpi.yaml index 7be93e4..5ca4221 100644 --- a/smarter-device-manager-ds-with-configmap-rpi.yaml +++ b/smarter-device-manager-ds-with-configmap-rpi.yaml @@ -34,7 +34,7 @@ spec: dnsPolicy: ClusterFirstWithHostNet containers: - name: smarter-device-manager - image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.5 + image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.6 imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false diff --git a/smarter-device-manager-ds-with-configmap-xavier-k3s.yaml b/smarter-device-manager-ds-with-configmap-xavier-k3s.yaml index 9c63b71..daf2efe 100644 --- a/smarter-device-manager-ds-with-configmap-xavier-k3s.yaml +++ b/smarter-device-manager-ds-with-configmap-xavier-k3s.yaml @@ -34,7 +34,7 @@ spec: dnsPolicy: ClusterFirstWithHostNet containers: - name: smarter-device-manager - image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.5 + image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.6 imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false diff --git a/smarter-device-manager-ds-with-configmap-xavier.yaml b/smarter-device-manager-ds-with-configmap-xavier.yaml index 0bbe5ac..a451eae 100644 --- a/smarter-device-manager-ds-with-configmap-xavier.yaml +++ b/smarter-device-manager-ds-with-configmap-xavier.yaml @@ -34,7 +34,7 @@ spec: dnsPolicy: ClusterFirstWithHostNet containers: - name: smarter-device-manager - image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.5 + image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.6 imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false diff --git a/smarter-device-manager-ds.yaml b/smarter-device-manager-ds.yaml index 3ebf031..3682b7c 100644 --- a/smarter-device-manager-ds.yaml +++ b/smarter-device-manager-ds.yaml @@ -34,7 +34,7 @@ spec: dnsPolicy: ClusterFirstWithHostNet containers: - name: smarter-device-manager - image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.5 + image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.6 imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false