Page MenuHomeFreeBSD

md5: Accept "-" as alias for stdin.
ClosedPublic

Authored by des on Feb 13 2024, 8:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 20, 11:57 PM
Unknown Object (File)
Fri, Apr 19, 2:05 PM
Unknown Object (File)
Fri, Apr 19, 11:58 AM
Unknown Object (File)
Mar 21 2024, 3:45 AM
Unknown Object (File)
Feb 18 2024, 12:35 AM
Unknown Object (File)
Feb 16 2024, 6:02 PM
Unknown Object (File)
Feb 16 2024, 12:51 PM

Details

Summary

PR: 276915
Reported by: Hannes Hauswedell <h2+fbsdports@fsfe.org>

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

des requested review of this revision.Feb 13 2024, 8:48 PM

Note, this is a superset of @jhb's D43807

allanjude added a subscriber: allanjude.

I could have sworn it did this already.

Reviewed-by: allanjude

This revision is now accepted and ready to land.Feb 14 2024, 1:57 PM

I could have sworn it did this already.

You're probably thinking of D43532

markj added inline comments.
sbin/md5/md5.c
633

It's not obvious to me that we want to limit rights on stdin as well (we might want CAP_IOCTL as well, for instance). Do the tests all pass when the kern.trap_enotcap sysctl is set to 1?

sbin/md5/md5.c
633

Presumably it should also work if e.g. the user passes /dev/stdin as a file; I think it should be OK to apply the same &rights to files and stdin (even if more rights may be needed in the list)

des marked 2 inline comments as done.Feb 14 2024, 3:43 PM
des added inline comments.
sbin/md5/md5.c
633

Normally for stdin we'd call caph_limit_stdin() which is _more_ restrictive than what we're asking for here, so it's fine.

markj added inline comments.
sbin/md5/md5.c
633

I think that's backwards? caph_limit_stdin() is less restrictive, e.g., because it includes CAP_IOCTL.

In any case, I think this caph_rights_limit() call was useless before - we pass the rights to fileargs_open(), so they're applied automatically. We don't need to call it again here.

I would suggest removing this call outright and replacing the existing caph_limit_stdout/stderr() calls with a caph_limit_stdio() call. We're still left with inconsistent behaviour for the /dev/stdin case as emaste mentioned, but that's probably harmless.

I agree with Mark's comments on cap_rights_limit, though I think that's also an orthogonal fix.

des marked an inline comment as done.Feb 14 2024, 7:44 PM
des added inline comments.
sbin/md5/md5.c
633

See D43897

This revision was automatically updated to reflect the committed changes.