github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/hack/libsubid_tag.sh (about)

     1  #!/usr/bin/env bash
     2  if test $(${GO:-go} env GOOS) != "linux" ; then
     3  	exit 0
     4  fi
     5  tmpdir="$PWD/tmp.$RANDOM"
     6  mkdir -p "$tmpdir"
     7  trap 'rm -fr "$tmpdir"' EXIT
     8  cc -o "$tmpdir"/libsubid_tag -l subid -x c - > /dev/null 2> /dev/null << EOF
     9  #include <shadow/subid.h>
    10  #include <stdio.h>
    11  #include <stdlib.h>
    12  
    13  const char *Prog = "test";
    14  FILE *shadow_logfd = NULL;
    15  
    16  int main() {
    17  	struct subid_range *ranges = NULL;
    18  #if SUBID_ABI_MAJOR >= 4
    19  	subid_get_uid_ranges("root", &ranges);
    20  #else
    21  	get_subuid_ranges("root", &ranges);
    22  #endif
    23  	free(ranges);
    24  	return 0;
    25  }
    26  EOF
    27  if test $? -eq 0 ; then
    28  	echo libsubid
    29  fi