diff U3 syslinux-6.04-pre1/com32/modules/Makefile b/com32/modules/Makefile
--- syslinux-6.04-pre1/com32/modules/Makefile Fri Mar 04 02:09:01 2016
+++ b/com32/modules/Makefile Fri Jun 30 20:09:01 2017
@@ -25,9 +25,9 @@
# All-architecture modules
MOD_ALL = cat.c32 cmd.c32 config.c32 cptime.c32 cpuid.c32 cpuidtest.c32 \
- debug.c32 dir.c32 dmitest.c32 hexdump.c32 host.c32 ifcpu.c32 \
- ifcpu64.c32 linux.c32 ls.c32 meminfo.c32 pwd.c32 reboot.c32 \
- vpdtest.c32 whichsys.c32 zzjson.c32
+ debug.c32 dir.c32 dmitest.c32 hash.c32 hexdump.c32 host.c32 \
+ ifcpu.c32 ifcpu64.c32 linux.c32 ls.c32 meminfo.c32 pwd.c32 \
+ reboot.c32 vpdtest.c32 whichsys.c32 zzjson.c32
ifeq ($(FIRMWARE),BIOS)
MODULES = $(MOD_ALL) $(MOD_BIOS)
diff U3 syslinux-6.04-pre1/com32/modules/hash.c b/com32/modules/hash.c
--- /dev/null Fri Mar 04 02:09:01 2016
+++ b/com32/modules/hash.c Fri Jun 30 20:09:01 2017
@@ -0,0 +1,236 @@
+/*
+ * Based on md5sum.c32 included in Slitaz 4.0.
+ * Based on c32box.c32 (md5sum.c) included in Slitaz 5.0 Rolling as of
2016-04-25.
+ * http://hg.slitaz.org/wok/log/default/syslinux/stuff/extra/md5sum.c
+ *
+ * Based in Gene Cumm's additional patches
+ * that make c32box.c32 compatible with Syslinux 5.0.
+ */
+
+/*
+ * Usage:
+ *
+ * _ from CLI:
+ * hash.c32 path/to/list_file
+ *
+ * _ from a configuration file :
+ * COM32 hash.c32
+ * APPEND path/to/list_file
+ *
+ * The content's format of the list_file is expected to be:
+ *
+ * md5sum path/to/file
+ *
+ * or more generally:
+ *
+ * hash_value1 path/to/file1
+ * hash_value2 path/to/file2
+ * hash_value3 path/to/file3
+ * ...
+ *
+ * in which:
+ * _ 'path/to/file'
+ * is the file to evaluate
+ *
+ * _ 'hash_value'
+ * is the expected checksum value for
+ * the file listed in the same row.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <console.h>
+#include <com32.h>
+#include <md5.h>
+#include <syslinux/config.h>
+/* FIXME: Do we really need disk.h? */
+#include <syslinux/disk.h>
+
+/* FIXME: Do we really need 'main_say()'? */
+static int main_say(int argc, char **argv)
+{
+ int i;
+ for (i = 1; i < argc; i++) {
+ printf("%s ",argv[i]);
+ }
+ printf("\n");
+ sleep(5);
+ return 0;
+}
+
+/*
+ * Based on busybox code.
+ *
+ * Compute MD5 checksum of strings according to the
+ * definition of MD5 in RFC 1321 from April 1992.
+ *
+ * Written by Ulrich Drepper <drepper at gnu.ai.mit.edu>, 1995.
+ *
+ * Copyright (C) 1995-1999 Free Software Foundation, Inc.
+ * Copyright (C) 2001 Manuel Novoa III
+ * Copyright (C) 2003 Glenn L. McGrath
+ * Copyright (C) 2003 Erik Andersen
+ * Copyright (C) 2010 Denys Vlasenko
+ * Copyright (C) 2012 Pascal Bellard
+ *
+ * Licensed under GPLv2 or later
+ */
+
+#define ALIGN1
+
+/* Emit a string of hex representation of bytes */
+static char* bin2hex(char *p, int count, const void *in)
+{
+ static const char bb_hexdigits_upcase[] ALIGN1 = "0123456789abcdef";
+ const char *cp = (const char *) in;
+ while (count) {
+ unsigned char c = *cp++;
+ /* put lowercase hex digits */
+ *p++ = bb_hexdigits_upcase[c >> 4];
+ *p++ = bb_hexdigits_upcase[c & 0xf];
+ count--;
+ }
+ return p;
+}
+
+/*
+ * Copyright (C) 2003 Glenn L. McGrath
+ * Copyright (C) 2003-2004 Erik Andersen
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ */
+
+/*
+ * FIXME: Considering that later-on we use 'unrockridge_iso()' ,
+ * do we really need 'unrockridge()'?
+ */
+static char *unrockridge(const char *name)
+{
+ static char buffer[256];
+ int i = 0, j = 8;
+ while (*name && i < 255) {
+ char c = *name++;
+ //if (c == '\\') c = '/';
+ if (c == '.') {
+ for (j = i; --j >= 0 && buffer[j] != '/';)
+ if (buffer[j] == '.') buffer[j] = '_';
+ if (i - j > 9) i = j + 9;
+ j = i + 4;
+ }
+ else if (c == '/') j = i + 9;
+ else if (i >= j) continue;
+ else if (c >= 'a' && c <= 'z') c += 'A'
- 'a';
+ else if ((c < 'A' || c > 'Z') && (c <
'0' || c > '9')) c = '_';
+ buffer[i++] = c;
+ }
+ buffer[i] = 0;
+ return buffer;
+}
+
+static const char *unrockridge_iso(const char *name)
+{
+ const struct syslinux_version *sv;
+ sv = syslinux_version();
+ if (sv->filesystem != SYSLINUX_FS_ISOLINUX) {
+ return unrockridge(name);
+ } else {
+ return name;
+ }
+}
+
+static uint8_t *md5_file(const char *filename)
+{
+ int src_fd, count;
+ uint8_t in_buf[4096];
+ static uint8_t hash_value[16*2+1];
+ static unsigned char hash[16];
+ MD5_CTX context;
+
+ src_fd = open(filename, O_RDONLY);
+ if (src_fd < 0) {
+ src_fd = open(unrockridge_iso(filename), O_RDONLY);
+ }
+ if (src_fd < 0) {
+ return NULL;
+ }
+
+ MD5Init(&context);
+ while ((count = read(src_fd, in_buf, 4096)) > 0) {
+ MD5Update(&context, in_buf, count);
+ }
+
+ close(src_fd);
+
+ if (count)
+ return NULL;
+
+ MD5Final(hash, &context);
+ bin2hex((char *)hash_value, 16, hash);
+
+ return hash_value;
+}
+
+static int main_md5sum(int argc, char **argv)
+{
+ int files = 0, tested = 0, good = 0;
+ static char clear_eol[] = " ";
+
+ (void) argc;
+ /* -c implied */
+ argv++;
+ do {
+ FILE *fp;
+ char eol, *line, buffer[4096];
+ fp = fopen(*argv,"r");
+ if (fp == NULL)
+ fp = fopen(unrockridge_iso(*argv),"r");
+
+ while ((line = fgets(buffer,sizeof(buffer),fp)) != NULL) {
+ uint8_t *hash_value;
+ char *filename_ptr, *status;
+ int len = strlen(line);
+
+ if (line[0] < '0')
+ continue;
+ if (line[len-1] == '\n')
+ line[len-1] = 0;
+ filename_ptr = strstr(line, " ");
+ /* handle format for binary checksums */
+ if (filename_ptr == NULL) {
+ filename_ptr = strstr(line, " *");
+ }
+ if (filename_ptr == NULL) {
+ continue;
+ }
+ *filename_ptr = '\0';
+ *++filename_ptr = '/';
+ if (filename_ptr[1] == '/')
+ filename_ptr++;
+
+ files++;
+ status = "NOT CHECKED";
+ eol = '\n';
+ hash_value = md5_file(filename_ptr);
+ if (hash_value) {
+ tested++;
+ status = "BROKEN";
+ if (!strcmp((char*)hash_value, line)) {
+ good++;
+ status = "OK";
+ eol = ' ';
+ }
+ }
+ printf("\r%s: %s%s%c", filename_ptr, status, clear_eol, eol);
+ }
+ fclose(fp);
+ } while (*++argv);
+ printf("\r%d files OK, %d broken, %d not checked.%s\n",
+ good, tested - good, files - tested, clear_eol);
+ printf("\n\rWe are now paused. Read the above result. Press enter to
finish.\n");
+ break;
+ sleep(5);
+ return 0;
+}
--
-Ady