Repository navigation
feat(id): add id - #288
feat(id): add id#288
Conversation
|
@strandly-the-agent Please review this PR |
strandly-the-agent
left a comment
There was a problem hiding this comment.
Approve. id matches GNU id on every flag combination and error I tried, it reports the same uid/gid (1000) the VFS already uses, and CI is green on every target. I found nothing blocking. There are three optional nits below the fold and one design question.
Question (non-blocking): USER=root id prints uid=1000(root) gid=1000(root) groups=1000(root) while id -u still prints 1000. GNU id derives the name from the uid and ignores $USER. Following $USER keeps id -un and whoami (#273) in agreement, which seems like the right trade, but the name and the number can now disagree. Is that intended?
✅ What I verified
- Head
ac10f8d.cargo test --test shell_integration id_ran 30 tests, 30 passed (that filter also matches some non-idtests). The reviewer pass ran the fullshell_integrationsuite: 1977 passed, 0 failed. Clippy shows nothing inid.rs. I didn't runcargo fmt --checkbecause rustfmt isn't installed here. - CI: every Rust/Python/Node target, the security audit, and the CI Gate are green on
ac10f8d. - Against GNU
id(coreutils 9.1), using the builtstrands-shell -c:id→uid=1000(lash) gid=1000(lash) groups=1000(lash), the same layout as GNU.id -un,id -nu,id -gnandid -u -ubehave the same as GNU.id -n→id: cannot print only names or real IDs in default format, exit 1. Same as GNU.id -u -g→id: cannot print "only" of more than one choice, exit 1. Same as GNU.[ "$(id -u)" -eq 0 ]is false, which is the use case in the PR description.USER= id -unandunset USER; id -unboth printlash.id -zandid lashexit 1. These options and operands are deliberately unsupported, as the description says.
- Identity consistency:
LASH_UID/LASH_GID(src/vfs.rs:14-15) are the ids the kernel uses for every permission check and new file.ls -ldoesn't print owners and there is nostat, so nothing else in the shell shows a name that could disagree.$UIDand$EUIDaren't set. - Command lists: both WASM lists are updated (
src/commands/mod.rslookup and thesrc/vfs.rs:830/binlist). Native builds register commands throughinventory. The README bump 33→34 matches.
Passes run
I ran a correctness/tests/docs reviewer pass (fresh context) plus my own build and GNU comparison. I didn't run an API bar-raiser pass because no public Rust/Python/Node API changed; the new surface is a shell command whose GNU behaviour I checked directly. I didn't run an adversarial pass because the only risky logic is a small lexopt loop, and the edge cases (--, --user=x, repeated flags, combined shorts) are covered in the verification above.
Appendix — non-blocking (3)
- ⚪ No test for the empty-
$USERfallback.src/commands/id.rs:46:Some(user) if !user.is_empty() =>. Deleting theif !user.is_empty()guard still passes everyid_test. One line afterid_unset_user(tests/shell_integration.rs:13633) would cover it:expect!(id_empty_user, "USER= id -un", "lash");
- ⚪
id_matches_whoami_userpasses by construction.tests/shell_integration.rs:13634-13638:[ "$(id -un)" = "$USER" ].idreads$USERitself, so this adds nothing beyondid_unandid_follows_user, andwhoamiisn't on main yet. Either drop it, or after #273 lands, make it a real cross-check:expect!(id_matches_whoami, "[ \"$(id -un)\" = \"$(whoami)\" ] && echo same", "same");
- ⚪ A third
"lash"literal.src/commands/id.rs:11:const DEFAULT_USER: &str = "lash";duplicatessrc/vfs_kernel.rs:291(env.insert("USER".into(), "lash".into())), and #273 adds the same constant inwhoami.rs. The PR description already plans this follow-up. Apub const LASH_USER: &str = "lash";next toLASH_UIDinsrc/vfs.rs:14would let all three share it.
Not from this PR:
- #273 and the hostname/uname PRs edit the same README count line and the same WASM
/binlist, so whichever merges later needs its count re-bumped. The description already flags this. - The command reference on strandsagents.com is in another repo and doesn't list
id; it will need a separate docs PR. - Pre-existing: the WASM
/binlist (src/vfs.rs:829-832) is missingcurlandsleep. This was noted on #273, and I'm not filing it separately.
|
Thanks. Pushed 70d7c3b: added the empty On The shared |
Description
There's no
id, so a script that checks whether it's running as root with[ "$(id -u)" -eq 0 ]gets command not found.This adds
idwith its default output plus-u,-g, and-n(so-unand-gnwork). It reports the shell's own user, never the host's: the uid and gid are the same 1000 the virtual filesystem already uses for file ownership, and the name is$USER(lashby default), the same namewhoamiprints. The group shares the user's name.-non its own and asking for both-uand-gare errors with GNU's messages. I left out-G,-r,-z, and looking up another user by name to keep this small; those are still errors. I also added it to the WASM command list and bumped the command count in the README.Related Issues
Part of #207
Documentation PR
Type of Change
New feature
Testing
I compared the output format and the error cases with GNU
id. The new tests cover the default output, each flag and combination, the user name variable, help, and the error cases. The full Rust suite passes and clippy has the same warnings as main. I didn't run the Python or Node suites because the bindings are unchanged. This is one of four small PRs addingwhoami,hostname,uname, andid; each stands on its own, but they touch the same command lists, so whichever lands later will need a trivial rebase. Oncewhoami(#273) and this one are both in, the shared default user name could move to one place.cargo test --workspace --all-targets,pytest tests/python,npm test)cargo fmtandcargo clippyChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.