| 71 | } |
| 72 | |
| 73 | void ImpersonateUser(const TShellCommandOptions::TUserOptions& userOpts) { |
| 74 | if (GetUsername() == userOpts.Name) { |
| 75 | return; |
| 76 | } |
| 77 | const passwd* newUser = getpwnam(userOpts.Name.c_str()); |
| 78 | if (!newUser) { |
| 79 | ythrow TSystemError(errno) << "getpwnam failed"; |
| 80 | } |
| 81 | if (userOpts.UseUserGroups) { |
| 82 | SetUserGroups(newUser); |
| 83 | } |
| 84 | if (setuid(newUser->pw_uid)) { |
| 85 | ythrow TSystemError(errno) << "setuid failed"; |
| 86 | } |
| 87 | } |
| 88 | #elif defined(_win_) |
| 89 | constexpr static size_t MAX_COMMAND_LINE = 32 * 1024; |
| 90 |
no test coverage detected