Skip to content

killUser: Don't fail if child kills itself - #99

Closed
shlevy wants to merge 1 commit into
NixOS:masterfrom
shlevy:allow-kill-self
Closed

shlevy wants to merge 1 commit into
NixOS:masterfrom
shlevy:allow-kill-self

Conversation

@shlevy

@shlevy shlevy commented Mar 12, 2013

Copy link
Copy Markdown
Member

POSIX doesn't specify that kill(-1, signo) doesn't kill the calling
process, and in fact on darwin it does.

POSIX doesn't specify that kill(-1, signo) doesn't kill the calling
process, and in fact on darwin it does.

Signed-off-by: Shea Levy <[email protected]>
@edolstra

Copy link
Copy Markdown
Member

This opens a security hole because there is no guarantee that the child process executed kill(-1, SIGKILL). It could have been killed by another process.

@shlevy

shlevy commented Mar 16, 2013

Copy link
Copy Markdown
Member Author

But the current behavior isn't any better, is it? I mean, if another process kills the killUser process then the current build will fail but the rogue process will still hang around.

@shlevy

shlevy commented Mar 16, 2013

Copy link
Copy Markdown
Member Author

Short of polling the process list until there are no processes for that user left (which AFAIK can only be portably done with system("ps -u")) or using cgroups, I don't think there's a good way to be completely sure that all processes started by the build are killed. But if we want to do that, we should whether or not this pull request is merged.

@edolstra

Copy link
Copy Markdown
Member

The rogue process will still be around, but that's not really a problem. The next time Nix wants to do a build under that uid, it will do killUser(uid) first. It will only proceed with the build if killUser() succeeds, i.e. there are no processes that might interfere with the build.

@shlevy

shlevy commented Mar 18, 2013

Copy link
Copy Markdown
Member Author

#103 does this better, without the security hole.

@shlevy shlevy closed this Mar 18, 2013
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 23, 2026
…nSink

BrotliCompressionSink::finish() and BrotliDecompressionSink::finish()
were byte-identical: flush(); writeInternal({}). The empty-view call is
brotli's drain idiom — its encoder/decoder loop interprets a
zero-length writeInternal as "finalise remaining state" — so the helper
must live on the chunked-codec subclass, not on CompressionSink. The
other three sinks (NoneSink, ArchiveCompressionSink,
ZstdMultiFrameCompressionSink) do not subclass ChunkedCompressionSink
and have their own per-codec trailers (libarchive close, zstd partial
frame, or just a flush).

Move the body to ChunkedCompressionSink::finish() and drop both
overrides. Both Brotli subclasses still inherit writeInternal as a pure
virtual, so the dispatch lands on each subclass's own implementation
exactly as before.

Candidate NixOS#99 in doc/inventory/candidates/.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 23, 2026
…ards

Adds **Branch:** lines to the 30 catalog entries that landed as commits
on the four cleanup shard branches (libexpr, libstore, libutil,
nix-cli) over the previous batch.

Per-shard tally (commits on each branch beyond the previously-pushed
tip):

- libexpr (HEAD 437eea9 -> +10): NixOS#64, NixOS#66, NixOS#68, NixOS#106, NixOS#107, NixOS#109,
  NixOS#110, NixOS#112, NixOS#196, NixOS#199. Two of the original twelve were skipped on
  rule grounds: NixOS#194 (LookupPath::Elem flatten) — the candidate
  framing claimed the types were internal, but search-path.hh ships
  via install_headers, so collapsing is a public-ABI break, not a
  trivial flatten; NixOS#197 (one-arg findFile drop) — EvalState::lookupPath
  is a private member, so the candidate's "have callers pass it
  explicitly" prescription cannot apply.

- libstore (HEAD 5f5b815 -> +12): NixOS#4, NixOS#5, NixOS#6, NixOS#14, NixOS#47, NixOS#82, NixOS#114,
  NixOS#115, NixOS#119, NixOS#157, NixOS#159, NixOS#165. Several departures from the literal
  prescription, recorded in each commit body and in the per-candidate
  Branch line: NixOS#14 lifted only getRemoteFSAccessor with a
  getLocalNarCacheDir hook (left the trivial getFSAccessor overrides
  per-class); NixOS#115 extracted only the prelude (lockProfile +
  findGenerations) since two callers use stateful reverse iteration;
  NixOS#119 confirmed init's setDefault is a different shape and stayed
  out; NixOS#159 dropped the assert(!childEOF) defensive check after walking
  Goal::handleEOF producers; NixOS#165 used option (b) of the prescription
  (a new derivation-output-fwd.hh) because option (a) would have
  introduced an include cycle.

- libutil (HEAD 784a4f4 -> +3): NixOS#29, NixOS#99, NixOS#117. NixOS#29's commit body
  caveat (XDG_*_HOME / XDG_CONFIG_DIRS reads moved from per-call to
  cached) is recorded on the candidate Branch line.

- nix-cli (HEAD 48524e0 -> +5): NixOS#24, NixOS#77, NixOS#89, NixOS#91, NixOS#187. NixOS#91 shipped
  the GcRootNamer + nameForCurrent consolidation but deferred the
  candidate's addPermRootWithCounter free helper because three
  behavioural differences across call sites (rootNr increment
  position, absPath timing, printGCWarning conditions on store2 null)
  would have either changed user-visible path naming or grown the API.

STATUS.md's cleanup-branches table is updated with each shard's
expanded Addresses list, and the Status column now distinguishes the
already-pushed tips (libfetchers/libflake/libmain remain Pushed since
they got no new commits) from the four shards whose new commits are
local-only.

Push policy is explicit-only — none of the four shard branches has
been pushed past its prior tip.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 23, 2026
…nSink

BrotliCompressionSink::finish() and BrotliDecompressionSink::finish()
were byte-identical: flush(); writeInternal({}). The empty-view call is
brotli's drain idiom — its encoder/decoder loop interprets a
zero-length writeInternal as "finalise remaining state" — so the helper
must live on the chunked-codec subclass, not on CompressionSink. The
other three sinks (NoneSink, ArchiveCompressionSink,
ZstdMultiFrameCompressionSink) do not subclass ChunkedCompressionSink
and have their own per-codec trailers (libarchive close, zstd partial
frame, or just a flush).

Move the body to ChunkedCompressionSink::finish() and drop both
overrides. Both Brotli subclasses still inherit writeInternal as a pure
virtual, so the dispatch lands on each subclass's own implementation
exactly as before.

Candidate NixOS#99 in doc/inventory/candidates/.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 24, 2026
A bidirectional traceability audit run after Batch G's commit
landed surfaced two more items beyond the NixOS#221 re-shelving
(already committed). Both addressed in this round.

1. Missing rl-next entry for BaseSetting<T>::overrideIfSet.
   Commit aa00e07 on libstore added a new public member
   function on a shipped libutil header (configuration.hh).
   Purely additive — no out-of-tree breakage — but the disclosure
   standard applied to other shipped-header changes in this
   batch (libmain getIntArg break, libstore log-fd shape change)
   calls for an rl-next entry on any public-API surface change.
   Added baseSetting-overrideIfSet.md on cleanup-libstore;
   new libstore tip b9a750f. nix build green.

2. Stylistic non-canonical commit-body form on three libutil
   commits. Bodies on 4212ac8 (NixOS#29), 7bfd6d1 (NixOS#99), and
   fe96867 (NixOS#117) used "Candidate #NN in doc/inventory/
   candidates/." instead of the canonical "Refs candidate
   #NN." Reworded via non-interactive git rebase -i master
   with sed-based GIT_SEQUENCE_EDITOR + GIT_EDITOR. Metadata
   only; trees identical. New libutil tip da1e0d7. clang-tidy
   and nix build green post-rebase (5 known pre-existing
   master errors only).

STATUS.md cleanup-branches table updated with new tips and
notes; the libstore row now records NixOS#119's overrideIfSet
helper extraction; the libutil row records the reword and
the dropped-NixOS#163 caveat. FOLLOWUPS.md adds a "Batch G
follow-ups (post-audit)" subsection with both items struck.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 24, 2026
…nSink

BrotliCompressionSink::finish() and BrotliDecompressionSink::finish()
were byte-identical: flush(); writeInternal({}). The empty-view call is
brotli's drain idiom — its encoder/decoder loop interprets a
zero-length writeInternal as "finalise remaining state" — so the helper
must live on the chunked-codec subclass, not on CompressionSink. The
other three sinks (NoneSink, ArchiveCompressionSink,
ZstdMultiFrameCompressionSink) do not subclass ChunkedCompressionSink
and have their own per-codec trailers (libarchive close, zstd partial
frame, or just a flush).

Move the body to ChunkedCompressionSink::finish() and drop both
overrides. Both Brotli subclasses still inherit writeInternal as a pure
virtual, so the dispatch lands on each subclass's own implementation
exactly as before.

Refs candidate NixOS#99.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants