root 78a5862
#!/bin/bash
root 78a5862
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
root 78a5862
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
root 78a5862
#
root 78a5862
#   runtest.sh of setting-group-acls
root 78a5862
#   Description: If you are using the -A/--acls option and you are not running as root and are not using the --numeric-ids option then if you have an ACL that includes a group entry for a group you are not a member of on the receiving side, then acl_set_file will return EINVAL, b/c rsync mistakenly maps the group name to gid GID_NONE (-1), which (fortunately) fails.
root 78a5862
#   Author: Ales Marecek <amarecek@redhat.com>
root 78a5862
#
root 78a5862
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
root 78a5862
#
root 78a5862
#   Copyright (c) 2011 Red Hat, Inc. All rights reserved.
root 78a5862
#
root 78a5862
#   This copyrighted material is made available to anyone wishing
root 78a5862
#   to use, modify, copy, or redistribute it subject to the terms
root 78a5862
#   and conditions of the GNU General Public License version 2.
root 78a5862
#
root 78a5862
#   This program is distributed in the hope that it will be
root 78a5862
#   useful, but WITHOUT ANY WARRANTY; without even the implied
root 78a5862
#   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
root 78a5862
#   PURPOSE. See the GNU General Public License for more details.
root 78a5862
#
root 78a5862
#   You should have received a copy of the GNU General Public
root 78a5862
#   License along with this program; if not, write to the Free
root 78a5862
#   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
root 78a5862
#   Boston, MA 02110-1301, USA.
root 78a5862
#
root 78a5862
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
root 78a5862
root 78a5862
# Include rhts environment
root 78a5862
. /usr/bin/rhts-environment.sh
root 78a5862
. /usr/share/beakerlib/beakerlib.sh
root 78a5862
root 78a5862
PACKAGE="rsync"
root 78a5862
_TEST_USER="rsynctestuser"
root 78a5862
_TEST_USER_PASSWORD="redhat"
root 78a5862
_TEST_USER_HOME_DIR="/home/${_TEST_USER}"
root 78a5862
_TEST_USER_SRC_TEST_DIR="${_TEST_USER_HOME_DIR}/src_rsync"
root 78a5862
_TEST_USER_DST_TEST_DIR="${_TEST_USER_HOME_DIR}/dst_rsync"
root 78a5862
_TEST_RAND_FILENAME="random.data"
root 78a5862
_TEST_TEXT_FILENAME="hello_world.txt"
root 78a5862
_TEST_RAND_FILE="${_TEST_USER_SRC_TEST_DIR}/${_TEST_RAND_FILENAME}"
root 78a5862
_TEST_TEXT_FILE="${_TEST_USER_SRC_TEST_DIR}/${_TEST_TEXT_FILENAME}"
root 78a5862
_TEST_RAND_FILE_SIZE=10
root 78a5862
root 78a5862
rlJournalStart
root 78a5862
    rlPhaseStartSetup
root 78a5862
        rlAssertRpm $PACKAGE
root 78a5862
	id ${_TEST_USER} >/dev/null 2>&1 || rlRun "useradd -d ${_TEST_USER_HOME_DIR} -m ${_TEST_USER}" 0 "Creating a test user"
root 78a5862
	rlRun "echo \"${_TEST_USER_PASSWORD}\" | passwd --stdin ${_TEST_USER} >/dev/null 2>&1" 0 "Setting user's password"
root 78a5862
	rlRun "su - ${_TEST_USER} -c \"mkdir -p ${_TEST_USER_SRC_TEST_DIR} ${_TEST_USER_DST_TEST_DIR}\"" 0 "Creating directories for test data"
root 78a5862
	rlRun "su ${_TEST_USER} -c \"dd if=/dev/urandom of=${_TEST_RAND_FILE} bs=1M count=${_TEST_RAND_FILE_SIZE}\"" 0 "Generating random data file"
root 78a5862
	rlRun "su ${_TEST_USER} -c \"echo 'Hello world' >${_TEST_TEXT_FILE}\"" 0 "Generating text data file"
root 78a5862
	rlRun "setfacl -m g:root:--- ${_TEST_RAND_FILE}" 0 "Setting ACL for random data file"
root 78a5862
	rlRun "setfacl -m g:root:--- ${_TEST_TEXT_FILE}" 0 "Setting ACL for text data file"
root 78a5862
    rlPhaseEnd
root 78a5862
root 78a5862
    rlPhaseStartTest
root 78a5862
	rlRun "su - ${_TEST_USER} -c \"rsync -A ${_TEST_RAND_FILE} ${_TEST_USER_DST_TEST_DIR}\"" 0 "Syncing random data file"
root 78a5862
	rlRun "su - ${_TEST_USER} -c \"rsync -A ${_TEST_TEXT_FILE} ${_TEST_USER_DST_TEST_DIR}\"" 0 "Syncing text data file"
root 78a5862
    getfacl ${_TEST_USER_DST_TEST_DIR}/${_TEST_RAND_FILENAME}
root 78a5862
    rlRun "getfacl ${_TEST_USER_DST_TEST_DIR}/${_TEST_RAND_FILENAME} | grep 'group:root:---'" 0 "Verify that ACL was properly set"
root 78a5862
    getfacl ${_TEST_USER_DST_TEST_DIR}/${_TEST_TEXT_FILENAME}
root 78a5862
    rlRun "getfacl ${_TEST_USER_DST_TEST_DIR}/${_TEST_TEXT_FILENAME} | grep 'group:root:---'" 0 "Verify that ACL was properly set"
root 78a5862
    rlPhaseEnd
root 78a5862
root 78a5862
    rlPhaseStartCleanup
root 78a5862
	rlRun "userdel -r ${_TEST_USER}" 0 "Deleting test user"
root 78a5862
    rlPhaseEnd
root 78a5862
rlJournalPrintText
root 78a5862
rlJournalEnd
root 78a5862