osutil: tweak build ID tests to account for too-old 'file'
The host's 'file' comamnd may be to old to be aware of Go BuildID, in which
case, the unit tests will fail. Work around that by forcing a specific Go build
ID via -ldflags=-buildid=.. For consistency, add a test for a fixed GNU BuildID
too.
Signed-off-by: Maciej Borzecki <email address hidden>
osutil: use go build-id when no gnu build-id is available
The go compiler will only create a GNU build-id when either
build with -buildmode=pie or when we have a `import "C"`
somewhere. We do not use -buildmode=pie on 32bit systems
and with PR#6759 we will stop using cgo (`import "C"`) soon.
This means that we have no GNU build-id in our binaries
anymore on some sytems. The build-id is criticial for the
system-key generation. Fortunately go also provides a
build-id that we can use. It is available since at least
go-1.6 so should cause no problems. Its longer than the
GNU build id (~50 bytes) but not unwieldy.
The old regex, `^[a-z0-9][-a-z0-9+.-_]*$`, had a bug in it where it
would accept any character within the range of '.-_' where 'a:b'
would match since '.' < ':' < '_' in the ASCII table.
Make IsValidUsername public since it makes adding tests easier and
subsequent commits will use this.