Skip to content

Add _CS_PATH abd _PATH_* constants to Solaris and Illumos - #5690

Open
asder8215 wants to merge 2 commits into
rust-lang:mainfrom
asder8215:solaris_paths_consts
Open

asder8215 wants to merge 2 commits into
rust-lang:mainfrom
asder8215:solaris_paths_consts

Conversation

@asder8215

@asder8215 asder8215 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

From @psumbera's comment here: rust-lang/rust#157144 (comment)

Solaris defines _PATH_BSHELL in <paths.h> as "/usr/bin/sh", but it does not define _PATH_DEFPATH.

For rust-lang/libc, it would be useful to add both Solaris _PATH_BSHELL and _CS_PATH (65). One caveat: the existing Rust Solaris confstr binding links to __confstr_xpg7, whereas Solaris execvp uses the mode-sensitive base confstr. Thus simply adding Solaris to the existing libc::confstr branch would select the XPG7 path and would not exactly reproduce current execvp behavior.

Oracle's documentation also confirms that the ENOEXEC shell depends on the caller's conformance mode: execvp(2) and standards(7).

From the rustc book, it seems like we only support Solaris targets running on Solaris 11.4. I assume that means that we don't need to worry about the mode-sensitive based confstr?

I also realized I forgot to check Illumos for how they handle _PATH_BSHELL/_PATH_DEFPATH. They have both a _PATH_DEFPATH, which uses "/usr/ccs/bin:/usr/bin:/bin", and a _PATH_BSHELL, which the value of _PATH_BSHELL is consistent with what @psumbera said. You can see the value it's set to in usr/src/head/paths.h; the _PATH_BSHELL is used in its execvp implementation in usr/src/lib/libc/port/gen/execvp.c (which also seems consistent with what @psumbera said!).

Since both use the same _PATH_BSHELL and _CS_PATH I put it in the solarish/mod.rs file. I hope that's fine?

Please let me know if I'm misunderstanding anything or if there are any issues with this PR @psumbera

Edit: _PATH_DEFPATH exists on illumos (missed it earlier).

@rustbot

rustbot commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in a solarish module

cc @jclulow, @pfmooney

@psumbera

psumbera commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

The code changes look correct to me. _CS_PATH has the same value on Solaris and illumos, and both define _PATH_BSHELL as "/usr/bin/sh", so placing them in solarish/mod.rs makes sense.

Two small corrections to the description:

  1. Supporting Solaris 11.4 does not mean that mode-sensitive confstr behavior can be ignored. The default and XPG conformance modes both exist on Solaris 11.4. This does not affect adding _CS_PATH, since _CS_PATH is only the numeric selector; the selected confstr symbol/process mode determines the returned value.
  2. illumos does define _PATH_DEFPATH, currently as "/usr/ccs/bin:/usr/bin:/bin" (paths.h). Its execvp implementation does not use that constant directly for the unset-PATH fallback, however, so it is not needed for this particular change.

@asder8215

asder8215 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author
  1. illumos does define _PATH_DEFPATH, currently as "/usr/ccs/bin:/usr/bin:/bin" (paths.h). Its execvp implementation does not use that constant directly for the unset-PATH fallback, however, so it is not needed for this particular change.

You're right, I missed that.

I'll add it _PATH_DEFPATH just for consistency with other platforms.

@asder8215 asder8215 changed the title Add _PATH_BSHELL to Solaris and Illumos; add _CS_PATH to Solaris as well Add some constants to to Solaris and Illumos Nov 5, 2026
@asder8215
asder8215 force-pushed the solaris_paths_consts branch from 5729c27 to 9a260f2 Compare November 5, 2026 19:11
@rustbot

rustbot commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@asder8215 asder8215 changed the title Add some constants to to Solaris and Illumos Add _CS_PATH abd PATH_* constants to Solaris and Illumos Nov 5, 2026
@asder8215 asder8215 changed the title Add _CS_PATH abd PATH_* constants to Solaris and Illumos Add _CS_PATH abd _PATH_* constants to Solaris and Illumos Nov 5, 2026
@asder8215

Copy link
Copy Markdown
Contributor Author

Completely forgot to do this
@rustbot label stable-nominated

@rustbot rustbot added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Nov 7, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-illumos O-solarish O-unix S-waiting-on-review stable-nominated This PR should be considered for cherry-pick to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants