Hi.

   I see that you've uploaded a new version of ninja, with a fix for
this bug:

> * Added a preinst script to create a logfile. (Closes: #568780).

   I wonder if there's a better way to do this. The basic problem is
that the code (in version 0.1.3-1, anyway) never gets a chance to create
the file in the first place.

   The file_isregular() function will return a fail if the file doesn't
exist (as well as if it's a directory/symlink etc). It's called in two
places that concern us here: in the LOG() function (log.c line 30) and
in the main() function (main.c line 92), which is called upon completion
of the first calls to LOG().

   Normally the fopen() calls on line 30 of log.c and line 95 of main.c
would create the file if it doesn't exist (they both have the "a" mode),
but neither is ever executed because they're both preceded by the
file_isregular() call.

   Suggest removing the file_isregular() call from line 30 of log.c.
Then, as long as there's a call to LOG() before the file_isregular()
call on main.c line 92, the file will be properly created if it doesn't
already exist (assuming there's no other problem, of course: that's what
the remaining file_isregular() call is for).

   If you really want to be paranoid, you can move the log.c call to
file_isregular() from line 30 to line 33, so we have

>  if ((fd != NULL) && file_isregular(global_opts.logfile) == 1)) {

   I think that should ensure we're not doing something we shouldn't.

   The trouble with creating the logfile at installation time is that,
if the file ever goes away for any reason, we're back where we started.
That's also why I wasn't sure what would happen after you fixed bug
#563328 and logrotate ran properly: would the file be re-created under
those circumstances? (I'm still not sure).

   Anyway, let me know what you think. Wouldn't surprise me if I'd
missed something obvious.

Thanks for you work on this,

 .....Ron


-- 
Ron Murray   (r...@rjmx.net)
http://www.rjmx.net/~ron
GPG Public Key Fingerprint:
  0ED0 C1D1 615C FCCE 7424  9B27 31D8 AED5 AF6D 0D4A

Random access is the optimum of the mass storages.



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to