This shouldn't change the semantics of the program.
For stable-1.2 this was cherry picked from commit af29c84 and
rebased against the older code in daemon/checksum.c.
#include "daemon.h"
#include "actions.h"
#include "daemon.h"
#include "actions.h"
-char *
-do_checksum (const char *csumtype, const char *path)
+static const char *
+program_of_csum (const char *csumtype)
- const char *program;
- char *buf;
- char *out, *err;
- int r;
- int len;
-
if (STRCASEEQ (csumtype, "crc"))
if (STRCASEEQ (csumtype, "crc"))
else if (STRCASEEQ (csumtype, "md5"))
else if (STRCASEEQ (csumtype, "md5"))
else if (STRCASEEQ (csumtype, "sha1"))
else if (STRCASEEQ (csumtype, "sha1"))
else if (STRCASEEQ (csumtype, "sha224"))
else if (STRCASEEQ (csumtype, "sha224"))
else if (STRCASEEQ (csumtype, "sha256"))
else if (STRCASEEQ (csumtype, "sha256"))
else if (STRCASEEQ (csumtype, "sha384"))
else if (STRCASEEQ (csumtype, "sha384"))
else if (STRCASEEQ (csumtype, "sha512"))
else if (STRCASEEQ (csumtype, "sha512"))
else {
reply_with_error ("unknown checksum type, expecting crc|md5|sha1|sha224|sha256|sha384|sha512");
return NULL;
}
else {
reply_with_error ("unknown checksum type, expecting crc|md5|sha1|sha224|sha256|sha384|sha512");
return NULL;
}
+}
+
+char *
+do_checksum (const char *csumtype, const char *path)
+{
+ const char *program;
+ char *buf;
+ char *out, *err;
+ int r;
+ int len;
+
+ program = program_of_csum (csumtype);
+ if (program == NULL)
+ return NULL;
/* Make the path relative to /sysroot. */
buf = sysroot_path (path);
/* Make the path relative to /sysroot. */
buf = sysroot_path (path);