#!/bin/sh LXC_BASEDIR="/home/vservers/" usage() { echo "shift uid and gid to orig-uid + uid-offset, e.g. 100000 to convert privileged container to unprivileged" echo echo "usage: $0 containername uid-offset" echo } OFFSET=$2 if [ -z "$2" ]; then usage exit 1 fi if [ ! -d "${LXC_BASEDIR}${1}/rootfs" ]; then echo "container rootfs at ${LXC_BASEDIR}${1}/rootfs not found. exit." exit 1 fi echo "mapping uid and gid + 100000" for i in `seq 0 65535`; do find ${LXC_BASEDIR}${1}/rootfs -uid $i -exec chown $(($OFFSET+i)) \{\} \; find ${LXC_BASEDIR}${1}/rootfs -gid $i -exec chgrp $(($OFFSET+i)) \{\} \; done # reset to privileged: #for i in `seq 0 65535`; do # find ${LXC_BASEDIR}${1}/rootfs -uid $i -exec chown $((i-1000000)) \{\} \; # find ${LXC_BASEDIR}${1}/rootfs -gid $i -exec chgrp $((i-1000000)) \{\} \; #done