2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1999 University of Maryland at College Park
4 * Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved.
7 * Permission to use, copy, modify, distribute, and sell this software and its
8 * documentation for any purpose is hereby granted without fee, provided that
9 * the above copyright notice appear in all copies and that both that
10 * copyright notice and this permission notice appear in supporting
11 * documentation, and that the name of U.M. not be used in advertising or
12 * publicity pertaining to distribution of the software without specific,
13 * written prior permission. U.M. makes no representations about the
14 * suitability of this software for any purpose. It is provided "as is"
15 * without express or implied warranty.
17 * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
19 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
21 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 * Authors: the Amanda Development Team. Its members are listed in a
25 * file named AUTHORS, in the root directory of this distribution.
28 * $Id: security.c,v 1.28 2006/05/25 01:47:12 johnfranks Exp $
30 * Security driver interface for the Amanda backup system.
39 extern const security_driver_t bsd_security_driver;
42 extern const security_driver_t krb5_security_driver;
45 extern const security_driver_t rsh_security_driver;
48 extern const security_driver_t ssh_security_driver;
50 #ifdef BSDTCP_SECURITY
51 extern const security_driver_t bsdtcp_security_driver;
53 #ifdef BSDUDP_SECURITY
54 extern const security_driver_t bsdudp_security_driver;
56 extern const security_driver_t local_security_driver;
58 static const security_driver_t *drivers[] = {
63 &krb5_security_driver,
71 #ifdef BSDTCP_SECURITY
72 &bsdtcp_security_driver,
74 #ifdef BSDUDP_SECURITY
75 &bsdudp_security_driver,
77 &local_security_driver,
79 #define NDRIVERS (size_t)(sizeof(drivers) / sizeof(drivers[0]))
82 * Given a name of a security type, returns the driver structure
84 const security_driver_t *
92 for (i = 0; i < NDRIVERS; i++) {
93 if (strcasecmp(name, drivers[i]->name) == 0) {
94 dbprintf(_("security_getdriver(name=%s) returns %p\n"),
99 dbprintf(_("security_getdriver(name=%s) returns NULL\n"), name);
104 * For the drivers: initialize the common part of a security_handle_t
108 security_handle_t * handle,
109 const security_driver_t * driver)
111 dbprintf(_("security_handleinit(handle=%p, driver=%p (%s))\n"),
112 handle, driver, driver->name);
113 handle->driver = driver;
114 handle->error = stralloc(_("unknown protocol error"));
117 printf_arglist_function1(void security_seterror, security_handle_t *, handle,
120 static char buf[1024];
123 assert(handle->error != NULL);
124 arglist_start(argp, fmt);
125 g_vsnprintf(buf, SIZEOF(buf), fmt, argp);
127 handle->error = newstralloc(handle->error, buf);
128 dbprintf(_("security_seterror(handle=%p, driver=%p (%s) error=%s)\n"),
129 handle, handle->driver,
130 handle->driver->name, handle->error);
135 security_handle_t * handle)
137 dbprintf(_("security_close(handle=%p, driver=%p (%s))\n"),
138 handle, handle->driver,
139 handle->driver->name);
140 amfree(handle->error);
141 (*handle->driver->close)(handle);
145 * For the drivers: initialize the common part of a security_stream_t
149 security_stream_t * stream,
150 const security_driver_t * driver)
152 dbprintf(_("security_streaminit(stream=%p, driver=%p (%s))\n"),
153 stream, driver, driver->name);
154 stream->driver = driver;
155 stream->error = stralloc(_("unknown stream error"));
158 printf_arglist_function1(void security_stream_seterror,
159 security_stream_t *, stream,
162 static char buf[1024];
165 arglist_start(argp, fmt);
166 g_vsnprintf(buf, SIZEOF(buf), fmt, argp);
168 stream->error = newstralloc(stream->error, buf);
169 dbprintf(_("security_stream_seterr(%p, %s)\n"), stream, stream->error);
173 security_stream_close(
174 security_stream_t * stream)
176 dbprintf(_("security_stream_close(%p)\n"), stream);
177 amfree(stream->error);
178 (*stream->driver->stream_close)(stream);