Simon Van den Bossche
Simon Van den Bossche

Reputation: 85

Can not overwrite file on linux

I want to overwrite a file with restricted permissions.

la -l on the file:

-r--rw-r-- 1 simon filesystem 77 nov 27 17:56 00041_Alarm

I want to do it with the following executable (written in c++). The executable has the following permissions:

-rwxrwsr-x 1 simon filesystem 286296 nov 28 16:28 project_file*

I've set the sgid bit on the executable, I thought that meant that the executable ran as the group filesystem and that I could write file with that group.

I open the file and test if it's open but it prints a 0, so not open:

std::ofstream file(filepath, std::ios::out | std::ios::binary | std::ofstream::trunc);
std::cout << file.is_open() << std::endl;

Upvotes: 1

Views: 68

Answers (0)

Related Questions