2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1998 University of Maryland at College Park
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of U.M. not be used in advertising or
11 * publicity pertaining to distribution of the software without specific,
12 * written prior permission. U.M. makes no representations about the
13 * suitability of this software for any purpose. It is provided "as is"
14 * without express or implied warranty.
16 * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Authors: the Amanda Development Team. Its members are listed in a
24 * file named AUTHORS, in the root directory of this distribution.
27 * $Id: rundump.c,v 1.33 2006/07/25 18:27:56 martinea Exp $
29 * runs DUMP program as root
31 * argv[0] is the rundump program name
32 * argv[1] is the config name or NOCONFIG
33 * argv[2] will be argv[0] of the DUMP program
40 int main(int argc, char **argv);
42 #if defined(VDUMP) || defined(XFSDUMP)
47 #if !defined(USE_RUNDUMP)
48 # define ERRMSG _("rundump not enabled on this system.\n")
50 # if !defined(DUMP) && !defined(VXDUMP) && !defined(VDUMP) && !defined(XFSDUMP)
51 # define ERRMSG _("DUMP not available on this system.\n")
70 * Configure program for internationalization:
71 * 1) Only set the message locale for now.
72 * 2) Set textdomain for all amanda related programs to "amanda"
73 * We don't want to be forced to support dozens of message catalogs.
75 setlocale(LC_MESSAGES, "C");
83 /* Don't die when child closes pipe */
84 signal(SIGPIPE, SIG_IGN);
86 dbopen(DBG_SUBDIR_CLIENT);
88 error(_("Need at least 3 arguments\n"));
92 dbprintf(_("version %s\n"), version());
96 g_fprintf(stderr, ERRMSG);
97 dbprintf("%s: %s", argv[0], ERRMSG);
103 #ifdef WANT_SETUID_CLIENT
104 check_running_as(RUNNING_AS_CLIENT_LOGIN | RUNNING_AS_UID_ONLY);
105 if (!become_root()) {
106 error(_("error [%s could not become root (is the setuid bit set?)]\n"), get_pname());
110 check_running_as(RUNNING_AS_CLIENT_LOGIN);
117 dbprintf(_("config: %s\n"), argv[0]);
118 if (strcmp(argv[0], "NOCONFIG") != 0)
119 dbrename(argv[0], DBG_SUBDIR_CLIENT);
125 if (strcmp(argv[0], "xfsdump") == 0)
126 dump_program = XFSDUMP;
127 else /* strcmp(argv[0], "xfsdump") != 0 */
133 if (strcmp(argv[0], "vxdump") == 0)
134 dump_program = VXDUMP;
135 else /* strcmp(argv[0], "vxdump") != 0 */
141 if (strcmp(argv[0], "vdump") == 0)
142 dump_program = VDUMP;
143 else /* strcmp(argv[0], "vdump") != 0 */
150 # if defined(XFSDUMP)
151 dump_program = XFSDUMP;
154 dump_program = VXDUMP;
156 dump_program = "dump";
161 cmdline = stralloc(dump_program);
162 for (i = 1; argv[i]; i++) {
165 quoted = quote_string(argv[i]);
166 cmdline = vstrextend(&cmdline, " ", quoted, NULL);
169 dbprintf(_("running: %s\n"), cmdline);
172 execve(dump_program, argv, safe_env());
175 dbprintf(_("failed (%s)\n"), e);
178 g_fprintf(stderr, _("rundump: could not exec %s: %s\n"), dump_program, e);