X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Fchecksum.c;h=24232650cea7b59591638e43a58991e2443fd880;hb=a3dfe9398c9f629d013a82c1ba8014b500462f7d;hp=bb30b05eb7fb89010d4d38fedeb5ceedb1a3a944;hpb=a7b73d4a1e09f12b2002083618056f0c823c1dcf;p=libguestfs.git diff --git a/daemon/checksum.c b/daemon/checksum.c index bb30b05..2423265 100644 --- a/daemon/checksum.c +++ b/daemon/checksum.c @@ -28,15 +28,13 @@ #include "actions.h" char * -do_checksum (char *csumtype, char *path) +do_checksum (const char *csumtype, const char *path) { const char *program; char *buf; char *out, *err; - int r, len; - - NEED_ROOT (NULL); - ABS_PATH (path, NULL); + int r; + int len; if (strcasecmp (csumtype, "crc") == 0) program = "cksum"; @@ -58,13 +56,11 @@ do_checksum (char *csumtype, char *path) } /* Make the path relative to /sysroot. */ - len = strlen (path) + 9; - buf = malloc (len); + buf = sysroot_path (path); if (!buf) { reply_with_perror ("malloc"); return NULL; } - snprintf (buf, len, "/sysroot%s", path); r = command (&out, &err, program, buf, NULL); free (buf);