aboutsummaryrefslogtreecommitdiffstats
path: root/util/system
diff options
context:
space:
mode:
authorsnowball <snowball@yandex-team.ru>2022-02-10 16:46:32 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:32 +0300
commit4d57126b1bae3cfd0f4f95c32d1a85ca684ee92c (patch)
tree9aa76172d0e8abdf7c78fce6ec639c5d7e62b459 /util/system
parent249e91c445cb92462f9509d1ef2730b27629f43d (diff)
downloadydb-4d57126b1bae3cfd0f4f95c32d1a85ca684ee92c.tar.gz
Restoring authorship annotation for <snowball@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/system')
-rw-r--r--util/system/benchmark/cpu_id/metrics/ya.make2
-rw-r--r--util/system/benchmark/create_destroy_thread/metrics/ya.make2
-rw-r--r--util/system/fstat.cpp10
-rw-r--r--util/system/shellcommand.cpp46
-rw-r--r--util/system/shellcommand.h32
5 files changed, 46 insertions, 46 deletions
diff --git a/util/system/benchmark/cpu_id/metrics/ya.make b/util/system/benchmark/cpu_id/metrics/ya.make
index 8c55def99b..b15a3230a0 100644
--- a/util/system/benchmark/cpu_id/metrics/ya.make
+++ b/util/system/benchmark/cpu_id/metrics/ya.make
@@ -9,7 +9,7 @@ PY2TEST()
SIZE(LARGE)
TAG(
- ya:force_sandbox
+ ya:force_sandbox
sb:intel_e5_2660v1
ya:fat
)
diff --git a/util/system/benchmark/create_destroy_thread/metrics/ya.make b/util/system/benchmark/create_destroy_thread/metrics/ya.make
index d526487e1a..92a8b5752f 100644
--- a/util/system/benchmark/create_destroy_thread/metrics/ya.make
+++ b/util/system/benchmark/create_destroy_thread/metrics/ya.make
@@ -9,7 +9,7 @@ PY2TEST()
SIZE(LARGE)
TAG(
- ya:force_sandbox
+ ya:force_sandbox
sb:intel_e5_2660v1
ya:fat
)
diff --git a/util/system/fstat.cpp b/util/system/fstat.cpp
index 81e98cbc6b..ea87835fc7 100644
--- a/util/system/fstat.cpp
+++ b/util/system/fstat.cpp
@@ -15,7 +15,7 @@
#endif
#define _S_IFLNK 0x80000000
-ui32 GetFileMode(DWORD fileAttributes) {
+ui32 GetFileMode(DWORD fileAttributes) {
ui32 mode = 0;
if (fileAttributes == 0xFFFFFFFF)
return mode;
@@ -23,14 +23,14 @@ ui32 GetFileMode(DWORD fileAttributes) {
mode |= _S_IFCHR;
if (fileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
mode |= _S_IFLNK; // todo: was undefined by the moment of writing this code
- if (fileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ if (fileAttributes & FILE_ATTRIBUTE_DIRECTORY)
mode |= _S_IFDIR;
if (fileAttributes & (FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_ARCHIVE))
mode |= _S_IFREG;
if ((fileAttributes & FILE_ATTRIBUTE_READONLY) == 0)
mode |= _S_IWRITE;
return mode;
-}
+}
#define S_ISDIR(st_mode) (st_mode & _S_IFDIR)
#define S_ISREG(st_mode) (st_mode & _S_IFREG)
@@ -42,8 +42,8 @@ using TSystemFStat = BY_HANDLE_FILE_INFORMATION;
using TSystemFStat = struct stat;
-#endif
-
+#endif
+
static void MakeStat(TFileStat& st, const TSystemFStat& fs) {
#ifdef _unix_
st.Mode = fs.st_mode;
diff --git a/util/system/shellcommand.cpp b/util/system/shellcommand.cpp
index b1989b5c8c..d071d8a4b3 100644
--- a/util/system/shellcommand.cpp
+++ b/util/system/shellcommand.cpp
@@ -28,11 +28,11 @@ using TPid = pid_t;
using TWaitResult = pid_t;
using TExitStatus = int;
#define WAIT_PROCEED 0
-
+
#if defined(_darwin_)
-using TGetGroupListGid = int;
+using TGetGroupListGid = int;
#else
-using TGetGroupListGid = gid_t;
+using TGetGroupListGid = gid_t;
#endif
#elif defined(_win_)
#include <string>
@@ -57,31 +57,31 @@ namespace {
constexpr static size_t DATA_BUFFER_SIZE = 128 * 1024;
#if defined(_unix_)
- void SetUserGroups(const passwd* pw) {
- int ngroups = 1;
+ void SetUserGroups(const passwd* pw) {
+ int ngroups = 1;
THolder<gid_t, TFree> groups = THolder<gid_t, TFree>(static_cast<gid_t*>(malloc(ngroups * sizeof(gid_t))));
- if (getgrouplist(pw->pw_name, pw->pw_gid, reinterpret_cast<TGetGroupListGid*>(groups.Get()), &ngroups) == -1) {
- groups.Reset(static_cast<gid_t*>(malloc(ngroups * sizeof(gid_t))));
- if (getgrouplist(pw->pw_name, pw->pw_gid, reinterpret_cast<TGetGroupListGid*>(groups.Get()), &ngroups) == -1) {
- ythrow TSystemError() << "getgrouplist failed: user " << pw->pw_name << " (" << pw->pw_uid << ")";
- }
- }
- if (setgroups(ngroups, groups.Get()) == -1) {
- ythrow TSystemError(errno) << "Unable to set groups for user " << pw->pw_name << Endl;
- }
- }
-
- void ImpersonateUser(const TShellCommandOptions::TUserOptions& userOpts) {
- if (GetUsername() == userOpts.Name) {
+ if (getgrouplist(pw->pw_name, pw->pw_gid, reinterpret_cast<TGetGroupListGid*>(groups.Get()), &ngroups) == -1) {
+ groups.Reset(static_cast<gid_t*>(malloc(ngroups * sizeof(gid_t))));
+ if (getgrouplist(pw->pw_name, pw->pw_gid, reinterpret_cast<TGetGroupListGid*>(groups.Get()), &ngroups) == -1) {
+ ythrow TSystemError() << "getgrouplist failed: user " << pw->pw_name << " (" << pw->pw_uid << ")";
+ }
+ }
+ if (setgroups(ngroups, groups.Get()) == -1) {
+ ythrow TSystemError(errno) << "Unable to set groups for user " << pw->pw_name << Endl;
+ }
+ }
+
+ void ImpersonateUser(const TShellCommandOptions::TUserOptions& userOpts) {
+ if (GetUsername() == userOpts.Name) {
return;
}
- const passwd* newUser = getpwnam(userOpts.Name.c_str());
+ const passwd* newUser = getpwnam(userOpts.Name.c_str());
if (!newUser) {
ythrow TSystemError(errno) << "getpwnam failed";
}
- if (userOpts.UseUserGroups) {
- SetUserGroups(newUser);
- }
+ if (userOpts.UseUserGroups) {
+ SetUserGroups(newUser);
+ }
if (setuid(newUser->pw_uid)) {
ythrow TSystemError(errno) << "setuid failed";
}
@@ -727,7 +727,7 @@ void TShellCommand::TImpl::OnFork(TPipes& pipes, sigset_t oldmask, char* const*
}
if (!User.Name.empty()) {
- ImpersonateUser(User);
+ ImpersonateUser(User);
}
if (Nice) {
diff --git a/util/system/shellcommand.h b/util/system/shellcommand.h
index 8730627fe5..977fa538cb 100644
--- a/util/system/shellcommand.h
+++ b/util/system/shellcommand.h
@@ -21,14 +21,14 @@ public:
#if defined(_win_)
TString Password;
#endif
-#if defined(_unix_)
- /**
- * Run child process with the user supplementary groups.
- * If true, the user supplementary groups will be set in the child process upon exec().
- * If false, the supplementary groups of the parent process will be used.
- */
- bool UseUserGroups = false;
-#endif
+#if defined(_unix_)
+ /**
+ * Run child process with the user supplementary groups.
+ * If true, the user supplementary groups will be set in the child process upon exec().
+ * If false, the supplementary groups of the parent process will be used.
+ */
+ bool UseUserGroups = false;
+#endif
};
enum EHandleMode {
@@ -66,7 +66,7 @@ public:
}
/**
- * @brief clear signal mask from parent process. If true, child process
+ * @brief clear signal mask from parent process. If true, child process
* clears the signal mask inherited from the parent process; otherwise
* child process retains the signal mask of the parent process.
*
@@ -80,7 +80,7 @@ public:
}
/**
- * @brief set close-on-exec mode. If true, all file descriptors
+ * @brief set close-on-exec mode. If true, all file descriptors
* from the parent process, except stdin, stdout, stderr, will be closed
* in the child process upon exec().
*
@@ -415,22 +415,22 @@ public:
TProcessId GetPid() const;
/**
- * @brief return the file handle that provides input to the child process
- *
+ * @brief return the file handle that provides input to the child process
+ *
* @return input file handle
*/
TFileHandle& GetInputHandle();
/**
- * @brief return the file handle that provides output from the child process
- *
+ * @brief return the file handle that provides output from the child process
+ *
* @return output file handle
*/
TFileHandle& GetOutputHandle();
/**
- * @brief return the file handle that provides error output from the child process
- *
+ * @brief return the file handle that provides error output from the child process
+ *
* @return error file handle
*/
TFileHandle& GetErrorHandle();