c659395a51e9fb88516d918dee89fa93290e00c4
[debian/amanda] / config / amanda / userid.m4
1 # SYNOPSIS
2 #
3 #   AMANDA_DISABLE_INSTALLPERMS
4 #
5 # OVERVIEW
6 #
7 #   Handle the --disable-installperms option, which disables all post-install
8 #   chown/chmod operations.  This is useful when packaging, as most packaging
9 #   systems build as non-root, and apply permissions in the post-install step of
10 #   the package itself.
11 #
12 AC_DEFUN([AMANDA_DISABLE_INSTALLPERMS],
13 [
14     WANT_INSTALLPERMS=yes
15     AC_ARG_ENABLE(installperms,
16         AS_HELP_STRING([--disable-installperms],
17                 [do not modify ownership and permissions on installed files]),
18         [ WANT_INSTALLPERMS="$enableval" ],
19         [ WANT_INSTALLPERMS="yes" ]
20     )
21     AM_CONDITIONAL(WANT_INSTALLPERMS, test x"$WANT_INSTALLPERMS" = x"yes")
22 ])
23
24 # SYNOPSIS
25 #
26 #   AMANDA_WITH_FORCE_UID
27 #
28 # OVERVIEW
29 #
30 #   Handle the --without-force-id option, which disables userid checks for
31 #   all Amanda applications.  Defines and substitutes CHECK_USERID *unless* 
32 #   this option is given.
33 #
34 AC_DEFUN([AMANDA_WITH_FORCE_UID],
35 [
36     AC_ARG_WITH(force-uid,
37         AS_HELP_STRING([--without-force-uid],
38                 [do not check userids when running programs]),
39         CHECK_USERID="$withval",
40         : ${CHECK_USERID=yes}
41     )
42     case "$CHECK_USERID" in
43         y | ye | yes) 
44             CHECK_USERID=1
45             AC_DEFINE(CHECK_USERID, 1,
46                 [Define to force to another user on client machines. ])
47           ;;
48         n | no) :
49             CHECK_USERID=
50           ;;
51         *)
52             AC_MSG_ERROR([*** You must not supply an argument to --with-force-uid option.])
53     esac
54     AC_SUBST(CHECK_USERID)
55 ])
56
57 # SYNOPSIS
58 #
59 #   AMANDA_WITH_USER
60 #
61 # OVERVIEW
62 #
63 #   Handle the --with-user option, which sets the userid Amanda expects to run
64 #   under.  Defines and substitutes CLIENT_LOGIN.
65 #
66 AC_DEFUN([AMANDA_WITH_USER],
67 [
68     AC_ARG_WITH(user,
69         AS_HELP_STRING([--with-user=USER],
70                 [force execution to USER on client systems (REQUIRED)]),
71         [
72             case "$withval" in
73                 "" | y | ye | yes | n | no)
74                     AC_MSG_ERROR([*** You must supply an argument to the --with-user option.])
75                   ;;
76                 *) 
77                     CLIENT_LOGIN="$withval"
78                   ;;
79             esac
80         ], [
81             AMANDA_MSG_WARN([[no user specified (--with-user) -- using 'amanda']])
82             CLIENT_LOGIN=amanda
83         ]
84     )
85
86     AC_DEFINE_UNQUOTED(CLIENT_LOGIN,"$CLIENT_LOGIN",
87         [Define as a the user to force to on client machines. ])
88     AC_SUBST(CLIENT_LOGIN)
89 ])
90
91 # SYNOPSIS
92 #
93 #   AMANDA_WITH_GROUP
94 #
95 # OVERVIEW
96 #
97 #   Handle the --with-group option, which sets the groupid Amanda expects to run
98 #   under.  Substitutes (but does not define) SETUID_GROUP.
99 #
100 AC_DEFUN([AMANDA_WITH_GROUP],
101 [
102     AC_ARG_WITH(group,
103         AS_HELP_STRING([--with-group=GROUP],
104             [group allowed to execute setuid-root programs (REQUIRED)]),
105         [
106             case "$withval" in
107                 "" | y | ye | yes | n | no)
108                     AC_MSG_ERROR([*** You must supply an argument to the --with-group option.])
109                   ;;
110                 *) SETUID_GROUP="$withval"
111                   ;;
112             esac
113         ], [
114             AMANDA_MSG_WARN([[no group specified (--with-group) -- using 'backup']])
115             CLIENT_LOGIN=backup
116         ]
117     )
118     AC_SUBST(SETUID_GROUP)
119 ])
120
121 # SYNOPSIS
122 #
123 #   AMANDA_WITH_OWNER
124 #
125 # OVERVIEW
126 #
127 #   Handle the --with-owner option, which sets the userid the 'make install' process
128 #   will use.  Substitutes and defines BINARY_OWNER.
129 #
130 AC_DEFUN([AMANDA_WITH_OWNER],
131 [
132     AC_REQUIRE([AMANDA_WITH_USER])
133     AC_ARG_WITH(owner,
134         AS_HELP_STRING([--with-owner=USER]
135             [force ownership of installed files to USER (default same as --with-user)]),
136         [
137             case "$withval" in
138             "" | y | ye | yes | n | no)
139                 AC_MSG_ERROR([*** You must supply an argument to the --with-owner option.])
140               ;;
141             *) BINARY_OWNER="$withval"
142               ;;
143             esac
144         ], [
145             BINARY_OWNER="$CLIENT_LOGIN"
146         ]
147     )
148     AC_DEFINE_UNQUOTED(BINARY_OWNER,"$BINARY_OWNER",
149         [Define as the user who owns installed binaries. ])
150     AC_SUBST(BINARY_OWNER)
151 ])
152
153 # SYNOPSIS
154 #
155 #   AMANDA_WITH_SINGLE_USERID
156 #
157 # OVERVIEW
158 #
159 #   Check if this system is one on which clients should be built setuid, 
160 #   Sets up AM_CONDITIONAL/define WANT_SETUID_CLIENT and defines 
161 #   SINGLE_USERID if either the system requires it or the user specified it.
162 #
163 AC_DEFUN([AMANDA_WITH_SINGLE_USERID],
164 [
165     SINGLE_USERID=${SINGLE_USERID:-no}
166     WANT_SETUID_CLIENT=${WANT_SETUID_CLIENT:-true}
167
168     AC_ARG_WITH(single-userid,
169         AS_HELP_STRING([--with-single-userid]
170             [force amanda to run as a single userid (for testing)]),
171         [   SINGLE_USERID=$withval ])
172
173     case "$target" in
174         *-pc-cygwin)
175             WANT_SETUID_CLIENT=false
176             SINGLE_USERID=yes
177             ;;
178     esac
179
180     if test x"$WANT_SETUID_CLIENT" = x"true"; then
181         AC_DEFINE(WANT_SETUID_CLIENT,1,
182             [Define if clients should be built setuid-root])
183     fi
184     AM_CONDITIONAL(WANT_SETUID_CLIENT, test x"$WANT_SETUID_CLIENT" = x"true")
185
186     if test x"$SINGLE_USERID" = x"yes"; then
187         AC_DEFINE(SINGLE_USERID, 1,
188             [Define if all of Amanda will run as a single userid (e.g., on Cygwin or for installchecks)])
189     fi
190 ])