forked from Plemya-x/ALR
command info
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user