" -n|--no-sync Don't autosync\n"
" --remote[=pid] Send commands to remote guestfish\n"
" -r|--ro Mount read-only\n"
+ " --selinux Enable SELinux support\n"
" -v|--verbose Verbose messages\n"
" -x Echo each command before executing it\n"
" -V|--version Display version and exit\n"
{ "no-sync", 0, 0, 'n' },
{ "remote", 2, 0, 0 },
{ "ro", 0, 0, 'r' },
+ { "selinux", 0, 0, 0 },
{ "verbose", 0, 0, 'v' },
{ "version", 0, 0, 'V' },
{ 0, 0, 0, 0 }
exit (1);
}
}
+ } else if (strcmp (long_options[option_index].name, "selinux") == 0) {
+ guestfs_set_selinux (g, 1);
} else {
fprintf (stderr, _("guestfish: unknown long option: %s (%d)\n"),
long_options[option_index].name, option_index);
*p = '\0';
mp->mountpoint = p+1;
} else
- mp->mountpoint = "/";
+ mp->mountpoint = bad_cast ("/");
mp->device = optarg;
mp->next = mps;
mps = mp;
char cmd[1024];
int r;
- if (drvs || mps || remote_control_listen || remote_control) {
- fprintf (stderr, _("guestfish: cannot use -i option with -a, -m, --listen or --remote\n"));
+ if (drvs || mps || remote_control_listen || remote_control ||
+ guestfs_get_selinux (g)) {
+ fprintf (stderr, _("guestfish: cannot use -i option with -a, -m, --listen, --remote or --selinux\n"));
exit (1);
}
if (optind >= argc) {
char *cmd;
char *p, *pend;
char *argv[64];
- int i, len;
+ int len;
int global_exit_on_error = !prompt;
int tilde_candidate;
if (len == 0) continue;
cmd = buf;
- i = 0;
+ unsigned int i = 0;
if (buf[len] == '\0') {
argv[0] = NULL;
goto got_command;
if (pipecmd) {
int fd[2];
- fflush (stdout);
- pipe (fd);
+ if (fflush (stdout) == EOF) {
+ perror ("failed to flush standard output");
+ return -1;
+ }
+ if (pipe (fd) < 0) {
+ perror ("pipe failed");
+ return -1;
+ }
pid = fork ();
if (pid == -1) {
perror ("fork");
if (pid == 0) { /* Child process. */
close (fd[1]);
- dup2 (fd[0], 0);
+ if (dup2 (fd[0], 0) < 0) {
+ perror ("dup2 of stdin failed");
+ _exit (1);
+ }
r = system (pipecmd);
if (r == -1) {
_exit (WEXITSTATUS (r));
}
- stdout_saved_fd = dup (1);
+ if ((stdout_saved_fd = dup (1)) < 0) {
+ perror ("failed to dup stdout");
+ return -1;
+ }
close (fd[0]);
- dup2 (fd[1], 1);
+ if (dup2 (fd[1], 1) < 0) {
+ perror ("failed to dup stdout");
+ close (stdout_saved_fd);
+ return -1;
+ }
close (fd[1]);
}
/* Always flush stdout after every command, so that messages, results
* etc appear immediately.
*/
- fflush (stdout);
+ if (fflush (stdout) == EOF) {
+ perror ("failed to flush standard output");
+ return -1;
+ }
if (pipecmd) {
close (1);
- dup2 (stdout_saved_fd, 1);
+ if (dup2 (stdout_saved_fd, 1) < 0) {
+ perror ("failed to dup2 standard output");
+ r = -1;
+ }
close (stdout_saved_fd);
- waitpid (pid, NULL, 0);
+ if (waitpid (pid, NULL, 0) < 0) {
+ perror ("waiting for command to complete");
+ r = -1;
+ }
}
return r;
}
int
-count_strings (char * const * const argv)
+count_strings (char *const *argv)
{
int c;
}
void
-print_strings (char * const * const argv)
+print_strings (char *const *argv)
{
int argc;
}
void
-print_table (char * const * const argv)
+print_table (char *const *argv)
{
int i;
}
int
-xwrite (int fd, const void *buf, size_t len)
+xwrite (int fd, const void *v_buf, size_t len)
{
int r;
+ const char *buf = v_buf;
while (len > 0) {
r = write (fd, buf, len);