summaryrefslogtreecommitdiffstats
path: root/instfiles/pam.d/mkpamrules
blob: e2cfb77b8e1601a391920c85ebdef0ac0c40b573 (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
#!/bin/sh

# Find suitable PAM config file

rules="$1"
srcdir="$2"
outfile="$3"

service="xrdp-sesman"
pamdir="/etc/pam.d"

guess_rules ()
{
  if test -s "$pamdir/password-auth"; then
    rules="redhat"
    return
  fi

  if test -s "$pamdir/common-account"; then
    if grep "^@include" "$pamdir/passwd" >/dev/null 2>&1; then
      rules="debian"
    else
      rules="suse"
    fi
    return
  fi

  rules="unix"
  return
}

if test "$rules" = "auto"; then
  guess_rules
fi

if test -s "$srcdir/$service.$rules"; then
  ln -nsf "$srcdir/$service.$rules" "$outfile"
else
  echo "Cannot find $srcdir/$service.$rules"
  exit 1
fi