Page MenuHomeFreeBSD

Add mkostempsat(3).
ClosedPublic

Authored by markj on Jul 22 2019, 8:30 PM.

Details

Summary

This is a variant of mkostemps() which takes a directory descriptor and
returns a descriptor for a file relative to that directory. This allows
easier capsicumization of some applications.

My particular use-case is strip(1), which processes each of its input
files, storing the result in a tempfile, and renames each tempfile back
over the corresponding input file.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

markj created this revision.Jul 22 2019, 8:30 PM
markj edited the summary of this revision. (Show Details)Jul 22 2019, 8:31 PM
markj added reviewers: brooks, oshogbo, emaste, capsicum.
brooks added inline comments.Jul 22 2019, 10:23 PM
lib/libc/stdio/mktemp.c
163 ↗(On Diff #60032)

Does there need to be a AT_FDCWD case here to match the manpage?

cem added a subscriber: cem.Jul 22 2019, 11:10 PM

LGTM other than the issue brooks noticed.

lib/libc/stdio/mktemp.c
163 ↗(On Diff #60032)

Yes, I think so.

markj updated this revision to Diff 60036.Jul 23 2019, 1:53 AM
  • Use AT_FDCWD when no relative dfd is specified.
  • Add a man page mlink.
markj marked 2 inline comments as done.Jul 23 2019, 1:53 AM
markj added inline comments.
lib/libc/stdio/mktemp.c
163 ↗(On Diff #60032)

The new block isn't really needed at all. The non-"at" mktemp functions can specify AT_FDCWD as the directory fd, which lets me get rid of the branches that I had added.

cem accepted this revision.Jul 23 2019, 5:36 AM
cem added inline comments.
lib/libc/stdio/mktemp.c
163–164 ↗(On Diff #60036)

Seems like a weird spelling of strrchr? Preexisting issue.

This revision is now accepted and ready to land.Jul 23 2019, 5:36 AM
markj marked an inline comment as done.Jul 23 2019, 1:47 PM
markj added inline comments.
lib/libc/stdio/mktemp.c
163–164 ↗(On Diff #60036)

Yeah. I'm also not sure why exactly we need this check in the first place.

This revision was automatically updated to reflect the committed changes.