X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=daemon%2Frealpath.c;h=607381b81963bf817e896f505a3cc97dc87f4ffb;hp=f9d08dac8d6e35a6f409b69b3b92d991c83405c1;hb=5ce759bfdc70c97121ef34ab4d5c918d568f2474;hpb=e94f89f40d989d111882178c87b5bfc22314fca8 diff --git a/daemon/realpath.c b/daemon/realpath.c index f9d08da..607381b 100644 --- a/daemon/realpath.c +++ b/daemon/realpath.c @@ -1,5 +1,5 @@ /* libguestfs - the guestfsd daemon - * Copyright (C) 2009 Red Hat Inc. + * Copyright (C) 2009-2011 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ #include #include "daemon.h" +#include "optgroups.h" #include "actions.h" /* On Windows, NAME_MAX is not defined. */ @@ -35,20 +36,34 @@ #define NAME_MAX FILENAME_MAX #endif +int +optgroup_realpath_available (void) +{ +#ifdef HAVE_REALPATH + return 1; +#else + return 0; +#endif +} + char * do_realpath (const char *path) { +#ifdef HAVE_REALPATH char *ret; CHROOT_IN; ret = realpath (path, NULL); CHROOT_OUT; if (ret == NULL) { - reply_with_perror ("realpath"); + reply_with_perror ("%s", path); return NULL; } return ret; /* caller frees */ +#else + NOT_AVAILABLE (NULL); +#endif } char * @@ -77,17 +92,13 @@ do_case_sensitive_path (const char *path) continue; } - if (verbose) - fprintf (stderr, "case_sensitive_path: path = %s, next = %zu, i = %zu\n", - path, next, i); - if ((i == 1 && path[0] == '.') || (i == 2 && path[0] == '.' && path[1] == '.')) { - reply_with_error ("case_sensitive_path: path contained . or .. elements"); + reply_with_error ("path contained . or .. elements"); goto error; } if (i > NAME_MAX) { - reply_with_error ("case_sensitive_path: path element too long"); + reply_with_error ("path element too long"); goto error; }