1# 2# Copyright 2021 Northern.tech AS 3# 4# This file is part of CFEngine 3 - written and maintained by Northern.tech AS. 5# 6# This program is free software; you can redistribute it and/or modify it 7# under the terms of the GNU General Public License as published by the 8# Free Software Foundation; version 3. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program; if not, write to the Free Software 17# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 18# 19# To the extent this program is licensed as part of the Enterprise 20# versions of CFEngine, the applicable Commercial Open Source License 21# (COSL) may apply to this file if you as a licensee so wish it. See 22# included file COSL.txt. 23# 24# CF3_PATH_ROOT_PROG(variable, program, value-if-not-found, path = $PATH) 25# -------------------------------------- 26# 27# This function has almost the same semantics as the AC_PATH_PROG 28# function. The difference is that this will detect tools that are 29# runnable by root, but not by the current user. These tools are 30# typically used not by the build, but by CFEngine itself, after 31# it is installed. 32# 33AC_DEFUN([CF3_PATH_ROOT_PROG], 34[ 35 found=0 36 AS_IF([test "x$4" = "x"], [ 37 path=$PATH 38 ], [ 39 path=$4 40 ]) 41 AS_ECHO_N(["checking for $2... "]) 42 for i in $(echo $path | sed -e 's/:/ /g'); do 43 AS_IF([test -e $i/$2 && ls -ld $i/$2 | grep ['^[^ ][^ ][^ ][xs][^ ][^ ][^ ][^ ][^ ][^ ]'] > /dev/null], [ 44 $1=$i/$2 45 found=1 46 break 47 ]) 48 done 49 50 AS_IF([test "$found" = "1"], [ 51 AS_ECHO(["$][$1"]) 52 ], [ 53 AS_ECHO([no]) 54 $1=$3 55 ]) 56]) 57