^.^

Ralph Corderoy <[email protected]> wrote:
 |>>> (The idea is that we now catch things when they get set as
 |>>> necessary, and can use them without further tests from then on.
 |>>
 |>> That sounds like a race condition.  :-)  Especially in a long-lived
 |>> program.  What later operations don't bother error checking because
 |>> $HOME is not writable, for example?
 |>
 |> Well, we initially fall back to what the user database reports for the
 |> local user if $HOME does not work out.  Of course later failures are
 |> still handled (much too many are fatal still where that may not be
 |> necessary, however).  But we know $HOME, $TMPDIR etc. are set and do
 |> not need myriads of unnecessary conditionals in the code.
 |
 |Neither does the normal way of running through the alternatives once,
 |lazily on first real need, and caching the result, e.g. a `static char
 |*home' in find_home().

Well this goes pretty much in details which can be done in quite
some differently thinkable ways.  We perform validation of
$LOGNAME (a.k.a. $USER) once upon program startup, so we do have
the getpwuid(3) at hand, however expensive fetching that mess may
have been at first, sic.  The time is pretty much right to do
other expensive initial checks[1], and $HOMEDIR is a valuable
target.

Also we now have a generalized variable handling, and it is very
likely that more generalization takes place once the exceeded
16-bit limit is raised.  For now (space adjusted)

  ?0[nail.git]$ git grep -E '_v_(TMP|HOME)' nail.h                              
                                                           
  nail.h:   ok_v_HOME,   /* {vip=1,nodel=1,notempty=1,import=1} */
  nail.h:   ok_v_TMPDIR, /* {import=1,vip=1,notempty=1,defval=VAL_TMPDIR} */

these are (oh the attribute order mess!) both VIPs which need
special treatment, in the future we could have dir_rwx and dir_rx,
for example.  Of course this still is TOCTOU.  Nonetheless, you
will not see me using non-constant static data in a function
except when being stucked in a kettle to be boiled to death.
Barbarian, that is.

  [1] https://git.sdaoden.eu/cgit/s-nail.git/tree/main.c#n370

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
__________________________________
[email protected]

Reply via email to