[BACK]Return to common.attr CVS log [TXT][DIR] Up to [Development] / xfs-cmds / xfstests

File: [Development] / xfs-cmds / xfstests / common.attr (download)

Revision 1.9, Tue Aug 10 03:55:47 2004 UTC (13 years, 2 months ago) by tes
Branch: MAIN
Changes since 1.8: +12 -0 lines

xfs qa changes to get thinks working on irix
add routine to help get 051 working on irix.
chacl -l doesn't exist on IRIX, need to use ls -D instead.

##/bin/sh

#
# Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
# 
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
# 
# This program is distributed in the hope that it would be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# 
# Further, this software is distributed without any warranty that it is
# free of the rightful claim of any third person regarding infringement
# or the like.  Any license provided herein, whether implied or
# otherwise, applies only to this software file.  Patent licenses, if
# any, provided herein do not apply to combinations of this program with
# other software, or any other product whatsoever.
# 
# You should have received a copy of the GNU General Public License along
# with this program; if not, write the Free Software Foundation, Inc., 59
# Temple Place - Suite 330, Boston MA 02111-1307, USA.
# 
# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
# Mountain View, CA  94043, or:
# 
# http://www.sgi.com 
# 
# For further information regarding this notice, see: 
# 
# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
#

# common extended attribute and ACL support

# pick three unused user/group ids, store them as $acl[1-3]
#
_acl_setup_ids()
{
    eval `cat /etc/passwd /etc/group | awk -F: '
      { ids[$3]=1 }
      END {
        j=1
        for(i=1; i<1000000 && j<=3;i++){
          if (! (i in ids)) {
	     printf "acl%d=%d;", j, i;		 
	     j++
          }
        }	
      }'`
}

# filter for the acl ids selected above
#
_acl_filter_id()
{
    sed \
       -e "s/u:$acl1/u:id1/" \
       -e "s/u:$acl2/u:id2/" \
       -e "s/u:$acl3/u:id3/" \
       -e "s/g:$acl1/g:id1/" \
       -e "s/g:$acl2/g:id2/" \
       -e "s/g:$acl3/g:id3/" \
       -e "s/ $acl1 / id1 /" \
       -e "s/ $acl2 / id2 /" \
       -e "s/ $acl3 / id3 /"
}

# filtered ls
#
_acl_ls()
{
    ls -ln $* | awk '{ print $1, $3, $4, $NF }' | _acl_filter_id
} 

#
_acl_list()
{
    _file1=$1

    if [ $HOSTOS = "IRIX" ]; then
	ls -D $_file1 | _acl_filter_id
    else 
        chacl -l $_file1 | _acl_filter_id
    fi
}

# create an ACL with n ACEs in it
#
_create_n_aces()
{
    n=`expr $1 - 4`
    acl='u::rwx,g::rwx,o::rwx,m::rwx' # 4 ace acl start
    while [ $n -ne 0 ]; do
       acl="$acl,u:$n:rwx"
       n=`expr $n - 1` 
    done
    echo $acl
}

# filter user ace names to user ids
#
_filter_aces()
{
    $AWK_PROG '
	BEGIN {
	    FS=":"
	    while ( getline <"/etc/passwd" > 0 ) {
		idlist[$1] = $3 
	    }
	}
	/^user/ { if ($2 in idlist) sub($2, idlist[$2]); print; next}
	/^default:user/ { if ($3 in idlist) sub($3, idlist[$3]); print; next}
	{print}
    '
}

# test if acl code will work
#
_acl_requirements()
{
    xfsdir=$TEST_DIR
    

    if [ ! -x /bin/chacl -a ! -x /usr/bin/chacl -a ! -x /sbin/chacl ]; then
    	_notrun "chacl command not found"
    fi

    # test if acl_get syscall is operational
    # and hence the ACL config has been turned on  
    touch $xfsdir/syscalltest
    if chacl -l $xfsdir/syscalltest 2>&1 | tee -a $here/$seq.full | grep 'Function not implemented' >/dev/null
    then
      cd $here
      _notrun "requires kernel ACL support"
    fi
}

# make sure this script returns success
/bin/true