2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1999 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: server_util.c,v 1.17.2.1 2006/11/24 18:05:07 martinea Exp $
32 #include "server_util.h"
40 const char *cmdstr[] = {
41 "BOGUS", "QUIT", "QUITTING", "DONE", "PARTIAL",
42 "START", "FILE-DUMP", "PORT-DUMP", "CONTINUE", "ABORT",/* dumper cmds */
43 "FAILED", "TRY-AGAIN", "NO-ROOM", "RQ-MORE-DISK", /* dumper results */
44 "ABORT-FINISHED", "BAD-COMMAND", /* dumper results */
45 "START-TAPER", "FILE-WRITE", "PORT-WRITE", /* taper cmds */
46 "PORT", "TAPE-ERROR", "TAPER-OK", "SPLIT-NEEDNEXT", /* taper results */
54 struct cmdargs * cmdargs)
59 assert(cmdargs != NULL);
62 printf("%s> ", get_pname());
64 line = readline(NULL);
69 line = stralloc("QUIT");
72 cmdargs->argc = split(line, cmdargs->argv,
73 (int)(sizeof(cmdargs->argv) / sizeof(cmdargs->argv[0])), " ");
79 fprintf(stderr,"argc = %d\n", cmdargs->argc);
80 for (i = 0; i < cmdargs->argc+1; i++)
81 fprintf(stderr,"argv[%d] = \"%s\"\n", i, cmdargs->argv[i]);
85 if (cmdargs->argc < 1)
88 for(cmd_i=BOGUS; cmdstr[cmd_i] != NULL; cmd_i++)
89 if(strcmp(cmdargs->argv[1], cmdstr[cmd_i]) == 0)
95 printf_arglist_function1(void putresult, cmd_t, result, const char *, format)
99 arglist_start(argp, format);
100 printf("%s ",cmdstr[result]);
101 vprintf(format, argp);
107 amhost_get_security_conf(
111 if(!string || !*string)
114 if(strcmp(string, "krb5principal")==0)
115 return(getconf_str(CNF_KRB5PRINCIPAL));
116 else if(strcmp(string, "krb5keytab")==0)
117 return(getconf_str(CNF_KRB5KEYTAB));
119 if(!arg || !((am_host_t *)arg)->disks) return(NULL);
121 if(strcmp(string, "amandad_path")==0)
122 return ((am_host_t *)arg)->disks->amandad_path;
123 else if(strcmp(string, "client_username")==0)
124 return ((am_host_t *)arg)->disks->client_username;
125 else if(strcmp(string, "ssh_keys")==0)
126 return ((am_host_t *)arg)->disks->ssh_keys;
137 char *hostinfodir, *old_hostinfodir, *Xhostinfodir;
138 char *diskdir, *old_diskdir, *Xdiskdir;
139 char *infofile, *old_infofile, *Xinfofile;
143 if (stat(infodir, &statbuf) != 0) {
147 for (dp = dl->head; dp != NULL; dp = dp->next) {
148 hostinfodir = sanitise_filename(dp->host->hostname);
149 diskdir = sanitise_filename(dp->name);
150 infofile = vstralloc(infodir, "/", hostinfodir, "/", diskdir,
152 if (stat(infofile, &statbuf) == -1 && errno == ENOENT) {
153 old_hostinfodir = old_sanitise_filename(dp->host->hostname);
154 old_diskdir = old_sanitise_filename(dp->name);
155 old_infofile = vstralloc(infodir, old_hostinfodir, "/",
156 old_diskdir, "/info", NULL);
157 if (stat(old_infofile, &statbuf) == 0) {
160 while (diskp != NULL) {
161 Xhostinfodir = sanitise_filename(diskp->host->hostname);
162 Xdiskdir = sanitise_filename(diskp->name);
163 Xinfofile = vstralloc(infodir, "/", Xhostinfodir, "/",
164 Xdiskdir, "/info", NULL);
165 if (strcmp(old_infofile, Xinfofile) == 0) {
173 if (other_dle_match == 0) {
174 if(mkpdir(infofile, (mode_t)02755, (uid_t)-1,
176 *errmsg = vstralloc("Can't create directory for ",
179 if(copy_file(infofile, old_infofile, errmsg) == -1)