Esempio n. 1
0
func ensureNoPrivs() error {
	if IsRoot() {
		return errors.New("still have non-zero UID or GID or capabilities")
	}

	err := setuid.Setuid(0)
	if err == nil {
		return errors.New("Can't drop privileges - setuid(0) still succeeded")
	}

	err = setuid.Setgid(0)
	if err == nil {
		return errors.New("Can't drop privileges - setgid(0) still succeeded")
	}

	return nil
}
Esempio n. 2
0
func ensureNoPrivs() error {
	if isRoot() {
		return errors.New("still have non-zero UID or GID")
	}

	err := setuid.Setuid(0)
	if err == nil {
		return errors.New("Can't drop privileges - setuid(0) still succeeded")
	}

	err = setuid.Setgid(0)
	if err == nil {
		return errors.New("Can't drop privileges - setgid(0) still succeeded")
	}

	if caps.HaveAny() {
		return errors.New("Still have some capabilities after attempting to drop them")
	}

	return nil
}