Skip to content

Commit f62fdb1

Browse files
authored
fix(ec): fix check for kots bin path (#5716)
1 parent 0021ba8 commit f62fdb1

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

pkg/kotsutil/kots.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,12 +1521,17 @@ func LoadAirgapFromBytes(data []byte) (*kotsv1beta1.Airgap, error) {
15211521

15221522
func GetKOTSBinPath() string {
15231523
if util.PodNamespace != "" {
1524-
// we're inside the kotsadm pod, the kots binary exists at /kots
1525-
return "/kots"
1526-
} else {
1527-
// we're not inside the kotsadm pod, return the command used to run kots
1528-
return os.Args[0]
1524+
// check that we are inside a kubernetes pod
1525+
//nolint:gosec // G101: This is a standard Kubernetes service account token path, not a hardcoded credential
1526+
tokenFile := "/var/run/secrets/kubernetes.io/serviceaccount/token"
1527+
if _, err := os.Stat(tokenFile); err == nil {
1528+
// we're inside the kotsadm pod, the kots binary exists at /kots
1529+
return "/kots"
1530+
}
15291531
}
1532+
1533+
// we're not inside the kotsadm pod, return the command used to run kots
1534+
return os.Args[0]
15301535
}
15311536

15321537
func LoadBrandingArchiveFromPath(archivePath string) (*bytes.Buffer, error) {

0 commit comments

Comments
 (0)