Tim Kathete Stadler
Tim Kathete Stadler

Reputation: 1069

Can't grant others write access to my via open() created file

I am creating a file on linux using open()

mode_t perms = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
int i = open(settingsPath.c_str(), O_CREAT | O_RDWR, perms);

As you can see I am specifiying Read/Write permissions for everyone. But when I inspect the permissions in a terminal it says

-rw-rw-r-- 1 tstadler tstadler    0 Apr 17 10:54 settings.json

Why can't I give everyone write permissions?

Upvotes: 0

Views: 54

Answers (1)

apangin
apangin

Reputation: 98284

Looks like write permissions to everyone are masked by current process' umask.
See man 2 umask

Upvotes: 2

Related Questions