[iso] update MD5SUMS/md5sums.txt text file for distros that have them

* The upcoming Ubuntu 20.04 comes with MD5 validation turned on by default.
* When creating persistent boot media, we may update some of the validated files
  to add persistence, update the search labels, etc.
* Make sure that the files we modify get their MD5 updated where needed.
* Also add 'loopback.cfg' to the list of config files we can add persistence to.
* Part of #1499
This commit is contained in:
Pete Batard 2020-04-06 16:27:05 +01:00
parent 045f590c3b
commit 1e6e38b180
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
4 changed files with 153 additions and 29 deletions

View file

@ -2,7 +2,7 @@
* Rufus: The Reliable USB Formatting Utility
* Standard User I/O Routines (logging, status, error, etc.)
* Copyright © 2020 Mattiwatti <mattiwatti@gmail.com>
* Copyright © 2011-2019 Pete Batard <pete@akeo.ie>
* Copyright © 2011-2020 Pete Batard <pete@akeo.ie>
*
* 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
@ -93,6 +93,53 @@ void _uprintfs(const char* str)
free(wstr);
}
uint32_t read_file(const char* path, uint8_t** buf)
{
FILE* fd = fopenU(path, "rb");
if (fd == NULL) {
uprintf("Error: Can't open file '%s'", path);
return 0;
}
fseek(fd, 0L, SEEK_END);
uint32_t size = (uint32_t)ftell(fd);
fseek(fd, 0L, SEEK_SET);
*buf = malloc(size);
if (*buf == NULL) {
uprintf("Error: Can't allocate %d bytes buffer for file '%s'", size, path);
size = 0;
goto out;
}
if (fread(*buf, 1, size, fd) != size) {
uprintf("Error: Can't read '%s'", path);
size = 0;
}
out:
fclose(fd);
if (size == 0) {
free(*buf);
*buf = NULL;
}
return size;
}
uint32_t write_file(const char* path, const uint8_t* buf, const uint32_t size)
{
uint32_t written;
FILE* fd = fopenU(path, "wb");
if (fd == NULL) {
uprintf("Error: Can't create '%s'", path);
return 0;
}
written = (uint32_t)fwrite(buf, 1, size, fd);
if (written != size)
uprintf("Error: Can't write '%s'", path);
fclose(fd);
return written;
}
// Prints a bitstring of a number of any size, with or without leading zeroes.
// See also the printbits() and printbitslz() helper macros in rufus.h
char *_printbits(size_t const size, void const * const ptr, int leading_zeroes)