-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dont delete user content #1625
Dont delete user content #1625
Conversation
The remove_files_in_manifest_from_fs function isn't used and was a user of a rather dangerous recursive remove function. Get rid of it to avoid potential confusion. Signed-off-by: William Douglas <[email protected]>
1547203
to
9c4befb
Compare
src/swupd_lib/target_root.c
Outdated
@@ -330,6 +333,61 @@ static enum swupd_code install_dir(const char *fullfile_path, const char *target | |||
return install_dir_using_tar(fullfile_path, target_file); | |||
} | |||
|
|||
/* Backup target directory to a backup and timestamp prefixed name. */ | |||
/* This function should only be used after the deletes are processed. */ | |||
static enum swupd_code move_to_timestamp(const char *filename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe call it "dirname" not "filename" to indicate we expect it to be a directory?
src/swupd_lib/target_root.c
Outdated
|
||
/* It shouldn't be possible to have an already created backup_dir | ||
but just in case, try and remove it and error out if unable to. */ | ||
ret = sys_rm_recursive(backup_dir); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shuold we actually check if this is there first? just incase we have some bug... then it only ever happens if it actually exists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, less to go wrong. I suspect if things are going wrong in this area though we are in a whole different world of hurt that'll show up all over in testing.
Currently sys_rm_recursive was used in any instance of deleting swupd content from the system (update, repair and bundle-remove). This can cause user data loss when unkown files are in directories that swupd is deleting. To prevent this, this patch changes how deleting content in swupd operates. Swupd content removal is now done with sys_rm and the return value is checked in case the removal failed due to a directory that still had files in it. When this specific failure occurs, the directory is added to a new list for reprocessing removals as it is expected once the rest of the deletes on the system occur the failures will go away as the directories will be empty (these deletes are processed in alphabetical reverse order so leaf directories are processed first). If the removal fails again it is presumed the contents of the directory are not files swupd knows about and as such should be kept somewhere else. For handling the retention of user data, directories (with only the content unknown to swupd) are renamed (currently using a .deleted.$timestamp. prefix of the old name) and stored at the same directory level they were previously found with one exception. The exception is for nested deleted content best illustrated with an example: /swupd-dir1/user-file1 /swupd-dir1/swupd-dir2/user-file2 When swupd tries to remove the /swupd-dir1 content, it will store the user files as follows: /.deleted.$timestamp1.swupd-dir1/user-file1 /.deleted.$timestamp1.swupd-dir1/.deleted.$timestamp1.swupd-dir2/user-file2 To demarcate what was part of swupd content vs user content. Signed-off-by: William Douglas <[email protected]>
9c4befb
to
987ee9e
Compare
No description provided.