Imported Upstream version 3.2.0
[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, and also sets AM_CONDITIONAL CHECK_USERID
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     AM_CONDITIONAL(CHECK_USERID, test x"$CHECK_USERID" = x"1")
56 ])
57
58 # SYNOPSIS
59 #
60 #   AMANDA_WITH_USER
61 #
62 # OVERVIEW
63 #
64 #   Handle the --with-user option, which sets the userid Amanda expects to run
65 #   under.  Defines and substitutes CLIENT_LOGIN.
66 #
67 AC_DEFUN([AMANDA_WITH_USER],
68 [
69     AC_ARG_WITH(user,
70         AS_HELP_STRING([--with-user=USER],
71                 [force execution to USER on client systems (REQUIRED)]),
72         [
73             case "$withval" in
74                 "" | y | ye | yes | n | no)
75                     AC_MSG_ERROR([*** You must supply an argument to the --with-user option.])
76                   ;;
77                 *) 
78                     CLIENT_LOGIN="$withval"
79                   ;;
80             esac
81         ], [
82             AMANDA_MSG_WARN([[no user specified (--with-user) -- using 'amanda']])
83             CLIENT_LOGIN=amanda
84         ]
85     )
86
87     AC_DEFINE_UNQUOTED(CLIENT_LOGIN,"$CLIENT_LOGIN",
88         [Define as a the user to force to on client machines. ])
89     AC_SUBST(CLIENT_LOGIN)
90 ])
91
92 # SYNOPSIS
93 #
94 #   AMANDA_WITH_GROUP
95 #
96 # OVERVIEW
97 #
98 #   Handle the --with-group option, which sets the groupid Amanda expects to run
99 #   under.  Substitutes (but does not define) SETUID_GROUP.
100 #
101 AC_DEFUN([AMANDA_WITH_GROUP],
102 [
103     AC_ARG_WITH(group,
104         AS_HELP_STRING([--with-group=GROUP],
105             [group allowed to execute setuid-root programs (REQUIRED)]),
106         [
107             case "$withval" in
108                 "" | y | ye | yes | n | no)
109                     AC_MSG_ERROR([*** You must supply an argument to the --with-group option.])
110                   ;;
111                 *) SETUID_GROUP="$withval"
112                   ;;
113             esac
114         ], [
115             AMANDA_MSG_WARN([[no group specified (--with-group) -- using 'backup']])
116             SETUID_GROUP=backup
117         ]
118     )
119     AC_SUBST(SETUID_GROUP)
120 ])
121
122 # SYNOPSIS
123 #
124 #   AMANDA_WITH_OWNER
125 #
126 # OVERVIEW
127 #
128 #   Handle the --with-owner option, which sets the userid the 'make install' process
129 #   will use.  Substitutes and defines BINARY_OWNER.
130 #
131 AC_DEFUN([AMANDA_WITH_OWNER],
132 [
133     AC_REQUIRE([AMANDA_WITH_USER])
134     AC_ARG_WITH(owner,
135         AS_HELP_STRING([--with-owner=USER]
136             [force ownership of installed files to USER (default same as --with-user)]),
137         [
138             case "$withval" in
139             "" | y | ye | yes | n | no)
140                 AC_MSG_ERROR([*** You must supply an argument to the --with-owner option.])
141               ;;
142             *) BINARY_OWNER="$withval"
143               ;;
144             esac
145         ], [
146             BINARY_OWNER="$CLIENT_LOGIN"
147         ]
148     )
149     AC_DEFINE_UNQUOTED(BINARY_OWNER,"$BINARY_OWNER",
150         [Define as the user who owns installed binaries. ])
151     AC_SUBST(BINARY_OWNER)
152 ])
153
154 # SYNOPSIS
155 #
156 #   AMANDA_WITH_SINGLE_USERID
157 #
158 # OVERVIEW
159 #
160 #   Check if this system is one on which clients should be built setuid, 
161 #   Sets up AM_CONDITIONAL/define WANT_SETUID_CLIENT and defines 
162 #   SINGLE_USERID if either the system requires it or the user specified it.
163 #
164 AC_DEFUN([AMANDA_WITH_SINGLE_USERID],
165 [
166     SINGLE_USERID=${SINGLE_USERID:-no}
167     WANT_SETUID_CLIENT=${WANT_SETUID_CLIENT:-true}
168
169     AC_ARG_WITH(single-userid,
170         AS_HELP_STRING([--with-single-userid]
171             [force amanda to run as a single userid (for testing)]),
172         [   SINGLE_USERID=$withval ])
173
174     case "$host" in
175         *-pc-cygwin)
176             WANT_SETUID_CLIENT=false
177             SINGLE_USERID=yes
178             ;;
179     esac
180
181     if test x"$WANT_SETUID_CLIENT" = x"true"; then
182         AC_DEFINE(WANT_SETUID_CLIENT,1,
183             [Define if clients should be built setuid-root])
184     fi
185     AM_CONDITIONAL(WANT_SETUID_CLIENT, test x"$WANT_SETUID_CLIENT" = x"true")
186
187     if test x"$SINGLE_USERID" = x"yes"; then
188         AC_DEFINE(SINGLE_USERID, 1,
189             [Define if all of Amanda will run as a single userid (e.g., on Cygwin or for installchecks)])
190     fi
191 ])