1#!/bin/bash -eu 2# Copyright 2021 Google LLC 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16################################################################################ 17 18function copy_lib 19 { 20 local fuzzer_path=$1 21 local lib=$2 22 cp $(ldd ${fuzzer_path} | grep "${lib}" | awk '{ print $3 }') ${OUT}/lib 23 } 24 25mkdir -p $OUT/lib 26 27git apply --ignore-whitespace $SRC/patch.diff 28# build project 29./configure --enable-fuzzer --enable-address-sanitizer 30# make tries to compile regular programs as fuzz targets 31# so -i flag ignores these errors 32make -i -j$(nproc) 33make -i install 34# use shared libraries 35ldconfig 36ls ./build/bin/local/fuzzer_* | while read i; do 37 patchelf --set-rpath '$ORIGIN/lib' ${i} 38 copy_lib ${i} libfreeradius 39 copy_lib ${i} talloc 40 copy_lib ${i} kqueue 41 cp ${i} $OUT/ 42done 43cp -r /usr/local/share/freeradius/dictionary $OUT/dict 44# export FR_DICTIONARY_DIR=/out/dictionary/ 45# export FR_LIBRARY_PATH=/out/lib/ 46