Merge pull request #136404 from borg-land/nonewprivs-agnhost

add nonewprivs to agnhost
This commit is contained in:
Kubernetes Prow Robot
2026-01-22 22:47:29 +05:30
committed by GitHub
5 changed files with 47 additions and 1 deletions

View File

@@ -1 +1 @@
2.61
2.62.0

View File

@@ -42,6 +42,7 @@ import (
"k8s.io/kubernetes/test/images/agnhost/nettest"
nosnat "k8s.io/kubernetes/test/images/agnhost/no-snat-test"
nosnatproxy "k8s.io/kubernetes/test/images/agnhost/no-snat-test-proxy"
"k8s.io/kubernetes/test/images/agnhost/nonewprivs"
"k8s.io/kubernetes/test/images/agnhost/openidmetadata"
"k8s.io/kubernetes/test/images/agnhost/pause"
"k8s.io/kubernetes/test/images/agnhost/podcertificatesigner"
@@ -96,6 +97,7 @@ func main() {
rootCmd.AddCommand(podcertificatesigner.CmdPodCertificateSigner)
rootCmd.AddCommand(mtlsclient.CmdMtlsClient)
rootCmd.AddCommand(mtlsserver.CmdMtlsServer)
rootCmd.AddCommand(nonewprivs.CmdNoNewPrivs)
// NOTE(claudiub): Some tests are passing logging related flags, so we need to be able to
// accept them. This will also include them in the printed help.
code := cli.Run(rootCmd)

View File

@@ -0,0 +1,4 @@
approvers:
- mkumatag
emeritus_approvers:
- jessfraz

View File

@@ -0,0 +1,3 @@
# nonewprivs
A simple go app that prints the UID of the process running to test security context features.

View File

@@ -0,0 +1,37 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package nonewprivs
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
// CmdNoneNewPrivs is used by agnhost Cobra.
var CmdNoNewPrivs = &cobra.Command{
Use: "nonewprivs",
Short: "Prints the UID of the running process",
Long: `A go app that prints the UID of the process running to test security context features`,
Args: cobra.MaximumNArgs(0),
Run: main,
}
func main(cmd *cobra.Command, args []string) {
fmt.Printf("Effective uid: %d\n", os.Geteuid())
}