This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/17523] open() and openat() ignore 'mode' with O_TMPFILE


https://sourceware.org/bugzilla/show_bug.cgi?id=17523

--- Comment #7 from Eric Rannaud <e at nanocritical dot com> ---
(In reply to Florian Weimer from comment #6)
> >     fd = open("/path/to/dir", O_TMPFILE|O_WRONLY, 0600);
> >     snprintf(path, PATH_MAX,  "/proc/self/fd/%d", fd);
> >     linkat(AT_FDCWD, path, AT_FDCWD, "/path/for/file", AT_SYMLINK_FOLLOW);
> 
> Why would anyone want to do this instead of opening /path/for/file directly
> with O_CREATE|O_EXCL?

An interesting application would set stricter permissions after open and before
linkat, such as:

    fsetxattr(fd, "security.selinux", ...)

This being said, I don't know if there any real users at this point. The need
for linkat on a mounted /proc (as opposed to a hypothetical flink(2)) appears
to make people think twice.

Samba people are looking to use this feature to emulate a regular open(O_CREAT)
that can atomically set ACLs before making the file visible in the filesystem:

https://lkml.org/lkml/2014/10/31/119
https://lkml.org/lkml/2014/11/3/843

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]