trash-cli icon indicating copy to clipboard operation
trash-cli copied to clipboard

trash-put: block 'trash-put /*' (was 无法阻止命令rm -rf /* 删除根目录)

Open YJiWei opened this issue 4 years ago • 8 comments

[root@myserver files]# which rm alias rm='trash' /usr/bin/trash [root@myserver rfiles]# rm -rf /* trash: cannot trash directory '/boot'

Running rm-rf / directly allows you to delete some system files, and you cannot use trash-restore after the deletion 直接执行 rm -rf /是可以删除部分系统文件的,而且删除后无法使用trash-restore恢复

[root@myserver files]# trash-restore Traceback (most recent call last): File "/usr/bin/trash-restore", line 5, in sys.exit(main()) File "/usr/lib/python2.7/site-packages/trashcli/cmds.py", line 16, in restore input = input23 File "/usr/lib/python2.7/site-packages/trashcli/restore.py", line 31, in init mount_points = fstab.mount_points() File "/usr/lib/python2.7/site-packages/trashcli/fstab.py", line 13, in mount_points return self.ismount.mount_points() File "/usr/lib/python2.7/site-packages/trashcli/fstab.py", line 40, in mount_points return os_mount_points() File "/usr/lib/python2.7/site-packages/trashcli/list_mount_points.py", line 5, in mount_points return list(mount_points_from_getmnt()) File "/usr/lib/python2.7/site-packages/trashcli/list_mount_points.py", line 10, in mount_points_from_getmnt for elem in _mounted_filesystems_from_getmnt(): File "/usr/lib/python2.7/site-packages/trashcli/list_mount_points.py", line 57, in _mounted_filesystems_from_getmnt libc = cdll.LoadLibrary(libc_name) File "/usr/lib64/python2.7/ctypes/init.py", line 438, in LoadLibrary return self._dlltype(name) File "/usr/lib64/python2.7/ctypes/init.py", line 360, in init self._handle = _dlopen(self._name, mode) OSError: /lib/libc.so.6: cannot open shared object file: No such file or directory

YJiWei avatar May 08 '20 08:05 YJiWei

trash中删除文件的命令是 trash-put吧。我不知道trash命令的作用。

gebangfeng avatar May 13 '20 11:05 gebangfeng

Trash-Cli dependent libraries are deleted after rm -rf /*

w3n9 avatar Dec 01 '20 05:12 w3n9

Please do not use trash-cli for deleting system folders using the root user

andreafrancia avatar Dec 11 '20 20:12 andreafrancia

yes I can't put it better

------------------ 原始邮件 ------------------ 发件人: "andreafrancia/trash-cli" <[email protected]>; 发送时间: 2020年12月12日(星期六) 凌晨4:36 收件人: "andreafrancia/trash-cli"<[email protected]>; 抄送: "啊!我不会一个人"<[email protected]>;"Comment"<[email protected]>; 主题: Re: [andreafrancia/trash-cli] 无法阻止命令rm -rf /* 删除根目录 (#167)

Please do not use trash-cli for deleting system folders using the root user

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

gebangfeng avatar Dec 12 '20 08:12 gebangfeng

What @YJiWei saying is, some barrier should be equipped, such as --no-preserve-root for rm -rf /, isn't it?

Without the alias setting, though, if trash-put ./* is mistyped, ... dear! X(

KSR-Yasuda avatar Dec 14 '20 02:12 KSR-Yasuda

Why would you alias rm to trash? You will break every script that uses rm.

jxu avatar Feb 03 '21 09:02 jxu