Page MenuHomeFreeBSD

Stop prepending prefix to the result of realpath(3).
ClosedPublic

Authored by kib on Fri, Jan 10, 2:13 PM.

Details

Summary

The path is already absolute.

Noted by: rstone

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

kib created this revision.Fri, Jan 10, 2:13 PM
rstone added inline comments.Fri, Jan 10, 2:26 PM
libexec/rtld-elf/rtld.c
5571 ↗(On Diff #66589)

This will change /foo/symlink to /bar/target where we didn't before. That's not an enormous deal, but realpath will fail within a capsicum sandbox as it needs to be able to stat every component of the path, including "/". I'd prefer to only use realpath on relative paths for this reason.

kib added inline comments.Fri, Jan 10, 2:48 PM
libexec/rtld-elf/rtld.c
5571 ↗(On Diff #66589)

So do you want realpath(3) at all there ?

kib added inline comments.Fri, Jan 10, 2:53 PM
libexec/rtld-elf/rtld.c
5571 ↗(On Diff #66589)

I can test with cap_getmode(2) and only call realpath if not in cap mode.

This is also a valid question for $ORIGIN resolution, where we use realpath(3) as well. See some minimal discussion with completely wrong patch at D23043.

kib updated this revision to Diff 66590.Fri, Jan 10, 2:54 PM

Do not use realpath() on abs path.

rstone accepted this revision.Fri, Jan 10, 4:35 PM
This revision is now accepted and ready to land.Fri, Jan 10, 4:35 PM
This revision was automatically updated to reflect the committed changes.