Page MenuHomeFreeBSD

nuageinit: Add guards against empty user data
ClosedPublic

Authored by jlduran on Oct 21 2025, 1:32 PM.
Tags
None
Referenced Files
F137839493: D53239.id164694.diff
Wed, Nov 26, 7:42 AM
Unknown Object (File)
Mon, Nov 24, 9:50 PM
Unknown Object (File)
Mon, Nov 24, 12:26 AM
Unknown Object (File)
Sun, Nov 23, 1:38 PM
Unknown Object (File)
Fri, Nov 21, 12:28 AM
Unknown Object (File)
Thu, Nov 20, 7:52 PM
Unknown Object (File)
Thu, Nov 20, 5:41 PM
Unknown Object (File)
Wed, Nov 19, 7:43 AM
Subscribers

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

libexec/nuageinit/nuageinit
665–669

I would probably recommend something like this instead of the below change; in particular, it defends against the additional case below where we try to concatenate nil in the citype ~= "postnet" case. OTOH, I'm looking at that and content probably suffers from the same problem. I wondered if it was better to move the new condition up here, but I guess we probably still want to write the blank output to /var/cache/nuageinit?

libexec/nuageinit/nuageinit
665–669

OK, yes, it is better.
However, I'm not sure if we want /var/cache/nuageinit with just a newline?

libexec/nuageinit/nuageinit
665–669

Right, maybe not- if it doesn't make sense to preserve an empty user_data, then you might as well preserve the nil-ness (so that you know it's empty and not just a blank line) and just move the check up. I wasn't really sure if it's feasible to reach this on a non-first boot and need to do something still with the user_data file written, but I guess the below open doesn't truncate it (and there's definitely no value in adding an extra blank line to it).

This revision is now accepted and ready to land.Oct 21 2025, 3:18 PM
jlduran retitled this revision from nuageinit: Add a guard against empty user data to nuageinit: Add guards against empty user data.Oct 21 2025, 3:38 PM
jlduran edited the summary of this revision. (Show Details)
  • Guard earlier against line being empty
  • Guard against content being empty
This revision now requires review to proceed.Oct 21 2025, 3:40 PM
This revision is now accepted and ready to land.Oct 21 2025, 3:56 PM

At this point I'm lost against the file specifications:

  • Guard against the file being empty or first line being empty
  • Guard against the contents being empty
This revision now requires review to proceed.Oct 21 2025, 4:05 PM

These are the current checks:

  • There is no file
  • The file is empty
  • The file contains a number of new lines (and nothing else)
  • The file has the first line empty, and then are valid contents <- I'm not sure if this is valid?
jlduran added inline comments.
libexec/nuageinit/nuageinit
666

This checks that the first line is not blank (no white spaces, tabs, non-printable characters, etc.).

If you think this blank-string check could be useful in other parts of nuageinit, I can create a function in nuage.lua.

  • The first line of the user data file cannot be empty
This revision is now accepted and ready to land.Fri, Nov 21, 5:24 PM