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