diff --git a/lxc/lxc-debian-userns b/lxc/lxc-debian-userns index fa5b046..87e8254 100755 --- a/lxc/lxc-debian-userns +++ b/lxc/lxc-debian-userns @@ -64,7 +64,7 @@ parse_args() { prog="${0}" shift - options=$(getopt -o h -l help,path:,name:,rootfs:,mirror:,security-mirror:,auth-key:,release:,uidmap:,gidmap: -- "${@}") + options=$(getopt -o h -l help,path:,name:,rootfs:,mirror:,security-mirror:,auth-key:,release:,uidmap:,gidmap:,mapped-uid:,mapped-gid: -- "${@}") if [ $? -ne 0 ]; then usage "${prog}" exit 1 @@ -86,6 +86,8 @@ parse_args() { --auth-key) auth_key=${2}; shift 2;; --uidmap) uidmap=${2}; shift 2;; --gidmap) gidmap=${2}; shift 2;; + --mapped-uid) echo "Cannot run with lxc.idmap set in config. Use --uidmap/--gidmap template options instead."; exit 1; shift 2;; + --mapped-gid) echo "Cannot run with lxc.idmap set in config. Use --uidmap/--gidmap template options instead."; exit 1; shift 2;; *) echo "programming error: found unknown opt ${1}"; exit 1; break;; esac done @@ -143,6 +145,13 @@ install_debian() ( ) +write_userns_to_config() ( + # uses $path, $uidmap, $gidmap + printf "lxc.idmap = %s\n" "$(printf "%s" "${uidmap}" | tr ':' ' ')" >> "${path}/config" + printf "lxc.idmap = %s\n" "$(printf "%s" "${gidmap}" | tr ':' ' ')" >> "${path}/config" +) + + parse_args "${0}" "${@}" check_required_binary "${0}" mmdebstrap || exit 1 @@ -151,3 +160,5 @@ check_required_binary "${0}" lxc-usernsexec || exit 1 chown_mountpoint || exit 1 install_debian + +write_userns_to_config