mirror of
https://github.com/clearlinux/swupd-server.git
synced 2026-11-21 23:05:22 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d4df7e035 | ||
|
|
4df4bf14c3 | ||
|
|
6affbd1ecb | ||
|
|
77a0bcd9f9 | ||
|
|
bf19e48917 | ||
|
|
d45304c8b7 | ||
|
|
2b4e9eb3c9 |
+2
-1
@@ -115,7 +115,8 @@ dist_check_SCRIPTS = \
|
|||||||
test/functional/fullfiles/test.bats \
|
test/functional/fullfiles/test.bats \
|
||||||
test/functional/pack/test.bats \
|
test/functional/pack/test.bats \
|
||||||
test/functional/full-run/test.bats \
|
test/functional/full-run/test.bats \
|
||||||
test/functional/full-run-delta/test.bats
|
test/functional/full-run-delta/test.bats \
|
||||||
|
test/functional/file-name-blacklisted/test.bats
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if COVERAGE
|
if COVERAGE
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
# Process this file with autoconf to produce a configure script.
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
AC_PREREQ([2.66])
|
AC_PREREQ([2.66])
|
||||||
AC_INIT(swupd-server, 3.2.2, timothy.c.pepper@linux.intel.com)
|
AC_INIT(swupd-server, 3.2.3, timothy.c.pepper@linux.intel.com)
|
||||||
AM_INIT_AUTOMAKE([foreign -Wall -W subdir-objects])
|
AM_INIT_AUTOMAKE([foreign -Wall -W subdir-objects])
|
||||||
AM_SILENT_RULES([yes])
|
AM_SILENT_RULES([yes])
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
|
|||||||
@@ -65,25 +65,5 @@ void chroot_create_full(int newversion)
|
|||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
free(command);
|
free(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and since some dumb files have things like install timestamps in
|
|
||||||
* them, we pull files from full back to bundles so each instance
|
|
||||||
* of the "same" file is truly identical across bundles. It may
|
|
||||||
* make sense at some point to add more logic here for conflict
|
|
||||||
* detection and resolution, including work to insure renames are
|
|
||||||
* consistent across groups. */
|
|
||||||
while (1) {
|
|
||||||
group = next_group();
|
|
||||||
if (!group) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG(NULL, "Recopy bundle chroot out of full", "%s", group);
|
|
||||||
string_or_die(&command, "rsync -aAX --existing %s %s/%i/%s",
|
|
||||||
full_dir, image_dir, newversion, group);
|
|
||||||
ret = system(command);
|
|
||||||
assert(ret == 0);
|
|
||||||
free(command);
|
|
||||||
}
|
|
||||||
free(full_dir);
|
free(full_dir);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ static void create_fullfile(struct file *file)
|
|||||||
if (rmdir(rename_tmpdir)) {
|
if (rmdir(rename_tmpdir)) {
|
||||||
LOG(NULL, "rmdir failed for %s", rename_tmpdir);
|
LOG(NULL, "rmdir failed for %s", rename_tmpdir);
|
||||||
}
|
}
|
||||||
|
free(rename_tmpdir);
|
||||||
|
|
||||||
free(tmp1);
|
free(tmp1);
|
||||||
free(tmp2);
|
free(tmp2);
|
||||||
|
|||||||
+35
-2
@@ -729,6 +729,9 @@ static int write_manifest_plain(struct manifest *manifest)
|
|||||||
char *conf = config_output_dir();
|
char *conf = config_output_dir();
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
char *submanifest_filename = NULL;
|
char *submanifest_filename = NULL;
|
||||||
|
char *manifest_tempdir = NULL;
|
||||||
|
char *tarcommand = NULL;
|
||||||
|
char *tempmanifest = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (conf == NULL) {
|
if (conf == NULL) {
|
||||||
@@ -776,24 +779,54 @@ static int write_manifest_plain(struct manifest *manifest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
list = g_list_first(manifest->manifests);
|
list = g_list_first(manifest->manifests);
|
||||||
|
string_or_die(&manifest_tempdir, "%s/XXXXXX", state_dir);
|
||||||
|
if (!mkdtemp(manifest_tempdir)) {
|
||||||
|
LOG(NULL, "Failed to create temporary directory %s for untarring Manifests", manifest_tempdir);
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
while (list) {
|
while (list) {
|
||||||
file = list->data;
|
file = list->data;
|
||||||
list = g_list_next(list);
|
list = g_list_next(list);
|
||||||
|
|
||||||
string_or_die(&submanifest_filename, "%s/%i/Manifest.%s", conf, file->last_change, file->filename);
|
string_or_die(&submanifest_filename, "%s/%i/Manifest.%s", conf, file->last_change, file->filename);
|
||||||
populate_file_struct(file, submanifest_filename);
|
populate_file_struct(file, submanifest_filename);
|
||||||
ret = compute_hash(file, submanifest_filename);
|
|
||||||
|
if (file->is_deleted) {
|
||||||
|
goto write_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Untar the Manifest.BUNDLE.tar and calculate the hash on that,
|
||||||
|
* otherwise we may get incorrect hashes due to owner permissions on
|
||||||
|
* the files. */
|
||||||
|
string_or_die(&tarcommand, TAR_COMMAND " -C %s " TAR_PERM_ATTR_ARGS " -xf %s.tar 2> /dev/null",
|
||||||
|
manifest_tempdir, submanifest_filename);
|
||||||
|
if (system(tarcommand) != 0) {
|
||||||
|
LOG(NULL, "Failed to run command:", "%s", tarcommand);
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
free(tarcommand);
|
||||||
|
string_or_die(&tempmanifest, "%s/Manifest.%s", manifest_tempdir, file->filename);
|
||||||
|
populate_file_struct(file, tempmanifest);
|
||||||
|
ret = compute_hash(file, tempmanifest);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
printf("Hash computation failed\n");
|
printf("Hash computation failed\n");
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
unlink(tempmanifest);
|
||||||
|
free(tempmanifest);
|
||||||
|
write_entry:
|
||||||
fprintf(out, "%s\t%s\t%i\t%s\n", file_type_to_string(file), file->hash, file->last_change, file->filename);
|
fprintf(out, "%s\t%s\t%i\t%s\n", file_type_to_string(file), file->hash, file->last_change, file->filename);
|
||||||
free(submanifest_filename);
|
free(submanifest_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
exit:
|
exit:
|
||||||
|
if (rmdir(manifest_tempdir) != 0) {
|
||||||
|
LOG(NULL, "rmdir failed for %s: %s", manifest_tempdir, strerror(errno));
|
||||||
|
}
|
||||||
|
free(manifest_tempdir);
|
||||||
|
|
||||||
if (out) {
|
if (out) {
|
||||||
fclose(out);
|
fclose(out);
|
||||||
}
|
}
|
||||||
|
|||||||
+40
@@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
# common functions
|
||||||
|
load "../swupdlib"
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
clean_test_dir
|
||||||
|
init_test_dir
|
||||||
|
|
||||||
|
init_server_ini
|
||||||
|
set_latest_ver 0
|
||||||
|
init_groups_ini os-core
|
||||||
|
|
||||||
|
set_os_release 10 os-core
|
||||||
|
track_bundle 10 os-core
|
||||||
|
|
||||||
|
gen_file_plain 10 os-core "semicolon;"
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_illegal_char() {
|
||||||
|
local output="$1"
|
||||||
|
local str=$(echo "Filename $2 includes illegal character(s)")
|
||||||
|
[[ "$output" =~ "$str" ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_valid_char() {
|
||||||
|
local output="$1"
|
||||||
|
local str=$(echo "Filename $2 includes illegal character(s)")
|
||||||
|
[[ ! "$output" =~ "$str" ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "file names with blacklisted characters" {
|
||||||
|
run sudo sh -c "$CREATE_UPDATE --osversion 10 --statedir $DIR --format 3"
|
||||||
|
|
||||||
|
echo "$output"
|
||||||
|
assert_illegal_char "$output" "/semicolon;"
|
||||||
|
assert_valid_char "$output" "/usr"
|
||||||
|
}
|
||||||
|
|
||||||
|
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
|
||||||
@@ -87,21 +87,21 @@ gen_file_to_delta() {
|
|||||||
gen_file_plain() {
|
gen_file_plain() {
|
||||||
local ver=$1
|
local ver=$1
|
||||||
local bundle=$2
|
local bundle=$2
|
||||||
local name=$3
|
local name="$3"
|
||||||
|
|
||||||
# Add plain text file into a bundle
|
# Add plain text file into a bundle
|
||||||
mkdir -p $DIR/image/$ver/$bundle
|
mkdir -p $DIR/image/$ver/$bundle
|
||||||
echo $name > $DIR/image/$ver/$bundle/$name
|
echo "$name" > $DIR/image/$ver/$bundle/"$name"
|
||||||
}
|
}
|
||||||
|
|
||||||
gen_file_plain_change() {
|
gen_file_plain_change() {
|
||||||
local ver=$1
|
local ver=$1
|
||||||
local bundle=$2
|
local bundle=$2
|
||||||
local name=$3
|
local name="$3"
|
||||||
|
|
||||||
# Add plain text file into a bundle
|
# Add plain text file into a bundle
|
||||||
mkdir -p $DIR/image/$ver/$bundle
|
mkdir -p $DIR/image/$ver/$bundle
|
||||||
echo $ver $name > $DIR/image/$ver/$bundle/$name
|
echo "$ver $name" > $DIR/image/$ver/$bundle/"$name"
|
||||||
}
|
}
|
||||||
|
|
||||||
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
|
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
|
||||||
|
|||||||
Reference in New Issue
Block a user