X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;ds=sidebyside;f=daemon%2Fguestfsd.c;h=06ad702e17b1e8007f7cc24e3ec83e562dc9749d;hb=af29c84cef791381ac3aebae30d8831b7de77e36;hp=84b62ab58e3602aec93fc949e0aa2b5cbe4f9315;hpb=9e0b31a2af26b8d58a44dd80993a5e73d4942307;p=libguestfs.git diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index 84b62ab..06ad702 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -227,6 +227,7 @@ main (int argc, char *argv[]) setenv ("PATH", "/sbin:/usr/sbin:/bin:/usr/bin", 1); setenv ("SHELL", "/bin/sh", 1); setenv ("LC_ALL", "C", 1); + setenv ("TERM", "dumb", 1); #ifndef WIN32 /* We document that umask defaults to 022 (it should be this anyway). */ @@ -1021,42 +1022,36 @@ print_arginfo (const struct printf_info *info, size_t n, int *argtypes) * the device nodes themselves will exist in the appliance. */ int -device_name_translation (char *device, const char *func) +device_name_translation (char *device) { int fd; fd = open (device, O_RDONLY); if (fd >= 0) { + close_ok: close (fd); return 0; } - if (errno != ENXIO && errno != ENOENT) { - error: - reply_with_perror ("%s: %s", func, device); + if (errno != ENXIO && errno != ENOENT) return -1; - } /* If the name begins with "/dev/sd" then try the alternatives. */ if (STRNEQLEN (device, "/dev/sd", 7)) - goto error; + return -1; device[5] = 'h'; /* /dev/hd (old IDE driver) */ fd = open (device, O_RDONLY); - if (fd >= 0) { - close (fd); - return 0; - } + if (fd >= 0) + goto close_ok; device[5] = 'v'; /* /dev/vd (for virtio devices) */ fd = open (device, O_RDONLY); - if (fd >= 0) { - close (fd); - return 0; - } + if (fd >= 0) + goto close_ok; device[5] = 's'; /* Restore original device name. */ - goto error; + return -1; } /* Check program exists and is executable on $PATH. Actually, we @@ -1065,7 +1060,7 @@ device_name_translation (char *device, const char *func) int prog_exists (const char *prog) { - static const char *dirs[] = + static const char * const dirs[] = { "/sbin", "/usr/sbin", "/bin", "/usr/bin" }; size_t i; char buf[1024];