andreafrancia / trash-cli

Command line interface to the freedesktop.org trashcan.
GNU General Public License v2.0
3.63k stars 177 forks source link

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

Open YJiWei opened 4 years ago

YJiWei commented 4 years ago

[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

gebangfeng commented 4 years ago

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

w3n9 commented 3 years ago

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

andreafrancia commented 3 years ago

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

gebangfeng commented 3 years ago

yes I can't put it better

------------------ 原始邮件 ------------------ 发件人: "andreafrancia/trash-cli" <notifications@github.com>; 发送时间: 2020年12月12日(星期六) 凌晨4:36 收件人: "andreafrancia/trash-cli"<trash-cli@noreply.github.com>; 抄送: "啊!我不会一个人"<2468558247@qq.com>;"Comment"<comment@noreply.github.com>; 主题: 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.

KSR-Yasuda commented 3 years ago

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(

jxu commented 3 years ago

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

jmtd commented 3 weeks ago

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

Scripts don't honour aliases; they're for interactive shells.

jxu commented 3 weeks ago

I put my aliases in ~/.bash_aliases. Idk if they are sourced or not