[arch-projects] [devtools] [PATCH 5/9] arch-nspawn: Avoid errors where $working_dir is longer than HOST_NAME_MAX.
Dave Reisner
d at falconindy.com
Sun May 11 11:54:05 EDT 2014
On Sun, May 11, 2014 at 12:04:31AM -0400, Luke Shumaker wrote:
> At Sat, 10 May 2014 22:36:44 -0400,
> Dave Reisner wrote:
> > On Sat, May 10, 2014 at 10:22:07PM -0400, Luke Shumaker wrote:
> > > +#HOST_NAME_MAX="$(printf '%s\n' '#include <limits.h>' 'HOST_NAME_MAX'|cpp -|sed -n '$p')"
> >
> > No need to write the include as if this were a source file, just tell
> > cpp about it directly:
> >
> > cpp -I limits.h <<<HOST_NAME_MAX | ...
>
> That doesn't work, but this does:
>
> cpp -include limits.h <<<HOST_NAME_MAX | ...
>
> I'd never had occasion to use that flag before, so thank you!
>
Ah, right. -I is for directories.
> > > +HOST_NAME_MAX=64
> > > +if [[ ${#machine_name} -gt "$HOST_NAME_MAX" ]]; then
> > > + machine_name="${machine_name:(-${HOST_NAME_MAX})}"
> > > + machine_name="${machine_name#-}"
> >
> > I think this is worth warning about, since it might result in name
> > clashes.
>
> Is it any more likely to cause clashes than the existing machine name
> munging? 64 characters is a lot, and I figure that the end is the
> part that is most likely to change.
Oh, I see. You're trimming leading characters, not truncating.
Alternatively, just hash the full path? Is the machine name really
useful in any way other than to define a unique name for the build
container?
> What about passing '-q' to systemd-nspawn and not directing its stderr
> to /dev/null? That way the user gets a reasonably friendly "Failed to
> register machine: Machine '$machine_name' already exits", as well as
> a message for any other errors that may occur. IIRC, the reason
> stderr was directed to /dev/null was that at the time it was written,
> systemd-nspawn didn't have a '-q' flag.
Sounds good to me. The --quiet flag was added to systemd in v209.
d
More information about the arch-projects
mailing list