The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/distrobuilder/pull/179

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: Re4son <re4...@kali.org>
From 8dac9aaa0e7368fe8be1e9d2743e345ef619a8dc Mon Sep 17 00:00:00 2001
From: Re4son <re4...@users.noreply.github.com>
Date: Thu, 23 May 2019 15:34:06 +1000
Subject: [PATCH] Add kali-linux distro

Signed-off-by: Re4son <re4...@kali.org>
---
 doc/examples/kali                    | 124 ++++++++++++++++++++++
 doc/examples/kali-with-core-packages | 151 +++++++++++++++++++++++++++
 shared/definition.go                 |   1 +
 shared/definition_test.go            |   3 +
 shared/osarch.go                     |   8 ++
 shared/osarch_test.go                |  13 +++
 6 files changed, 300 insertions(+)
 create mode 100644 doc/examples/kali
 create mode 100644 doc/examples/kali-with-core-packages

diff --git a/doc/examples/kali b/doc/examples/kali
new file mode 100644
index 0000000..5a9554e
--- /dev/null
+++ b/doc/examples/kali
@@ -0,0 +1,124 @@
+image:
+  distribution: "kali"
+  release: kali-rolling
+
+source:
+  downloader: debootstrap
+  url: http://http.kali.org/kali
+  keyserver: keys.gnupg.net
+  keys:
+    - 44C6513A8E4FB3D30875F758ED444FF07D8D0BF6
+  variant: minbase
+  apt_sources: |-
+    deb http://http.kali.org/kali {{ image.release }} main non-free contrib
+
+targets:
+  lxc:
+    create-message: |-
+      You just created a {{ image.description }} container.
+
+      To enable SSH, run: apt install openssh-server
+      No default root or user password are set by LXC.
+
+    config:
+      - type: all
+        before: 5
+        content: |-
+          lxc.include = LXC_TEMPLATE_CONFIG/kali.common.conf
+
+      - type: user
+        before: 5
+        content: |-
+          lxc.include = LXC_TEMPLATE_CONFIG/kali.userns.conf
+
+      - type: all
+        after: 4
+        content: |-
+          lxc.include = LXC_TEMPLATE_CONFIG/common.conf
+
+      - type: user
+        after: 4
+        content: |-
+          lxc.include = LXC_TEMPLATE_CONFIG/userns.conf
+
+      - type: all
+        content: |-
+          lxc.arch = {{ image.architecture_personality }}
+
+files:
+ - path: /etc/hostname
+   generator: hostname
+
+ - path: /etc/hosts
+   generator: hosts
+
+ - path: /etc/resolvconf/resolv.conf.d/original
+   generator: remove
+
+ - path: /etc/resolvconf/resolv.conf.d/tail
+   generator: remove
+
+ - path: /etc/machine-id
+   generator: remove
+
+ - path: /etc/network/interfaces
+   generator: dump
+   content: |-
+     # This file describes the network interfaces available on your system
+     # and how to activate them. For more information, see interfaces(5).
+
+     # The loopback network interface
+     auto lo
+     iface lo inet loopback
+
+     auto eth0
+     iface eth0 inet dhcp
+
+packages:
+  manager: apt
+  update: true
+  cleanup: true
+
+  sets:
+    - packages:
+      - dialog
+      - ifupdown
+      - isc-dhcp-client
+      - locales
+      - netbase
+      - net-tools
+      - openssh-client
+      - vim
+      - systemd
+      - kali-archive-keyring
+      action: install
+
+actions:
+  - trigger: post-packages
+    action: |-
+      #!/bin/sh
+      set -eux
+
+      # Make sure the locale is built and functional
+      echo en_US.UTF-8 UTF-8 >> /etc/locale.gen
+      locale-gen en_US.UTF-8 UTF-8
+      update-locale LANG=en_US.UTF-8
+
+      # Cleanup underlying /run
+      mount -o bind / /mnt
+      rm -rf /mnt/run/*
+      umount /mnt
+
+      # Cleanup temporary shadow paths
+      rm /etc/*-
+
+  - trigger: post-packages
+    action: |-
+      #!/bin/sh
+      set -eux
+      apt-get install iproute2 init -y
+    releases:
+      - kali-rolling
+
+mappings:
+  architecture_map: kali
diff --git a/doc/examples/kali-with-core-packages 
b/doc/examples/kali-with-core-packages
new file mode 100644
index 0000000..cfab995
--- /dev/null
+++ b/doc/examples/kali-with-core-packages
@@ -0,0 +1,151 @@
+image:
+  distribution: "kali"
+  release: kali-rolling
+
+source:
+  downloader: debootstrap
+  url: http://http.kali.org/kali
+  keyserver: keys.gnupg.net
+  keys:
+    - 44C6513A8E4FB3D30875F758ED444FF07D8D0BF6
+  variant: minbase
+  apt_sources: |-
+    deb http://http.kali.org/kali {{ image.release }} main non-free contrib
+
+targets:
+  lxc:
+    create-message: |-
+      You just created a {{ image.description }} container.
+
+      To enable SSH, run: apt install openssh-server
+      No default root or user password are set by LXC.
+
+    config:
+      - type: all
+        before: 5
+        content: |-
+          lxc.include = LXC_TEMPLATE_CONFIG/kali.common.conf
+
+      - type: user
+        before: 5
+        content: |-
+          lxc.include = LXC_TEMPLATE_CONFIG/kali.userns.conf
+
+      - type: all
+        after: 4
+        content: |-
+          lxc.include = LXC_TEMPLATE_CONFIG/common.conf
+
+      - type: user
+        after: 4
+        content: |-
+          lxc.include = LXC_TEMPLATE_CONFIG/userns.conf
+
+      - type: all
+        content: |-
+          lxc.arch = {{ image.architecture_personality }}
+
+files:
+ - path: /etc/hostname
+   generator: hostname
+
+ - path: /etc/hosts
+   generator: hosts
+
+ - path: /etc/resolvconf/resolv.conf.d/original
+   generator: remove
+
+ - path: /etc/resolvconf/resolv.conf.d/tail
+   generator: remove
+
+ - path: /etc/machine-id
+   generator: remove
+
+ - path: /etc/network/interfaces
+   generator: dump
+   content: |-
+     # This file describes the network interfaces available on your system
+     # and how to activate them. For more information, see interfaces(5).
+
+     # The loopback network interface
+     auto lo
+     iface lo inet loopback
+
+     auto eth0
+     iface eth0 inet dhcp
+
+packages:
+  manager: apt
+  update: true
+  cleanup: true
+
+  sets:
+    - packages:
+      - dialog
+      - ifupdown
+      - isc-dhcp-client
+      - locales
+      - netbase
+      - net-tools
+      - openssh-client
+      - vim
+      - systemd
+      - iw
+      - kali-defaults
+      - mlocate
+      - netcat-traditional
+      - net-tools
+      - psmisc
+      - screen
+      - tmux
+      - wget
+      - zerofree
+      - exploitdb
+      - hydra
+      - john
+      - medusa
+      - metasploit-framework
+      - mfoc
+      - ncrack
+      - nmap
+      - passing-the-hash
+      - proxychains
+      - recon-ng
+      - sqlmap
+      - tcpdump
+      - theharvester
+      - tor
+      - tshark
+      - whois
+      - kali-archive-keyring
+      action: install
+
+actions:
+  - trigger: post-packages
+    action: |-
+      #!/bin/sh
+      set -eux
+
+      # Make sure the locale is built and functional
+      echo en_US.UTF-8 UTF-8 >> /etc/locale.gen
+      locale-gen en_US.UTF-8 UTF-8
+      update-locale LANG=en_US.UTF-8
+
+      # Cleanup underlying /run
+      mount -o bind / /mnt
+      rm -rf /mnt/run/*
+      umount /mnt
+
+      # Cleanup temporary shadow paths
+      rm /etc/*-
+
+  - trigger: post-packages
+    action: |-
+      #!/bin/sh
+      set -eux
+      apt-get install iproute2 init -y
+    releases:
+      - kali-rolling
+
+mappings:
+  architecture_map: kali
diff --git a/shared/definition.go b/shared/definition.go
index 058a32b..3f8bd16 100644
--- a/shared/definition.go
+++ b/shared/definition.go
@@ -333,6 +333,7 @@ func (d *Definition) Validate() error {
                "centos",
                "debian",
                "gentoo",
+               "kali",
                "plamolinux",
        }
 
diff --git a/shared/definition_test.go b/shared/definition_test.go
index a4099d9..2db51e9 100644
--- a/shared/definition_test.go
+++ b/shared/definition_test.go
@@ -49,6 +49,9 @@ func TestValidateDefinition(t *testing.T) {
                                Mappings: DefinitionMappings{
                                        ArchitectureMap: "debian",
                                },
+                               Mappings: DefinitionMappings{
+                                       ArchitectureMap: "kali",
+                               },
                        },
                        "",
                        false,
diff --git a/shared/osarch.go b/shared/osarch.go
index f0f67ef..5124075 100644
--- a/shared/osarch.go
+++ b/shared/osarch.go
@@ -41,6 +41,13 @@ var gentooArchitectureNames = map[int]string{
        osarch.ARCH_64BIT_S390_BIG_ENDIAN:       "s390x",
 }
 
+var kaliArchitectureNames = map[int]string{
+       osarch.ARCH_32BIT_INTEL_X86:           "i386",
+       osarch.ARCH_64BIT_INTEL_X86:           "amd64",
+       osarch.ARCH_32BIT_ARMV7_LITTLE_ENDIAN: "armhf",
+       osarch.ARCH_64BIT_ARMV8_LITTLE_ENDIAN: "arm64",
+}
+
 var plamoLinuxArchitectureNames = map[int]string{
        osarch.ARCH_32BIT_INTEL_X86: "x86",
 }
@@ -58,6 +65,7 @@ var distroArchitecture = map[string]map[int]string{
        "centos":      centosArchitectureNames,
        "debian":      debianArchitectureNames,
        "gentoo":      gentooArchitectureNames,
+       "kali":        kaliArchitectureNames,
        "plamolinux":  plamoLinuxArchitectureNames,
 }
 
diff --git a/shared/osarch_test.go b/shared/osarch_test.go
index 4068033..25c777f 100644
--- a/shared/osarch_test.go
+++ b/shared/osarch_test.go
@@ -38,6 +38,16 @@ func TestGetArch(t *testing.T) {
                        "s390x",
                        "s390x",
                },
+               {
+                       "kali",
+                       "amd64",
+                       "amd64",
+               },
+               {
+                       "kali",
+                       "x86_64",
+                       "amd64",
+               },
        }
 
        for i, tt := range tests {
@@ -52,4 +62,7 @@ func TestGetArch(t *testing.T) {
 
        _, err = GetArch("debian", "arch")
        require.EqualError(t, err, "Architecture isn't supported: arch")
+
+       _, err = GetArch("kali", "arch")
+       require.EqualError(t, err, "Architecture isn't supported: arch")
 }
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to