PageRenderTime 50ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/amanda/tags/3_3_0beta1/recover-src/set_commands.c

#
C | 851 lines | 661 code | 91 blank | 99 comment | 184 complexity | 9b4211e92607c2a8e0f9a91cc74c7d61 MD5 | raw file
  1. /*
  2. * Amanda, The Advanced Maryland Automatic Network Disk Archiver
  3. * Copyright (c) 1991-1998, 2000 University of Maryland at College Park
  4. * All Rights Reserved.
  5. *
  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.
  15. *
  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.
  22. *
  23. * Authors: the Amanda Development Team. Its members are listed in a
  24. * file named AUTHORS, in the root directory of this distribution.
  25. */
  26. /*
  27. * $Id: set_commands.c,v 1.26 2006/07/05 13:14:58 martinea Exp $
  28. *
  29. * implements the "set" commands in amrecover
  30. */
  31. #include "amanda.h"
  32. #include "match.h"
  33. #include "util.h"
  34. #include "amrecover.h"
  35. #include "amxml.h"
  36. extern unsigned short samba_extract_method;
  37. /* sets a date, mapping given date into standard form if needed */
  38. int
  39. set_date(
  40. char * date)
  41. {
  42. char *cmd = NULL;
  43. char *qdisk_path;
  44. clear_dir_list();
  45. cmd = stralloc2("DATE ", date);
  46. if (converse(cmd) == -1)
  47. exit(1);
  48. /* if a host/disk/directory is set, then check if that directory
  49. is still valid at the new date, and if not set directory to
  50. mount_point */
  51. if (disk_path != NULL) {
  52. qdisk_path = quote_string(disk_path);
  53. cmd = newstralloc2(cmd, "OISD ", qdisk_path);
  54. amfree(qdisk_path);
  55. if (exchange(cmd) == -1)
  56. exit(1);
  57. if (server_happy())
  58. {
  59. suck_dir_list_from_server();
  60. }
  61. else
  62. {
  63. g_printf(_("No index records for cwd on new date\n"));
  64. g_printf(_("Setting cwd to mount point\n"));
  65. disk_path = newstralloc(disk_path, "/"); /* fake it */
  66. clear_dir_list();
  67. }
  68. }
  69. amfree(cmd);
  70. return 0;
  71. }
  72. void
  73. set_host(
  74. const char *host)
  75. {
  76. char *cmd = NULL;
  77. struct hostent *hp = NULL;
  78. char **hostp;
  79. int found_host = 0;
  80. char *uqhost = unquote_string(host);
  81. if (is_extract_list_nonempty())
  82. {
  83. g_printf(_("Must clear extract list before changing host\n"));
  84. amfree(uqhost);
  85. return;
  86. }
  87. /*
  88. * The idea here is to try as many permutations of the hostname
  89. * as we can imagine. The server will reject anything it doesn't
  90. * recognize.
  91. */
  92. cmd = stralloc2("HOST ", uqhost);
  93. if (converse(cmd) == -1)
  94. exit(1);
  95. if (server_happy())
  96. found_host = 1;
  97. /*
  98. * Try converting the given host to a fully qualified, canonical
  99. * name.
  100. */
  101. if (!found_host) {
  102. if ((hp = gethostbyname(uqhost)) != NULL) {
  103. host = hp->h_name;
  104. g_printf(_("Trying host %s ...\n"), host);
  105. cmd = newstralloc2(cmd, "HOST ", host);
  106. if (converse(cmd) == -1)
  107. exit(1);
  108. if(server_happy())
  109. found_host = 1;
  110. }
  111. }
  112. /*
  113. * Since we have them, try any CNAMEs that were traversed from uqhost
  114. * to the canonical name (this assumes gethostbyname was called above)
  115. */
  116. if (!found_host) {
  117. if (hp) {
  118. for (hostp = hp->h_aliases; (host = *hostp) != NULL; hostp++)
  119. {
  120. g_printf(_("Trying host %s ...\n"), host);
  121. cmd = newstralloc2(cmd, "HOST ", host);
  122. if (converse(cmd) == -1)
  123. exit(1);
  124. if(server_happy())
  125. {
  126. found_host = 1;
  127. break;
  128. }
  129. }
  130. }
  131. }
  132. /* Try looking up the canonical name of the host */
  133. if (!found_host) {
  134. char *canonname;
  135. int result;
  136. result = resolve_hostname(uqhost, 0, NULL, &canonname);
  137. if (result == 0 && canonname) {
  138. host = canonname;
  139. g_printf(_("Trying host %s ...\n"), host);
  140. cmd = newstralloc2(cmd, "HOST ", host);
  141. if (converse(cmd) == -1)
  142. exit(1);
  143. if(server_happy())
  144. found_host = 1;
  145. }
  146. }
  147. if(found_host) {
  148. dump_hostname = newstralloc(dump_hostname, host);
  149. amfree(disk_name);
  150. amfree(mount_point);
  151. amfree(disk_path);
  152. clear_dir_list();
  153. }
  154. amfree(cmd);
  155. amfree(uqhost);
  156. }
  157. void
  158. list_host(void)
  159. {
  160. char *cmd = NULL;
  161. cmd = stralloc("LISTHOST");
  162. if (converse(cmd) == -1)
  163. exit(1);
  164. amfree(cmd);
  165. }
  166. void
  167. set_disk(
  168. char * dsk,
  169. char * mtpt)
  170. {
  171. char *cmd = NULL;
  172. char *qdsk;
  173. char *uqdsk;
  174. char *uqmtpt = NULL;
  175. if (is_extract_list_nonempty())
  176. {
  177. g_printf(_("Must clear extract list before changing disk\n"));
  178. return;
  179. }
  180. /* if mount point specified, check it is valid */
  181. if (mtpt != NULL) {
  182. uqmtpt = unquote_string(mtpt);
  183. if (*mtpt != '/') {
  184. g_printf(_("Mount point \"%s\" invalid - must start with /\n"), uqmtpt);
  185. amfree(uqmtpt);
  186. return;
  187. }
  188. }
  189. clear_dir_list();
  190. uqdsk = unquote_string(dsk);
  191. qdsk = quote_string(uqdsk);
  192. cmd = stralloc2("DISK ", qdsk);
  193. amfree(qdsk);
  194. if (converse(cmd) == -1)
  195. exit(1);
  196. amfree(cmd);
  197. if (!server_happy()) {
  198. amfree(uqmtpt);
  199. amfree(uqdsk);
  200. return;
  201. }
  202. disk_name = newstralloc(disk_name, uqdsk);
  203. if (mtpt == NULL)
  204. {
  205. /* mount point not specified */
  206. if (*uqdsk == '/')
  207. {
  208. /* disk specified by mount point, hence use it */
  209. mount_point = newstralloc(mount_point, uqdsk);
  210. }
  211. else
  212. {
  213. /* device name given, use '/' because nothing better */
  214. mount_point = newstralloc(mount_point, "/");
  215. }
  216. }
  217. else
  218. {
  219. /* mount point specified */
  220. mount_point = newstralloc(mount_point, uqmtpt);
  221. }
  222. /* set the working directory to the mount point */
  223. /* there is the possibility that there are no index records for the
  224. disk for the given date, hence setting the directory to the
  225. mount point will fail. Preempt this by checking first so we can write
  226. a more informative message. */
  227. if (exchange("OISD /") == -1)
  228. exit(1);
  229. if (server_happy())
  230. {
  231. disk_path = newstralloc(disk_path, "/");
  232. suck_dir_list_from_server(); /* get list of directory contents */
  233. }
  234. else
  235. {
  236. g_printf(_("No index records for disk for specified date\n"));
  237. g_printf(_("If date correct, notify system administrator\n"));
  238. disk_path = newstralloc(disk_path, "/"); /* fake it */
  239. clear_dir_list();
  240. }
  241. amfree(uqmtpt);
  242. amfree(uqdsk);
  243. if (am_has_feature(indexsrv_features, fe_amindexd_DLE)) {
  244. char *dle_str;
  245. char *errmsg = NULL;
  246. cmd = stralloc("DLE");
  247. if (exchange(cmd) == -1)
  248. exit(1);
  249. amfree(cmd);
  250. if (!server_happy())
  251. return;
  252. dle_str = reply_line();
  253. if (BSTRNCMP(dle_str+4, "NODLE") == 0) {
  254. dump_dle = NULL;
  255. } else {
  256. dle_str = unquote_string(dle_str+4);
  257. dump_dle = amxml_parse_node_CHAR(dle_str, &errmsg);
  258. amfree(dle_str);
  259. }
  260. }
  261. }
  262. void
  263. list_disk(
  264. char * amdevice)
  265. {
  266. char *cmd = NULL;
  267. char *qamdevice, *uqamdevice;
  268. if(amdevice) {
  269. uqamdevice = unquote_string(amdevice);
  270. qamdevice = quote_string(uqamdevice);
  271. cmd = stralloc2("LISTDISK ", qamdevice);
  272. amfree(uqamdevice);
  273. amfree(qamdevice);
  274. if (converse(cmd) == -1)
  275. exit(1);
  276. amfree(cmd);
  277. }
  278. else {
  279. cmd = stralloc("LISTDISK");
  280. if (converse(cmd) == -1)
  281. exit(1);
  282. amfree(cmd);
  283. }
  284. }
  285. static GSList *prop_values = NULL;
  286. void
  287. set_property_name(
  288. char *name,
  289. int append)
  290. {
  291. property_t *prop;
  292. char *property_name, *pn;
  293. pn = unquote_string(name);
  294. property_name = amandaify_property_name(pn);
  295. amfree(pn);
  296. if (!append) {
  297. g_hash_table_remove(proplist, property_name);
  298. prop = NULL;
  299. } else {
  300. prop = g_hash_table_lookup(proplist, property_name);
  301. }
  302. if (!prop) {
  303. prop = malloc(sizeof(property_t));
  304. prop->append = 0;
  305. prop->priority = 1;
  306. prop->values = NULL;
  307. g_hash_table_insert(proplist, stralloc(property_name), prop);
  308. }
  309. /* add prop_values to prop->values */
  310. if (!prop->values) {
  311. prop->values = prop_values;
  312. prop_values = NULL;
  313. } else {
  314. GSList *pv;
  315. for(pv = prop_values; pv != NULL; pv = pv->next) {
  316. prop->values = g_slist_append(prop->values, pv->data);
  317. }
  318. g_slist_free(prop_values);
  319. prop_values = NULL;
  320. }
  321. amfree(property_name);
  322. }
  323. void
  324. add_property_value(
  325. char *value)
  326. {
  327. if (value) {
  328. prop_values = g_slist_prepend(prop_values, unquote_string(value));
  329. }
  330. }
  331. /* A GHFunc (callback for g_hash_table_foreach) */
  332. static void list_one_property(
  333. gpointer key_p,
  334. gpointer value_p,
  335. gpointer user_data_p G_GNUC_UNUSED)
  336. {
  337. char *property_s = key_p;
  338. char *qproperty;
  339. property_t *property = value_p;
  340. GSList *value;
  341. char *qvalue;
  342. qproperty = quote_string_always(property_s);
  343. printf("property %s", qproperty);
  344. amfree(qproperty);
  345. for (value = property->values; value != NULL; value = value->next) {
  346. qvalue = quote_string_always((char*)value->data);
  347. printf(" %s", qvalue);
  348. amfree(qvalue);
  349. }
  350. printf("\n");
  351. }
  352. void
  353. list_property(void)
  354. {
  355. if (proplist) {
  356. g_hash_table_foreach(proplist, list_one_property, NULL);
  357. } else {
  358. printf("No property set\n");
  359. }
  360. }
  361. void
  362. local_cd(
  363. char *dir)
  364. {
  365. char *uqdir = unquote_string(dir);
  366. if (chdir(uqdir) == -1) {
  367. perror(uqdir);
  368. }
  369. amfree(uqdir);
  370. }
  371. int
  372. cd_glob(
  373. char * glob,
  374. int verbose)
  375. {
  376. char *regex;
  377. char *regex_path;
  378. char *s;
  379. char *uqglob;
  380. int result;
  381. char *path_on_disk = NULL;
  382. if (disk_name == NULL) {
  383. g_printf(_("Must select disk before changing directory\n"));
  384. return 0;
  385. }
  386. uqglob = unquote_string(glob);
  387. regex = glob_to_regex(uqglob);
  388. dbprintf(_("cd_glob (%s) -> %s\n"), uqglob, regex);
  389. if ((s = validate_regexp(regex)) != NULL) {
  390. g_printf(_("\"%s\" is not a valid shell wildcard pattern: "), glob);
  391. puts(s);
  392. amfree(regex);
  393. amfree(uqglob);
  394. return 0;
  395. }
  396. /*
  397. * glob_to_regex() anchors the beginning of the pattern with ^,
  398. * but we will be tacking it onto the end of the current directory
  399. * in add_file, so strip that off. Also, it anchors the end with
  400. * $, but we need to match a trailing /, add it if it is not there
  401. */
  402. regex_path = stralloc(regex + 1);
  403. amfree(regex);
  404. if(regex_path[strlen(regex_path) - 2] != '/' ) {
  405. regex_path[strlen(regex_path) - 1] = '\0';
  406. strappend(regex_path, "/$");
  407. }
  408. /* convert path (assumed in cwd) to one on disk */
  409. if (strcmp(disk_path, "/") == 0)
  410. path_on_disk = stralloc2("/", regex_path);
  411. else {
  412. char *clean_disk_path = clean_regex(disk_path, 0);
  413. path_on_disk = vstralloc(clean_disk_path, "/", regex_path, NULL);
  414. amfree(clean_disk_path);
  415. }
  416. result = cd_dir(path_on_disk, uqglob, verbose);
  417. amfree(regex_path);
  418. amfree(path_on_disk);
  419. amfree(uqglob);
  420. return result;
  421. }
  422. int
  423. cd_regex(
  424. char * regex,
  425. int verbose)
  426. {
  427. char *s;
  428. char *uq_orig_regex;
  429. char *uqregex;
  430. int len_uqregex;
  431. int result;
  432. char *path_on_disk = NULL;
  433. if (disk_name == NULL) {
  434. g_printf(_("Must select disk before changing directory\n"));
  435. return 0;
  436. }
  437. uq_orig_regex = unquote_string(regex);
  438. uqregex = stralloc(uq_orig_regex);
  439. /* Add a terminating '/' if it is not there, maybe before a '$' */
  440. len_uqregex = strlen(uqregex);
  441. if (uqregex[len_uqregex-1] == '$') {
  442. if (uqregex[len_uqregex-2] != '/') {
  443. uqregex[len_uqregex-1] = '\0';
  444. strappend(uqregex, "/$");
  445. }
  446. } else if (uqregex[len_uqregex-1] != '/') {
  447. //uqregex[len_uqregex-1] = '\0';
  448. strappend(uqregex, "/");
  449. }
  450. if ((s = validate_regexp(uqregex)) != NULL) {
  451. g_printf(_("\"%s\" is not a valid regular expression: "), uq_orig_regex);
  452. amfree(uqregex);
  453. amfree(uq_orig_regex);
  454. puts(s);
  455. return 0;
  456. }
  457. /* convert path (assumed in cwd) to one on disk */
  458. if (strcmp(disk_path, "/") == 0)
  459. path_on_disk = stralloc2("/", uqregex);
  460. else {
  461. char *clean_disk_path = clean_regex(disk_path, 0);
  462. path_on_disk = vstralloc(clean_disk_path, "/", regex, NULL);
  463. amfree(clean_disk_path);
  464. }
  465. result = cd_dir(path_on_disk, uq_orig_regex, verbose);
  466. amfree(path_on_disk);
  467. amfree(uqregex);
  468. amfree(uq_orig_regex);
  469. return result;
  470. }
  471. int
  472. cd_dir(
  473. char * path_on_disk,
  474. char * default_dir,
  475. int verbose)
  476. {
  477. char *dir = NULL;
  478. char *s;
  479. int nb_found;
  480. int result;
  481. size_t i;
  482. DIR_ITEM *ditem;
  483. if ((s = validate_regexp(path_on_disk)) != NULL) {
  484. result = set_directory(default_dir, verbose);
  485. return result;
  486. }
  487. nb_found = 0;
  488. for (ditem=get_dir_list(); ditem!=NULL && nb_found <= 1;
  489. ditem=get_next_dir_item(ditem))
  490. {
  491. if (match(path_on_disk, ditem->path))
  492. {
  493. i = strlen(ditem->path);
  494. if((i > 0 && ditem->path[i-1] == '/')
  495. || (i > 1 && ditem->path[i-2] == '/' && ditem->path[i-1] == '.'))
  496. { /* It is a directory */
  497. char *dir1, *dir2;
  498. nb_found++;
  499. dir = newstralloc(dir,ditem->path);
  500. if(dir[strlen(dir)-1] == '/')
  501. dir[strlen(dir)-1] = '\0'; /* remove last / */
  502. /* remove everything before the last / */
  503. dir1 = strrchr(dir,'/');
  504. if (dir1) {
  505. dir1++;
  506. dir2 = stralloc(dir1);
  507. amfree(dir);
  508. dir = dir2;
  509. }
  510. }
  511. }
  512. }
  513. if(nb_found==0) {
  514. result = set_directory(default_dir, verbose);
  515. }
  516. else if(nb_found==1) {
  517. result = set_directory(dir, verbose);
  518. }
  519. else {
  520. g_printf(_("Too many directories matching '%s'\n"), default_dir);
  521. result = 0;
  522. }
  523. amfree(dir);
  524. return result;
  525. }
  526. int
  527. set_directory(
  528. char * dir,
  529. int verbose)
  530. {
  531. char *cmd = NULL;
  532. char *new_dir = NULL;
  533. char *qnew_dir;
  534. char *dp, *de;
  535. char *ldir = NULL;
  536. int result;
  537. /* do nothing if "." */
  538. if(strcmp(dir,".")==0) {
  539. show_directory(); /* say where we are */
  540. return 1;
  541. /*NOTREACHED*/
  542. }
  543. if (disk_name == NULL) {
  544. g_printf(_("Must select disk before setting directory\n"));
  545. return 0;
  546. /*NOTREACHED*/
  547. }
  548. ldir = stralloc(dir);
  549. clean_pathname(ldir);
  550. /* convert directory into absolute path relative to disk mount point */
  551. if (ldir[0] == '/')
  552. {
  553. /* absolute path specified, must start with mount point */
  554. if (strcmp(mount_point, "/") == 0)
  555. {
  556. new_dir = stralloc(ldir);
  557. }
  558. else
  559. {
  560. if (strncmp(mount_point, ldir, strlen(mount_point)) != 0)
  561. {
  562. g_printf(_("Invalid directory - Can't cd outside mount point \"%s\"\n"),
  563. mount_point);
  564. amfree(ldir);
  565. return 0;
  566. /*NOTREACHED*/
  567. }
  568. new_dir = stralloc(ldir+strlen(mount_point));
  569. if (strlen(new_dir) == 0) {
  570. new_dir = newstralloc(new_dir, "/");
  571. /* i.e. ldir == mount_point */
  572. }
  573. }
  574. }
  575. else
  576. {
  577. new_dir = stralloc(disk_path);
  578. dp = ldir;
  579. /* strip any leading ..s */
  580. while (strncmp(dp, "../", 3) == 0)
  581. {
  582. de = strrchr(new_dir, '/'); /* always at least 1 */
  583. if (de == new_dir)
  584. {
  585. /* at top of disk */
  586. *(de + 1) = '\0';
  587. dp = dp + 3;
  588. }
  589. else
  590. {
  591. *de = '\0';
  592. dp = dp + 3;
  593. }
  594. }
  595. if (strcmp(dp, "..") == 0) {
  596. if (strcmp(new_dir, "/") == 0) {
  597. /* at top of disk */
  598. g_printf(_("Invalid directory - Can't cd outside mount point \"%s\"\n"),
  599. mount_point);
  600. /*@ignore@*/
  601. amfree(new_dir);
  602. /*@end@*/
  603. amfree(ldir);
  604. return 0;
  605. /*NOTREACHED*/
  606. }
  607. de = strrchr(new_dir, '/'); /* always at least 1 */
  608. if (de == new_dir)
  609. {
  610. /* at top of disk */
  611. *(de+1) = '\0';
  612. }
  613. else
  614. {
  615. *de = '\0';
  616. }
  617. } else {
  618. /*@ignore@*/
  619. if (strcmp(new_dir, "/") != 0) {
  620. strappend(new_dir, "/");
  621. }
  622. strappend(new_dir, ldir);
  623. /*@end@*/
  624. }
  625. }
  626. qnew_dir = quote_string(new_dir);
  627. cmd = stralloc2("OISD ", qnew_dir);
  628. amfree(qnew_dir);
  629. if (exchange(cmd) == -1) {
  630. exit(1);
  631. /*NOTREACHED*/
  632. }
  633. amfree(cmd);
  634. if (server_happy())
  635. {
  636. disk_path = newstralloc(disk_path, new_dir);
  637. suck_dir_list_from_server(); /* get list of directory contents */
  638. if (verbose)
  639. show_directory(); /* say where we moved to */
  640. result = 1;
  641. }
  642. else
  643. {
  644. g_printf(_("Invalid directory - %s\n"), dir);
  645. result = 0;
  646. }
  647. /*@ignore@*/
  648. amfree(new_dir);
  649. amfree(ldir);
  650. /*@end@*/
  651. return result;
  652. }
  653. /* prints the current working directory */
  654. void
  655. show_directory(void)
  656. {
  657. if (mount_point == NULL || disk_path == NULL)
  658. g_printf(_("Must select disk first\n"));
  659. else if (strcmp(mount_point, "/") == 0)
  660. g_printf("%s\n", disk_path);
  661. else if (strcmp(disk_path, "/") == 0)
  662. g_printf("%s\n", mount_point);
  663. else
  664. g_printf("%s%s\n", mount_point, disk_path);
  665. }
  666. /* set the tape server and device (deprecated version) */
  667. void
  668. set_tape(
  669. char * tape)
  670. {
  671. char *uqtape = unquote_string(tape);
  672. char *tapedev = strchr(uqtape, ':');
  673. char *host = NULL;
  674. g_printf(_("NOTE: 'settape' is deprecated; use setdevice instead.\n"));
  675. if (tapedev)
  676. {
  677. /* This command is deprecated because this parsing is going to fall
  678. * behind the list of available device names at some point, or to shadow
  679. * an interesting hostname (wouldn't 'tape' be a good name for a
  680. * tape server?) */
  681. if (tapedev != uqtape) {
  682. if((strchr(tapedev+1, ':') == NULL) &&
  683. (strncmp_const(uqtape, "null:") == 0 ||
  684. strncmp_const(uqtape, "rait:") == 0 ||
  685. strncmp_const(uqtape, "file:") == 0 ||
  686. strncmp_const(uqtape, "s3:") == 0 ||
  687. strncmp_const(uqtape, "tape:") == 0)) {
  688. tapedev = uqtape;
  689. }
  690. else {
  691. *tapedev = '\0';
  692. host = stralloc(uqtape);
  693. ++tapedev;
  694. }
  695. } else {
  696. ++tapedev;
  697. }
  698. } else
  699. tapedev = uqtape;
  700. if (tapedev[0])
  701. {
  702. if (strcmp(tapedev, "default") == 0)
  703. tapedev = NULL;
  704. }
  705. /* call out to the new version */
  706. set_device(host, tapedev);
  707. amfree(host);
  708. amfree(uqtape);
  709. }
  710. /* set the tape server and device, for real */
  711. void
  712. set_device(
  713. char * host,
  714. char * device)
  715. {
  716. if (host)
  717. tape_server_name = newstralloc(tape_server_name, host);
  718. else
  719. amfree(tape_server_name);
  720. if (device)
  721. tape_device_name = newstralloc(tape_device_name, device);
  722. else
  723. amfree(tape_device_name);
  724. /* print the current status */
  725. if (tape_device_name)
  726. g_printf (_("Using tape \"%s\""), tape_device_name);
  727. else
  728. g_printf (_("Using default tape"));
  729. if (tape_server_name)
  730. g_printf (_(" from server %s.\n"), tape_server_name);
  731. else
  732. g_printf (_(".\nTape server unspecified, assumed to be %s.\n"),
  733. server_name);
  734. }
  735. void
  736. set_mode(
  737. int mode)
  738. {
  739. if (mode == SAMBA_SMBCLIENT) {
  740. g_printf (_("SAMBA dumps will be extracted using smbclient\n"));
  741. samba_extract_method = SAMBA_SMBCLIENT;
  742. } else {
  743. if (mode == SAMBA_TAR) {
  744. g_printf (_("SAMBA dumps will be extracted as TAR dumps\n"));
  745. samba_extract_method = SAMBA_TAR;
  746. }
  747. }
  748. }
  749. void
  750. show_mode(void)
  751. {
  752. #ifdef SAMBA_CLIENT
  753. g_printf (_("SAMBA dumps are extracted "));
  754. if (samba_extract_method == SAMBA_TAR) {
  755. g_printf (_(" as TAR dumps\n"));
  756. } else {
  757. g_printf (_("using smbclient\n"));
  758. }
  759. #endif /* SAMBA_CLIENT */
  760. }