I am getting a l bit in file permission sometimes but not regulaly When i create
file With int fd = open("\tmp\lockfile", O_CREAT | O_EXCL);. The O/P that i get in rare
scenario When i do ll \tmp\locfile is
root@cool> ll lockfile
---x--l--- 1 root nms 0 Feb 21 10:40 lockfile
root@cool>`
While most of the time O/P is this :-
root@cool> ll importer.lck
---------- 1 user nms 0 Feb 22 10:58 importer.lck`
I know creating file through O_CREAT While not providing the mode can be an issue as done
above can be an issue . In this case:-
root@cool> ll lockfile
---x--l--- 1 root nms 0 Feb 21 10:40 lockfile
root@cool>
i am not able to delete the lockfile once the process Which created this is over`.
chmod also does not work in above case but chown seems to work .
How can i prevent creating the file with these permission ---x--l--- is it just by passing mode ? The mask set is :-
root@cesme:/tmp# umask
0022
root@cesme:/tmp#`
You omitted the required third parameter of open(), which is mode. (The parameter is required when you use O_CREAT). Since there’s no parameter on the stack, open uses a random value (i.e. the return address on the stack).