9fd8d9758c1a7ad5c6f28bf4d69bfcc94769f9e2
[debian/amanda] / config / amanda / ssh-security.m4
1 # SYNOPSIS
2 #
3 #   AMANDA_SSH_SECURITY
4 #
5 # OVERVIEW
6 #
7 #   Handle configuration for SSH security, implementing the --with-ssh-security
8 #   option and checking for the relevant programs and options.
9 #
10 AC_DEFUN([AMANDA_SSH_SECURITY],
11 [
12     SSH_SECURITY=no
13     AC_ARG_WITH(ssh-security,
14         AS_HELP_STRING([--with-ssh-security], 
15                 [include SSH authentication]),
16         [
17             case "$withval" in
18                 n | no) : ;;
19                 y |  ye | yes) SSH_SECURITY=yes ;;
20                 *) AC_MSG_ERROR([*** You must not supply an argument to --with-ssh-security.])
21               ;;
22             esac
23         ],
24     )
25
26     if test "x$SSH_SECURITY" = "xyes"; then
27         # find the SSH binary
28         AC_PATH_PROGS(SSH, ssh, , $LOCSYSPATH)
29
30         # see what options we should use
31         AC_ARG_WITH(ssh-options,
32             AS_HELP_STRING([ --with-ssh-options=@<:@OPTIONS@:>@],
33                [Use these ssh options for ssh security; the default should work]),
34             [ SSH_OPTIONS="$withval" ],
35             [ SSH_OPTIONS='' ]
36         )
37
38         case "$SSH_OPTIONS" in
39             y | ye | yes | n | no)
40                 AC_MSG_ERROR([*** You must supply an argument to --with-ssh-options.]);;
41             *) : ;;
42         esac
43
44         AC_MSG_CHECKING([SSH options])
45         # if we didn't get SSH options from the user, figure them out for ourselves
46         if test -z "$SSH_OPTIONS"; then
47             case `$SSH -V 2>&1` in
48                 OpenSSH*) SSH_OPTIONS='-x -o BatchMode=yes -o PreferredAuthentications=publickey';;
49                 *) SSH_OPTIONS='-x -o BatchMode=yes' ;;
50             esac
51         fi
52
53         # now convert that to a comma-separated list of C strings
54         eval "set dummy ${SSH_OPTIONS}"; shift
55         SSH_OPTIONS=''
56         for i in "${@}"; do 
57             quoted="\"`echo "$i" | sed -e 's/\"/\\\"/'`\""
58             SSH_OPTIONS="${SSH_OPTIONS}${SSH_OPTIONS:+, }$quoted"; 
59         done
60         AC_MSG_RESULT($SSH_OPTIONS)
61
62         # finally, make the various outputs for all of this
63         AC_DEFINE(SSH_SECURITY,1,
64                 [Define if SSH transport should be enabled. ])
65         AC_DEFINE_UNQUOTED(SSH, "$SSH", 
66                 [Path to the SSH binary])
67         AC_DEFINE_UNQUOTED(SSH_OPTIONS, $SSH_OPTIONS, 
68                 [Arguments to ssh])
69     fi
70     AM_CONDITIONAL(WANT_SSH_SECURITY, test x"$SSH_SECURITY" = x"yes")
71 ])