Rename FS ID setting function

This commit is contained in:
2020-04-07 16:01:40 +02:00
parent a3c3d3e59d
commit 21e70bc7cd
2 changed files with 7 additions and 8 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
#include <string>
namespace WriterUtils {
void set_process_effective_id(int user_id);
void set_fs_id(int user_id);
void create_destination_folder(const std::string& output_file);
}
+6 -7
View File
@@ -1,12 +1,11 @@
#include <iostream>
#include <unistd.h>
#include <sys/fsuid.h>
#include "WriterUtils.hpp"
#include "date.h"
using namespace std;
void WriterUtils::set_process_effective_id(int user_id)
void WriterUtils::set_fs_id(int user_id)
{
#ifdef DEBUG_OUTPUT
@@ -17,25 +16,25 @@ void WriterUtils::set_process_effective_id(int user_id)
cout << " Setting process user to " << user_id << endl;
#endif
if (setegid(user_id)) {
if (setfsgid(user_id)) {
stringstream err_msg;
using namespace date;
using namespace chrono;
err_msg << "[" << system_clock::now() << "]";
err_msg << "[WriterUtils::set_process_effective_id]";
err_msg << "[WriterUtils::set_fs_uid]";
err_msg << " Cannot set group_id to " << user_id << endl;
throw runtime_error(err_msg.str());
}
if (seteuid(user_id)) {
if (setfsuid(user_id)) {
stringstream err_msg;
using namespace date;
using namespace chrono;
err_msg << "[" << system_clock::now() << "]";
err_msg << "[WriterUtils::set_process_effective_id]";
err_msg << "[WriterUtils::set_fs_uid]";
err_msg << " Cannot set user_id to " << user_id << endl;
throw runtime_error(err_msg.str());