diff --git a/install.sh b/install.sh index 3d4e4e933d..cf822b82a8 100755 --- a/install.sh +++ b/install.sh @@ -180,7 +180,8 @@ fi SHARE_DIRS="$SHARE_LOCATION/examples \ $SHARE_LOCATION/examples/tm" -ETC_DIRS="$ETC_LOCATION/im_ec2 \ +ETC_DIRS="$ETC_LOCATION/image \ + $ETC_LOCATION/im_ec2 \ $ETC_LOCATION/vmm_ec2 \ $ETC_LOCATION/vmm_exec \ $ETC_LOCATION/tm_shared \ @@ -469,6 +470,7 @@ INSTALL_ETC_FILES=( VMWARE_ETC_FILES:$ETC_LOCATION VMM_EC2_ETC_FILES:$ETC_LOCATION/vmm_ec2 VMM_EXEC_ETC_FILES:$ETC_LOCATION/vmm_exec + IMAGE_DRIVER_FS_ETC_FILES:$ETC_LOCATION/image/ IM_EC2_ETC_FILES:$ETC_LOCATION/im_ec2 TM_SHARED_ETC_FILES:$ETC_LOCATION/tm_shared TM_SSH_ETC_FILES:$ETC_LOCATION/tm_ssh @@ -731,6 +733,9 @@ VMWARE_TM_COMMANDS_LIB_FILES="src/tm_mad/vmware/tm_clone.sh \ # Image Repository drivers, to be installed under $REMOTES_LOCATION/image # - FS based Image Repository, $REMOTES_LOCATION/image/fs #------------------------------------------------------------------------------- + +IMAGE_DRIVER_FS_ETC_FILES="src/image_mad/remotes/fs/fs.conf" + IMAGE_DRIVER_FS_SCRIPTS="src/image_mad/remotes/fs/cp \ src/image_mad/remotes/fs/mkfs \ src/image_mad/remotes/fs/mv \ diff --git a/src/image_mad/remotes/fs/fs.conf b/src/image_mad/remotes/fs/fs.conf new file mode 100644 index 0000000000..8e464991f9 --- /dev/null +++ b/src/image_mad/remotes/fs/fs.conf @@ -0,0 +1,38 @@ +# -------------------------------------------------------------------------- # +# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +# PRESERVE BASH SYNTAX + +#******************************************************************************* +# Configuration File for File-System based Image Repositories +#------------------------------------------------------------------------------- +# IMAGE_REPOSITORY: Path where the images will be stored. If not defined +# defaults to /var/lib/one/images or $ONE_LOCATION/var/images +# +# RESTRICTED_DIRS: Paths that can not be used to register images. A space +# separated list of paths. This prevents users to access important files like +# oned.db or /etc/shadow. OpenNebula will automatically add its configuration +# dirs:/var/lib/one, /etc/one and oneadmin's home ($HOME). +# +# SAFE_DIRS: Paths that are safe to specify image paths. This will allow you to +# open specific paths within RESTRICTED_DIRS +#******************************************************************************* + +#IMAGE_REPOSITORY_PATH=/var/lib/one/images + +RESTRICTED_DIRS="/etc/" + +SAFE_DIRS="$HOME/public/" diff --git a/src/image_mad/remotes/fs/fsrc b/src/image_mad/remotes/fs/fsrc index c8e7a58d3a..8cec0f0b05 100644 --- a/src/image_mad/remotes/fs/fsrc +++ b/src/image_mad/remotes/fs/fsrc @@ -22,12 +22,6 @@ # - RESTRICTED_DIRS: Paths that can not be used to register images # - SAFE_DIRS: Paths that are safe to specify image paths #------------------------------------------------------------------------------ -if [ -z "${ONE_LOCATION}" ]; then - export IMAGE_REPOSITORY_PATH=/var/lib/one/images -else - export IMAGE_REPOSITORY_PATH=$ONE_LOCATION/var/images -fi - if [ -z "${ONE_LOCATION}" ]; then VAR_LOCATION=/var/lib/one/ ETC_LOCATION=/etc/one/ @@ -36,8 +30,23 @@ else ETC_LOCATION=$ONE_LOCATION/etc/ fi -export RESTRICTED_DIRS="$VAR_LOCATION $ETC_LOCATION $HOME/ /etc/" -export SAFE_DIRS="$HOME/public/" +CONF_FILE=$ETC_LOCATION/image/fs.conf + +source $CONF_FILE + +if [ -z "${IMAGE_REPOSITORY_PATH}" ]; then + if [ -z "${ONE_LOCATION}" ]; then + IMAGE_REPOSITORY_PATH=/var/lib/one/images + else + IMAGE_REPOSITORY_PATH=$ONE_LOCATION/var/images + fi +fi + +RESTRICTED_DIRS="$VAR_LOCATION $ETC_LOCATION $HOME/ $RESTRICTED_DIRS" + +export IMAGE_REPOSITORY_PATH +export RESTRICTED_DIRS +export SAFE_DIRS #------------------------------------------------------------------------------ # Function used to generate Image names, you should not need to override this @@ -86,7 +95,6 @@ function check_restricted { # Change the permissions of all the files inside directoriers (= VMware disks) function fix_owner_perms { - find $IMAGE_REPOSITORY_PATH -type d \ -mindepth 1 \ -maxdepth 1 \