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

tools/filegone: Support rename/unlink failed situation #4792

Merged
merged 1 commit into from
Nov 7, 2023

Conversation

Rtoax
Copy link
Contributor

@Rtoax Rtoax commented Nov 5, 2023

When deleting or renaming a file or folder for which you do not have permissions, vfs_unlink/rename will fail and we should skip the failure.

Reproducing the problem:

Terminal 1:

    $ sudo ./filegone.py

Terminal 2, failed 1,2,3,4:

    $ sudo touch /etc/a.txt
    $ sudo mkdir /etc/a.dir
    $ # Permission deny
    $ rm -f /etc/a.txt
    rm: cannot remove '/etc/a.txt': Permission denied               << 1
    $ mv /etc/a.txt /etc/b.txt
    mv: cannot move '/etc/a.txt' to '/etc/b.txt': Permission denied << 2
    $ rmdir /etc/a.dir
    rmdir: failed to remove '/etc/a.dir': Permission denied         << 3
    $ mv /etc/a.dir /etc/b.dir
    mv: cannot move '/etc/a.dir' to '/etc/b.dir': Permission denied << 4
    $ # Success gone
    $ sudo mv /etc/a.txt /etc/b.txt
    $ sudo rm /etc/b.txt
    $ sudo mv /etc/a.dir /etc/b.dir
    $ sudo rmdir /etc/b.dir

Then terminal 1, wrong statistic 1,2,3,4:

    $ sudo ./filegone.py
    TIME     PID     COMM             ACTION FILE
    13:32:11 10767   rm               DELETE a.txt                  << 1
    13:32:11 10768   mv               RENAME a.txt > b.txt          << 2
    13:32:11 10769   rmdir            DELETE a.dir                  << 3
    13:32:11 10770   mv               RENAME a.dir > b.dir          << 4
    13:32:11 10772   mv               RENAME a.txt > b.txt
    13:32:11 10774   rm               DELETE b.txt
    13:32:11 10776   mv               RENAME a.dir > b.dir
    13:32:11 10778   rmdir            DELETE b.dir

This commit fix the statistical error above, the result:

    $ sudo ./filegone.py
    TIME     PID     COMM             ACTION FILE
    13:36:52 10937   mv               RENAME a.txt > b.txt
    13:36:52 10939   rm               DELETE b.txt
    13:36:52 10941   mv               RENAME a.dir > b.dir
    13:36:52 10943   rmdir            DELETE b.dir

tools/filegone.py Show resolved Hide resolved
tools/filegone.py Outdated Show resolved Hide resolved
When deleting or renaming a file or folder for which you do not have
permissions, vfs_unlink/rename will fail and we should skip the failure.

Reproducing the problem:

  Terminal 1:

    $ sudo ./filegone.py

  Terminal 2, failed 1,2,3,4:

    $ sudo touch /etc/a.txt
    $ sudo mkdir /etc/a.dir
    $ # Permission deny
    $ rm -f /etc/a.txt
    rm: cannot remove '/etc/a.txt': Permission denied               << 1
    $ mv /etc/a.txt /etc/b.txt
    mv: cannot move '/etc/a.txt' to '/etc/b.txt': Permission denied << 2
    $ rmdir /etc/a.dir
    rmdir: failed to remove '/etc/a.dir': Permission denied         << 3
    $ mv /etc/a.dir /etc/b.dir
    mv: cannot move '/etc/a.dir' to '/etc/b.dir': Permission denied << 4
    $ # Success gone
    $ sudo mv /etc/a.txt /etc/b.txt
    $ sudo rm /etc/b.txt
    $ sudo mv /etc/a.dir /etc/b.dir
    $ sudo rmdir /etc/b.dir

  Then terminal 1, wrong statistic 1,2,3,4:

    $ sudo ./filegone.py
    TIME     PID     COMM             ACTION FILE
    13:32:11 10767   rm               DELETE a.txt                  << 1
    13:32:11 10768   mv               RENAME a.txt > b.txt          << 2
    13:32:11 10769   rmdir            DELETE a.dir                  << 3
    13:32:11 10770   mv               RENAME a.dir > b.dir          << 4
    13:32:11 10772   mv               RENAME a.txt > b.txt
    13:32:11 10774   rm               DELETE b.txt
    13:32:11 10776   mv               RENAME a.dir > b.dir
    13:32:11 10778   rmdir            DELETE b.dir

This commit fix the statistical error above, the result:

    $ sudo ./filegone.py
    TIME     PID     COMM             ACTION FILE
    13:36:52 10937   mv               RENAME a.txt > b.txt
    13:36:52 10939   rm               DELETE b.txt
    13:36:52 10941   mv               RENAME a.dir > b.dir
    13:36:52 10943   rmdir            DELETE b.dir

Signed-off-by: Rong Tao <[email protected]>
@Rtoax Rtoax force-pushed the patch-57-filegone-EPERM branch from fae1d99 to 1c8b1ec Compare November 7, 2023 00:38
@yonghong-song yonghong-song merged commit 130c81d into iovisor:master Nov 7, 2023
4 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants