Skip to content
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

Script called with -p calls rmlint for directory compare - overwrites rmlint.sh etc. despite -x flag being set #552

Closed
james-cook opened this issue Feb 6, 2022 · 3 comments
Labels

Comments

@james-cook
Copy link

Calling sudo ./rmlint.sh -px
A directory compare takes place for example if paranoid mode is selected.

The resulting call to rmlint (the command not the script) overwrites the rmlint.sh and rmlint.json despite -x being specified

This can be a little disconcerting

@cebtenzzre
Copy link
Contributor

Related to #458: When --equal is passed, rm_cmd_parse_equal gets called before rm_cmd_set_outputs, so the rm_fmt_clear call is ineffective.

@cebtenzzre
Copy link
Contributor

 lib/cmdline.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/cmdline.c b/lib/cmdline.c
index 49c81627..b3b884c5 100644
--- a/lib/cmdline.c
+++ b/lib/cmdline.c
@@ -1060,6 +1060,10 @@ static bool rm_cmd_set_paths(RmSession *session, char **paths) {
 }
 
 static bool rm_cmd_set_outputs(RmSession *session, GError **error) {
+    if(session->cfg->run_equal_mode) {
+        return true;
+    }
+
     if(session->output_cnt[0] >= 0 && session->output_cnt[1] >= 0) {
         g_set_error(error, RM_ERROR_QUARK, 0,
                     _("Specifying both -o and -O is not allowed"));

I haven't tested this patch but it should work around the issue. The correct fix would be to have dedicated option parsing for --equal, just like --is-reflink and --dedupe - I disagree with the conclusion in #483 that it is fine as-is, because although it uses the main "shredder" code, it should only allow a narrow subset of options because of its specific purpose.

@james-cook
Copy link
Author

I haven't had a chance to test this yet.

Just to restate in case it gets forgotten:
As mentioned (#553)
the problem is that the running rmlint.sh can currently overwrite itself as it is executing - and this can in fact change what is being executed leading to unexpected results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants