command info

This commit is contained in:
2025-04-13 17:49:02 +03:00
parent 3603dc45a4
commit 93d568ec00
5 changed files with 85 additions and 46 deletions

View File

@ -17,6 +17,8 @@
package utils
import (
"errors"
"log/slog"
"os"
"os/user"
"strconv"
@ -66,6 +68,24 @@ func DropCapsToAlrUser() error {
if err != nil {
return err
}
newUid := syscall.Getuid()
if newUid != uid {
return errors.New("new uid don't matches requested")
}
newGid := syscall.Getgid()
if newGid != gid {
return errors.New("new gid don't matches requested")
}
return nil
}
// Returns cli.Exit to
func ExitIfCantDropCapsToAlrUser() error {
err := DropCapsToAlrUser()
if err != nil {
slog.Debug("dropping capabilities error", "err", err)
return cli.Exit(gotext.Get("Error dropping capabilities"), 1)
}
return nil
}