Page MenuHomeFreeBSD

nuageinit: Add guards against empty user data
Needs ReviewPublic

Authored by jlduran on Tue, Oct 21, 1:32 PM.
Tags
None
Referenced Files
F133096621: D53239.diff
Wed, Oct 22, 10:53 PM
F133049150: D53239.id164699.diff
Wed, Oct 22, 11:12 AM
F133042067: D53239.id.diff
Wed, Oct 22, 9:19 AM
Unknown Object (File)
Wed, Oct 22, 6:39 AM
Unknown Object (File)
Wed, Oct 22, 5:46 AM
Unknown Object (File)
Wed, Oct 22, 4:34 AM
Unknown Object (File)
Wed, Oct 22, 2:54 AM
Unknown Object (File)
Wed, Oct 22, 2:54 AM
Subscribers

Details

Reviewers
bapt
dtxdf
kevans
Summary

Add guards against attempting to process an empty user data file.

PR: 290395

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 67961
Build 64844: arc lint + arc unit

Event Timeline

libexec/nuageinit/nuageinit
665

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

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

libexec/nuageinit/nuageinit
665

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.Tue, Oct 21, 3:18 PM
jlduran retitled this revision from nuageinit: Add a guard against empty user data to nuageinit: Add guards against empty user data.Tue, Oct 21, 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.Tue, Oct 21, 3:40 PM
This revision is now accepted and ready to land.Tue, Oct 21, 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.Tue, Oct 21, 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