2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1998 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: rundump.c,v 1.33 2006/07/25 18:27:56 martinea Exp $
30 * runs DUMP program as root
32 * argv[0] is the rundump program name
33 * argv[1] is the config name or NOCONFIG
34 * argv[2] will be argv[0] of the DUMP program
41 int main(int argc, char **argv);
43 #if defined(VDUMP) || defined(XFSDUMP)
48 #if !defined(USE_RUNDUMP)
49 # define ERRMSG _("rundump not enabled on this system.\n")
51 # if !defined(DUMP) && !defined(VXDUMP) && !defined(VDUMP) && !defined(XFSDUMP)
52 # define ERRMSG _("DUMP not available on this system.\n")
70 if (argc > 1 && argv && argv[1] && g_str_equal(argv[1], "--version")) {
71 printf("rundump-%s\n", VERSION);
76 * Configure program for internationalization:
77 * 1) Only set the message locale for now.
78 * 2) Set textdomain for all amanda related programs to "amanda"
79 * We don't want to be forced to support dozens of message catalogs.
81 setlocale(LC_MESSAGES, "C");
89 /* Don't die when child closes pipe */
90 signal(SIGPIPE, SIG_IGN);
92 dbopen(DBG_SUBDIR_CLIENT);
93 config_init(CONFIG_INIT_CLIENT, NULL);
96 error(_("Need at least 3 arguments\n"));
100 dbprintf(_("version %s\n"), VERSION);
102 #ifdef ERRMSG /* { */
104 g_fprintf(stderr, ERRMSG);
105 dbprintf("%s: %s", argv[0], ERRMSG);
111 #ifdef WANT_SETUID_CLIENT
112 check_running_as(RUNNING_AS_CLIENT_LOGIN | RUNNING_AS_UID_ONLY);
113 if (!become_root()) {
114 error(_("error [%s could not become root (is the setuid bit set?)]\n"), get_pname());
118 check_running_as(RUNNING_AS_CLIENT_LOGIN);
125 dbprintf(_("config: %s\n"), argv[0]);
126 if (strcmp(argv[0], "NOCONFIG") != 0)
127 dbrename(argv[0], DBG_SUBDIR_CLIENT);
133 if (strcmp(argv[0], "xfsdump") == 0)
134 dump_program = XFSDUMP;
135 else /* strcmp(argv[0], "xfsdump") != 0 */
141 if (strcmp(argv[0], "vxdump") == 0)
142 dump_program = VXDUMP;
143 else /* strcmp(argv[0], "vxdump") != 0 */
149 if (strcmp(argv[0], "vdump") == 0)
150 dump_program = VDUMP;
151 else /* strcmp(argv[0], "vdump") != 0 */
158 # if defined(XFSDUMP)
159 dump_program = XFSDUMP;
162 dump_program = VXDUMP;
164 dump_program = "dump";
169 cmdline = stralloc(dump_program);
170 for (i = 1; argv[i]; i++) {
173 quoted = quote_string(argv[i]);
174 cmdline = vstrextend(&cmdline, " ", quoted, NULL);
177 dbprintf(_("running: %s\n"), cmdline);
180 execve(dump_program, argv, safe_env());
183 dbprintf(_("failed (%s)\n"), e);
186 g_fprintf(stderr, _("rundump: could not exec %s: %s\n"), dump_program, e);