diff --git a/CHANGELOG.md b/CHANGELOG.md index 0482590..e534e87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ - rootfs generator for Ubuntu 14.04. +- Parameter for setting up docker registry server. + ### Fixed - Spelling in output. diff --git a/kernel.go b/kernel.go index 0037ad3..9d5d129 100644 --- a/kernel.go +++ b/kernel.go @@ -109,7 +109,7 @@ func vsyscallAvailable() (available bool, err error) { return } -func generateBaseDockerImage(sk config.KernelMask) (err error) { +func generateBaseDockerImage(registry string, sk config.KernelMask) (err error) { imagePath, err := dockerImagePath(sk) if err != nil { return @@ -128,7 +128,12 @@ func generateBaseDockerImage(sk config.KernelMask) (err error) { sk.DistroType.String(), sk.DistroRelease) os.MkdirAll(imagePath, os.ModePerm) - d += fmt.Sprintf("FROM %s:%s\n", + d += "FROM " + if registry != "" { + d += registry + "/" + } + + d += fmt.Sprintf("%s:%s\n", strings.ToLower(sk.DistroType.String()), sk.DistroRelease, ) @@ -573,7 +578,9 @@ func shuffle(a []string) []string { return a } -func generateKernels(km config.KernelMask, max int64, download bool) (err error) { +func generateKernels(km config.KernelMask, registry string, max int64, + download bool) (err error) { + log.Println("Generating for kernel mask", km) _, err = genRootfsImage(dockerImageInfo{ContainerName: km.DockerName()}, @@ -582,7 +589,7 @@ func generateKernels(km config.KernelMask, max int64, download bool) (err error) return } - err = generateBaseDockerImage(km) + err = generateBaseDockerImage(registry, km) if err != nil { return } @@ -632,7 +639,9 @@ func generateKernels(km config.KernelMask, max int64, download bool) (err error) return } -func kernelAutogenHandler(workPath string, max int64, host, download bool) (err error) { +func kernelAutogenHandler(workPath, registry string, max int64, host, + download bool) (err error) { + ka, err := config.ReadArtifactConfig(workPath + "/.out-of-tree.toml") if err != nil { return @@ -644,7 +653,7 @@ func kernelAutogenHandler(workPath string, max int64, host, download bool) (err return } - err = generateKernels(sk, max, download) + err = generateKernels(sk, registry, max, download) if err != nil { return } @@ -695,7 +704,9 @@ func kernelDockerRegenHandler(host, download bool) (err error) { return updateKernelsCfg(host, download) } -func kernelGenallHandler(distro, version string, host, download bool) (err error) { +func kernelGenallHandler(distro, version, registry string, host, + download bool) (err error) { + distroType, err := config.NewDistroType(distro) if err != nil { return @@ -706,7 +717,7 @@ func kernelGenallHandler(distro, version string, host, download bool) (err error DistroRelease: version, ReleaseMask: ".*", } - err = generateKernels(km, kernelsAll, download) + err = generateKernels(km, registry, kernelsAll, download) if err != nil { return } diff --git a/main.go b/main.go index e21fb73..6e113d7 100644 --- a/main.go +++ b/main.go @@ -117,6 +117,9 @@ func main() { dockerTimeoutFlag := app.Flag("docker-timeout", "Timeout for docker") dockerTimeout := dockerTimeoutFlag.Default(conf.Docker.Timeout).Duration() + dockerRegistryFlag := app.Flag("docker-registry", "Registry for docker") + dockerRegistry := dockerRegistryFlag.Default(conf.Docker.Registry).String() + pewCommand := app.Command("pew", "Build, run and test module/exploit") pewMax := pewCommand.Flag("max", "Test no more than X kernels"). @@ -289,12 +292,12 @@ func main() { case kernelListCommand.FullCommand(): err = kernelListHandler(kcfg) case kernelAutogenCommand.FullCommand(): - err = kernelAutogenHandler(*path, *kernelAutogenMax, - *kernelUseHost, !*kernelNoDownload) + err = kernelAutogenHandler(*path, *dockerRegistry, + *kernelAutogenMax, *kernelUseHost, !*kernelNoDownload) case kernelDockerRegenCommand.FullCommand(): err = kernelDockerRegenHandler(*kernelUseHost, !*kernelNoDownload) case kernelGenallCommand.FullCommand(): - err = kernelGenallHandler(*distro, *version, + err = kernelGenallHandler(*distro, *version, *dockerRegistry, *kernelUseHost, !*kernelNoDownload) case genModuleCommand.FullCommand(): err = genConfig(config.KernelModule) @@ -318,7 +321,7 @@ func main() { case logMarkdownCommand.FullCommand(): err = logMarkdownHandler(db, *path, *logMarkdownTag) case packCommand.FullCommand(): - err = packHandler(db, *path, kcfg, *packAutogen, + err = packHandler(db, *path, *dockerRegistry, kcfg, *packAutogen, !*packNoDownload, *packExploitRuns, *packKernelRuns) } diff --git a/pack.go b/pack.go index fab0f0d..9474c1b 100644 --- a/pack.go +++ b/pack.go @@ -15,7 +15,7 @@ import ( "code.dumpstack.io/tools/out-of-tree/config" ) -func packHandler(db *sql.DB, path string, kcfg config.KernelConfig, +func packHandler(db *sql.DB, path, registry string, kcfg config.KernelConfig, autogen, download bool, exploitRuns, kernelRuns int64) (err error) { dockerTimeout := time.Minute @@ -39,7 +39,8 @@ func packHandler(db *sql.DB, path string, kcfg config.KernelConfig, if autogen { var perRegex int64 = 1 - err = kernelAutogenHandler(workPath, perRegex, false, download) + err = kernelAutogenHandler(workPath, registry, + perRegex, false, download) if err != nil { return }