mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-03 00:34:13 +02:00
Rename FS ID setting function
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user