1dnl Process this file with autoconf to produce a configure script.
2
3dnl stupid hack to properly parse $PATH for /bin
4dnl if this breaks your configure, delete it
5dnl all it does is append the first dir to the end
6dnl first_part=`echo $PATH | cut -f1 -d\:`
7dnl export PATH=$PATH:$first_part
8PATH="$PATH:/usr/local/bin"
9
10dnl
11dnl Say what we are:
12AC_INIT(scponly, 4.8, joe@sublimation.org)
13
14dnl AC_CONFIG_SRCDIR([helper.c])
15AC_CONFIG_HEADER([config.h])
16
17AC_CANONICAL_HOST
18
19# this temp_os is a brutal hack until i look into the proper way to do this. ie- rtfm
20temp_os=`echo $host_os | cut -c-7`
21if test "$temp_os" = solaris; then
22	AC_DEFINE(UNIX_COMPAT)
23fi
24temp_os=`echo $host_os | cut -c-4`
25if test "$temp_os" = irix;  then
26	AC_DEFINE(IRIX_COMPAT)
27fi
28temp_os=`echo $host_os | cut -c-3`
29if test "$temp_os" = aix; then
30	AC_DEFINE(UNIX_COMPAT)
31fi
32
33AC_DEFINE(HOST_OS,$host_os)
34
35dnl Checks for programs.
36AC_PROG_CC
37AC_PROG_INSTALL
38AC_PROG_LN_S
39AC_PATH_PROG(PROG_CUT, cut)
40AC_PATH_PROG(PROG_GREP, grep)
41AC_PATH_PROG(PROG_SORT, sort)
42AC_PATH_PROG(PROG_LDD, ldd)
43AC_PATH_PROG(PROG_USERADD, useradd)
44AC_PATH_PROG(PROG_CHOWN, chown)
45AC_PATH_PROG(PROG_CHMOD, chmod)
46AC_PATH_PROG(PROG_DIRNAME, dirname)
47AC_PATH_PROG(PROG_ID, id)
48AC_PATH_PROG(PROG_PW, pw)
49AC_PATH_PROG(PROG_RM, rm)
50AC_PATH_PROG(PROG_PWD_MKDB, pwd_mkdb)
51
52dnl Features wanted for this installation:
53dnl Command-line args to ./configure
54dnl Call options "--disable-foo" if they default to on,
55dnl call them "--enable-foo" otherwise.
56
57AC_ARG_ENABLE([restrictive-names],
58      AC_HELP_STRING([--disable-restrictive-names], [disable restrictive filename checks]),
59      [
60              if test "x$enableval" != "xno"; then
61                      AC_DEFINE([RESTRICTIVE_FILENAMES])
62              fi
63      ],[
64dnl           Default clause. This one defaults to on.
65              AC_DEFINE([RESTRICTIVE_FILENAMES])
66      ])
67
68AC_ARG_ENABLE([wildcards],
69      AC_HELP_STRING([--disable-wildcards], [disable wildcard processing]),
70      [
71dnl           Did they say anything, including an explicit --enable-wildcards?
72              if test "x$enableval" != "xno"; then
73                      AC_DEFINE([ENABLE_WILDCARDS])
74              fi
75      ],[
76dnl           Default clause. This one defaults to on.
77              AC_DEFINE([ENABLE_WILDCARDS])
78      ])
79
80AC_ARG_ENABLE([gftp-compat],
81      AC_HELP_STRING([--disable-gftp-compat], [disable gftp compatibility]),
82      [
83              if test "x$enableval" != "xno"; then
84                      AC_DEFINE([GFTP_COMPAT])
85              fi
86      ],[
87              AC_DEFINE([GFTP_COMPAT])
88      ])
89
90AC_ARG_WITH([sftp-server],
91      AC_HELP_STRING([--with-sftp-server], [path to sftp-server binary [defaults to on+guessed]]),
92      [
93              if test "x$withval" != "xno"; then
94dnl                   --without-sftp-server is a perfectly good
95dnl                   way of requesting that sftp compatability *not*
96dnl                   be present.
97                      scponly_explicit_sftpserver_path=$withval
98                      dnl  TODO: should test viability...
99                      AC_DEFINE([ENABLE_SFTP])
100                      scponly_sftp_compat=1
101              fi
102      ],[
103              AC_DEFINE([ENABLE_SFTP])
104              scponly_sftp_compat=1
105      ])
106
107AC_ARG_ENABLE([winscp-compat],
108      AC_HELP_STRING([--enable-winscp-compat], [enable winscp (and scp) compatibility]),
109      [
110              if test "x$enableval" != "xno"; then
111                      scponly_scp_compat=1
112                      AC_DEFINE([ENABLE_SCP2])
113                      AC_DEFINE([WINSCP_COMPAT])
114              fi
115      ],[
116              echo -n      dnl  Defaults to off, must be turned on explicitly
117      ])
118
119AC_ARG_WITH([default-chdir],
120	AC_HELP_STRING([--with-default-chdir=DIR], [cd to this directory after authentication (only for interactive logins)]),
121		[
122			AC_DEFINE([ENABLE_DEFAULT_CHDIR])
123			AC_DEFINE_UNQUOTED([DEFAULT_CHDIR], ["$withval"])
124		],[
125			echo -n      dnl  Defaults to off, must be turned on explicitly
126		])
127
128AC_ARG_ENABLE([unison-compat],
129      AC_HELP_STRING([--enable-unison-compat], [enable unison compatibility]),
130      [
131              if test "x$enableval" != "xno"; then
132                      AC_DEFINE([UNISON_COMPAT])
133              fi
134      ],[
135              echo -n      dnl  Defaults to off, must be turned on explicitly
136      ])
137
138AC_ARG_ENABLE([scp-compat],
139      AC_HELP_STRING([--enable-scp-compat], [enable scp compatibility]),
140      [
141              if test "x$enableval" != "xno"; then
142					AC_DEFINE([ENABLE_SCP2])
143					scponly_scp_compat=1
144              fi
145      ],[
146              echo -n      dnl  Defaults to off, must be turned on explicitly
147      ])
148
149AC_ARG_ENABLE([rsync-compat],
150      AC_HELP_STRING([--enable-rsync-compat], [enable rsync compatibility]),
151      [
152              if test "x$enableval" != "xno"; then
153                      AC_DEFINE([RSYNC_COMPAT])
154              fi
155      ],[
156              echo -n      dnl  Defaults to off, must be turned on explicitly
157      ])
158
159AC_ARG_ENABLE([chrooted-binary],
160      AC_HELP_STRING([--enable-chrooted-binary], [install chrooted binary 'scponlyc']),
161      [
162              if test "x$enableval" != "xno"; then
163                      AC_SUBST([CHROOTED_NAME], [scponlyc])
164                      AC_DEFINE([CHROOTED_NAME], ["scponlyc"])
165              fi
166      ],[
167              echo -n
168      ])
169
170AC_ARG_ENABLE([chroot-checkdir],
171      AC_HELP_STRING([--disable-chroot-checkdir], [disable checking chroot dir ownership]),
172      [
173              if test "x$enableval" != "xno"; then
174                      AC_DEFINE([CHROOT_CHECKDIR])
175              fi
176      ],[
177dnl           Default clause. This one defaults to on.
178              AC_DEFINE([CHROOT_CHECKDIR])
179      ])
180
181AC_ARG_ENABLE([svn-compat],
182      AC_HELP_STRING([--enable-svn-compat], [enable subversion SCS cli compatibility]),
183      [
184              if test "x$enableval" != "xno"; then
185                      AC_DEFINE([SVN_COMPAT])
186              fi
187      ],[
188              echo -n      dnl  Defaults to off, must be turned on explicitly
189      ])
190
191AC_ARG_ENABLE([svnserv-compat],
192      AC_HELP_STRING([--enable-svnserv-compat], [enable subversion SCS svnserve compatibility]),
193      [
194              if test "x$enableval" != "xno"; then
195                      AC_DEFINE([SVNSERV_COMPAT])
196              fi
197      ],[
198              echo -n      dnl  Defaults to off, must be turned on explicitly
199      ])
200
201AC_ARG_ENABLE([passwd-compat],
202      AC_HELP_STRING([--enable-passwd-compat], [enable passwd compatibility]),
203      [
204              if test "x$enableval" != "xno"; then
205                      AC_DEFINE([PASSWD_COMPAT])
206              fi
207      ],[
208              echo -n      dnl  Defaults to off, must be turned on explicitly
209      ])
210
211AC_ARG_ENABLE([quota-compat],
212      AC_HELP_STRING([--enable-quota-compat], [enable quota compatibility]),
213      [
214              if test "x$enableval" != "xno"; then
215                      AC_DEFINE([QUOTA_COMPAT])
216              fi
217      ],[
218              echo -n      dnl  Defaults to off, must be turned on explicitly
219      ])
220
221if test "x$scponly_scp_compat" != "x"; then
222	AC_MSG_NOTICE([enabling core WinSCP and Vanilla SCP binaries...])
223	SCPONLY_PATH_PROG_DEFINE([PROG_SFTP_SERVER], [sftp-server],[/usr/lib:/usr/lib64:/usr/libexec:/usr/libexec/openssh:/usr/lib/ssh:/usr/lib64/ssh:/usr/local/libexec:/usr/lib/misc:/usr/lib/openssh])
224	SCPONLY_PATH_PROG_DEFINE([PROG_LS],    [ls],    [/bin:/usr/bin:/sbin:/usr/sbin])
225	SCPONLY_PATH_PROG_DEFINE([PROG_SCP],   [scp],   [/bin:/usr/bin:/sbin:/usr/sbin])
226	SCPONLY_PATH_PROG_DEFINE([PROG_RM],    [rm],    [/bin:/usr/bin:/sbin:/usr/sbin])
227	SCPONLY_PATH_PROG_DEFINE([PROG_LN],    [ln],    [/bin:/usr/bin:/sbin:/usr/sbin])
228	SCPONLY_PATH_PROG_DEFINE([PROG_MV],    [mv],    [/bin:/usr/bin:/sbin:/usr/sbin])
229	SCPONLY_PATH_PROG_DEFINE([PROG_CHMOD], [chmod], [/bin:/usr/bin:/sbin:/usr/sbin])
230	SCPONLY_PATH_PROG_DEFINE([PROG_CHOWN], [chown], [/bin:/usr/bin:/sbin:/usr/sbin])
231	SCPONLY_PATH_PROG_DEFINE([PROG_CHGRP], [chgrp], [/bin:/usr/bin:/sbin:/usr/sbin])
232	SCPONLY_PATH_PROG_DEFINE([PROG_MKDIR], [mkdir], [/bin:/usr/bin:/sbin:/usr/sbin])
233	SCPONLY_PATH_PROG_DEFINE([PROG_RMDIR], [rmdir], [/bin:/usr/bin:/sbin:/usr/sbin])
234fi
235
236dnl Check for binaries required by the WinSCP compatibility mode
237dnl winscp-compat conditionals:
238if test "x$enable_winscp_compat" != "xno"; then
239    AC_MSG_NOTICE([enabling WinSCP compatability...])
240	SCPONLY_PATH_PROG_DEFINE([PROG_PWD],    [pwd],    [/bin:/usr/bin:/sbin:/usr/sbin])
241	SCPONLY_PATH_PROG_DEFINE([PROG_GROUPS], [groups], [/bin:/usr/bin:/sbin:/usr/sbin])
242	SCPONLY_PATH_PROG_DEFINE([PROG_ID], 	[id],     [/bin:/usr/bin:/sbin:/usr/sbin])
243	SCPONLY_PATH_PROG_DEFINE([PROG_ECHO],   [echo],   [/bin:/usr/bin:/sbin:/usr/sbin])
244fi
245
246# unison-compat conditionals:
247if test "x$enable_unison_compat" != "x" && test "x$enable_unison_compat" != "xno"; then
248	AC_MSG_WARN([read the SECURITY document before enabling unison compatibility])
249	AC_MSG_NOTICE([enabling unison compatability...])
250	SCPONLY_PATH_PROG_DEFINE([PROG_UNISON],   [unison], [/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin])
251fi
252
253# rsync-compat conditionals:
254if test "x$enable_rsync_compat" != "x" && test "x$enable_rsync_compat" != "xno"; then
255	AC_MSG_WARN([read the SECURITY document before enabling rsync compatibility])
256	AC_MSG_NOTICE([enabling rsync compatability...])
257	SCPONLY_PATH_PROG_DEFINE([PROG_RSYNC],   [rsync], [/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin])
258fi
259
260dnl Find the svnserve and svn binaries
261if test "x$enable_svnserv_compat" != "x" && test "x$enable_svnserv_compat" != "xno"; then
262	AC_MSG_WARN([read the SECURITY document before enabling svnserv compatibility])
263	AC_MSG_NOTICE([enabling svnserv compatibility...])
264	SCPONLY_PATH_PROG_DEFINE([PROG_SVNSERV], [svnserve], [/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin])
265fi
266
267if test "x$enable_svn_compat" != "x" && test "x$enable_svn_compat" != "xno"; then
268	AC_MSG_WARN([read the SECURITY document before enabling svn compatibility])
269	AC_MSG_NOTICE([enabling subversion compatability...])
270	SCPONLY_PATH_PROG_DEFINE([PROG_SVN],   [svn],   [/bin:/usr/bin:/usr/local/bin:/usr/local/bin])
271fi
272
273if test "x$enable_passwd_compat" != "x" && test "x$enable_passwd_compat" != "xno"; then
274	AC_MSG_NOTICE([enabling passwd compatability...])
275	SCPONLY_PATH_PROG_DEFINE([PROG_PASSWD],   [passwd],   [/bin:/usr/bin:/sbin:/usr/sbin])
276fi
277
278if test "x$enable_quota_compat" != "x" && test "x$enable_quota_compat" != "xno"; then
279	AC_MSG_NOTICE([enabling quota compatability...])
280	SCPONLY_PATH_PROG_DEFINE([PROG_QUOTA],   [quota],   [/bin:/usr/bin:/sbin:/usr/sbin])
281fi
282
283dnl with-sftp-server conditionals:
284if test "x$scponly_sftp_compat" != "x"; then
285  AC_MSG_NOTICE([enabling SFTP compatability...])
286  if test "x$scponly_explicit_sftpserver_path" = "x"; then
287      dnl Informed guess:
288      SCPONLY_PATH_PROG_DEFINE([PROG_SFTP_SERVER], [sftp-server],
289       [/usr/lib:/usr/lib/ssh:/usr/libexec/openssh:/usr/libexec:/usr/local/libexec])
290      dnl Debian uses /usr/lib
291      dnl Red Hat uses /usr/libexec/openssh
292      dnl Many a *BSD uses $PATH itself (which is implicit + checked 1st)
293      dnl Lupe says FreeBSD wants /usr/[local]/libexec
294      dnl I've seen it in /usr/lib/ssh under Mandrake 8.1
295  else
296      dnl Do what SCPONLY_PATH_PROG_DEFINE does:
297      echo checking for sftp-server... $scponly_explicit_sftpserver_path
298      AC_DEFINE_UNQUOTED([PROG_SFTP_SERVER], ["$scponly_explicit_sftpserver_path"])
299      scponly_PROG_SFTP_SERVER=$scponly_explicit_sftpserver_path
300  fi
301fi
302
303dnl Checks for libraries.
304dnl Checks for header files.
305AC_HEADER_STDC
306AC_CHECK_HEADERS([stdlib.h string.h syslog.h unistd.h wordexp.h glob.h libgen.h getopt.h])
307
308dnl Checks for typedefs, structures, and compiler characteristics.
309AC_C_CONST
310AC_C_INLINE
311
312dnl Checks for library functions.
313AC_FUNC_ALLOCA
314AC_CHECK_FUNCS([malloc atexit bzero strchr strerror glob wordexp strspn basename getopt])
315
316AC_CHECK_DECL(optreset,
317 AC_DEFINE([HAVE_OPTRESET],[1],[have optreset]),,
318 [#include <getopt.h>] )
319
320dnl AC_CONFIG_FILES([Makefile])
321AC_OUTPUT([Makefile setup_chroot.sh])
322