git.annexia.org
/
libguestfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Prepare for version 1.0.78
[libguestfs.git]
/
daemon
/
checksum.c
diff --git
a/daemon/checksum.c
b/daemon/checksum.c
index
bb30b05
..
499d19d
100644
(file)
--- a/
daemon/checksum.c
+++ b/
daemon/checksum.c
@@
-28,29
+28,27
@@
#include "actions.h"
char *
#include "actions.h"
char *
-do_checksum (c
har *csumtype,
char *path)
+do_checksum (c
onst char *csumtype, const
char *path)
{
const char *program;
char *buf;
char *out, *err;
{
const char *program;
char *buf;
char *out, *err;
- int r, len;
+ int r;
+ int len;
- NEED_ROOT (NULL);
- ABS_PATH (path, NULL);
-
- if (strcasecmp (csumtype, "crc") == 0)
+ if (STRCASEEQ (csumtype, "crc"))
program = "cksum";
program = "cksum";
- else if (
strcasecmp (csumtype, "md5") == 0
)
+ else if (
STRCASEEQ (csumtype, "md5")
)
program = "md5sum";
program = "md5sum";
- else if (
strcasecmp (csumtype, "sha1") == 0
)
+ else if (
STRCASEEQ (csumtype, "sha1")
)
program = "sha1sum";
program = "sha1sum";
- else if (
strcasecmp (csumtype, "sha224") == 0
)
+ else if (
STRCASEEQ (csumtype, "sha224")
)
program = "sha224sum";
program = "sha224sum";
- else if (
strcasecmp (csumtype, "sha256") == 0
)
+ else if (
STRCASEEQ (csumtype, "sha256")
)
program = "sha256sum";
program = "sha256sum";
- else if (
strcasecmp (csumtype, "sha384") == 0
)
+ else if (
STRCASEEQ (csumtype, "sha384")
)
program = "sha384sum";
program = "sha384sum";
- else if (
strcasecmp (csumtype, "sha512") == 0
)
+ else if (
STRCASEEQ (csumtype, "sha512")
)
program = "sha512sum";
else {
reply_with_error ("unknown checksum type, expecting crc|md5|sha1|sha224|sha256|sha384|sha512");
program = "sha512sum";
else {
reply_with_error ("unknown checksum type, expecting crc|md5|sha1|sha224|sha256|sha384|sha512");
@@
-58,13
+56,11
@@
do_checksum (char *csumtype, char *path)
}
/* Make the path relative to /sysroot. */
}
/* 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;
}
if (!buf) {
reply_with_perror ("malloc");
return NULL;
}
- snprintf (buf, len, "/sysroot%s", path);
r = command (&out, &err, program, buf, NULL);
free (buf);
r = command (&out, &err, program, buf, NULL);
free (buf);