-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
k8s: allow to configure logs permissions on k8s deployments
Add the TETRAGON_LOGS_PERM environment variable so we can configure the export logs permissions. It has some sanity checks to ensure that tetragon can read/write the logs. Signed-off-by: Djalal Harouni <tixxdz@gmail.com>
- Loading branch information
Showing
6 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Authors of Tetragon | ||
package fileutils | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strconv" | ||
) | ||
|
||
// RegularFilePerms() takes an octal string representation and returns | ||
// a FileMode permission and after applying a mask on it and nil if no | ||
// errors. | ||
// | ||
// If the string can not be parsed into a 32 bit unsigned octal, or if | ||
// the passed string is not for a regular file then an error is returned, | ||
// and the default secure file mode always returned. | ||
// | ||
// The default secure mode is 0600 | ||
func RegularFilePerms(s string, requiredMask os.FileMode, avoidMask os.FileMode) (os.FileMode, error) { | ||
secure := os.FileMode(0100600) | ||
if s == "" { | ||
return secure, fmt.Errorf("failed passed permissions are empty") | ||
} | ||
|
||
n, err := strconv.ParseUint(s, 8, 32) | ||
if err != nil { | ||
return secure, err | ||
} | ||
|
||
mode := os.FileMode(n) | ||
if mode.IsRegular() == false { | ||
return secure, nil | ||
} | ||
|
||
if avoidMask != 0 { | ||
mode &= ^avoidMask | ||
} | ||
|
||
mode |= requiredMask | ||
return mode, nil | ||
} |