summaryrefslogtreecommitdiff
path: root/perl/t/data/netdb-fake
blob: 56744a7849073502be95be87981aa6239a411c8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
# $Id$
#
# netdb-fake -- Fake NetDB remctl interface.
#
# This netdb-fake script is meant to be run by remctld during testing of
# the NetDB ACL verifier.  It returns known roles or errors for different
# nodes.

set -e

if [ "$1" != "node-roles" ] ; then
    echo "Invalid command $1" >&2
    exit 1
fi

case "$2" in
test-user)
    case "$3" in
    all)
        echo 'admin'
        echo 'team'
        echo 'user'
        ;;
    admin)
        echo 'admin'
        ;;
    team)
        echo 'team'
        ;;
    user)
        echo 'This is just ignored' >&2
        echo 'user'
        ;;
    unknown)
        echo 'admin' >&2
        echo 'unknown'
        ;;
    none)
        ;;
    esac
    ;;
error)
    case "$3" in
    normal)
        echo 'some error' >&2
        exit 1
        ;;
    status)
        exit 1
        ;;
    esac
    ;;
*)
    echo "Unknown principal $2" >&2
    exit 1
    ;;
esac