static char add_drives (struct drv *drv, char next_drive);
static void prepare_drives (struct drv *drv);
static void mount_mps (struct mp *mp);
+static void free_drives (struct drv *drv);
+static void free_mps (struct mp *mp);
static int launch (void);
static void interactive (void);
static void shell_script (void);
int exit_on_error = 1;
int command_num = 0;
int keys_from_stdin = 0;
+int echo_keys = 0;
const char *libvirt_uri = NULL;
int inspector = 0;
int utf8_mode = 0;
" -c|--connect uri Specify libvirt URI for -d option\n"
" -d|--domain guest Add disks from libvirt guest\n"
" -D|--no-dest-paths Don't tab-complete paths from guest fs\n"
+ " --echo-keys Don't turn off echo for passphrases\n"
" -f|--file file Read commands from file\n"
" -i|--inspector Automatically mount filesystems\n"
" --keys-from-stdin Read passphrases from stdin\n"
{ "cmd-help", 2, 0, 'h' },
{ "connect", 1, 0, 'c' },
{ "domain", 1, 0, 'd' },
+ { "echo-keys", 0, 0, 0 },
{ "file", 1, 0, 'f' },
{ "help", 0, 0, HELP_OPTION },
{ "inspector", 0, 0, 'i' },
override_progress_bars = 1;
} else if (STREQ (long_options[option_index].name, "no-progress-bars")) {
override_progress_bars = 0;
+ } else if (STREQ (long_options[option_index].name, "echo-keys")) {
+ echo_keys = 1;
} else {
fprintf (stderr, _("%s: unknown long option: %s (%d)\n"),
program_name, long_options[option_index].name, option_index);
mount_mps (mps);
}
+ /* Free up data structures, no longer needed after this point. */
+ free_drives (drvs);
+ free_mps (mps);
+
/* Remote control? */
if (remote_control_listen && remote_control) {
fprintf (stderr,
}
}
+static void
+free_drives (struct drv *drv)
+{
+ if (!drv) return;
+ free_drives (drv->next);
+
+ switch (drv->type) {
+ case drv_a: /* a.filename is optarg, don't free it */ break;
+ case drv_d: /* d.filename is optarg, don't free it */ break;
+ case drv_N:
+ free (drv->N.filename);
+ free (drv->N.device);
+ free_prep_data (drv->N.data);
+ break;
+ default: ; /* keep GCC happy */
+ }
+ free (drv);
+}
+
+static void
+free_mps (struct mp *mp)
+{
+ if (!mp) return;
+ free_mps (mp->next);
+
+ /* The drive and mountpoint fields are not allocated
+ * from the heap, so we should not free them here.
+ */
+
+ free (mp);
+}
+
static int
launch (void)
{
#else
(void) write_history (histfile);
#endif
+ clear_history ();
}
#endif
}
static char *
file_in_heredoc (const char *endmarker)
{
- static const char template[] = "/tmp/heredocXXXXXX";
+ TMP_TEMPLATE_ON_STACK (template);
file_in_tmpfile = strdup (template);
if (file_in_tmpfile == NULL) {
perror ("strdup");
if (tty) {
fprintf (outfp, _("Enter key or passphrase (\"%s\"): "), param);
- if (tcgetattr (fileno (infp), &orig) == -1) {
- perror ("tcgetattr");
- goto error;
- }
- memcpy (&temp, &orig, sizeof temp);
- temp.c_lflag &= ~ECHO;
+ if (!echo_keys) {
+ if (tcgetattr (fileno (infp), &orig) == -1) {
+ perror ("tcgetattr");
+ goto error;
+ }
+ memcpy (&temp, &orig, sizeof temp);
+ temp.c_lflag &= ~ECHO;
- tcsetattr (fileno (infp), TCSAFLUSH, &temp);
- tcset = 1;
+ tcsetattr (fileno (infp), TCSAFLUSH, &temp);
+ tcset = 1;
+ }
}
size_t n = 0;