become_user.h 829 B

1234567891011121314151617181920212223242526
  1. #pragma once
  2. #include <util/generic/string.h>
  3. namespace NYql {
  4. // works on Linux only
  5. // assume we have enough capabilities to do so: CAP_SETUID, CAP_SETGID
  6. void BecomeUser(const TString& username, const TString& groupname);
  7. // should be called by root (more specifically caps required: CAP_SETPCAP)
  8. // special ambient capabilities will be set up: CAP_SETUID, CAP_SETGID, CAP_KILL
  9. // they will be preserved by fork and exec*
  10. void TurnOnBecomeUserAmbientCaps();
  11. // forget ambient capabilities and ensure we cannot setuid to root
  12. void TurnOffBecomeUserAbility();
  13. // dump to stderr current secirity context incluing uid/guid/caps
  14. void DumpCaps(const TString& title);
  15. // subscribe child process on receiving signal on parent process death (particularly on parent thread exit)
  16. void SendSignalOnParentThreadExit(int signo);
  17. }