3 ms·
While i agree with the general folly of piping to a shell, have you ever actually tried to do a rm -rf / ? Most modern posix systems will catch you, even if you
by secstate 13y ago
While i agree with the general folly of piping to a shell, have you ever actually tried to do a rm -rf / ? Most modern posix systems will catch you, even if you sudo it.
Also, barring that example I can't come up with many other horrible scenario. Unfortunate ones, sure. But not catastrophic. And as someone else said, adding random ppas would allow much worse things, and people do that all the time.
- randuser 13y agorm -rf ~
- mturmon 13y agodir_user_old=/home/luser/.old_version dir_user=/home/luser rm -rf $dir_user_old ^ Truncate at the caret (^), and it turns into: dir_user_old=/home/luser/.old_version dir_user=/home/luser rm -rf $dir_user which removes your home directory. Incidentally, I think the last example in the OP ("rm -rf /") is wrong. The "/" would never be transmitted, it is part of the variable $TMP_DIR which is expanded on the local system, not the remote server. But the idea and the other test with echo seem correct.
- codezero 13y agoAssuming the probability that you drop connection is evenly distributed amongst all characters, even if there is no payload and this is all that is executed then there's barely a 1% chance of the truncation happening in the way you describe. Considering that there is usually a sizable payload and the probability of a dropped connection is not evenly distributed and is probably very low, the scenario gets even less likely. Yes, it's possible, but it's also possible to rm -rf / because you typed a path wrong and I bet the probability of human error is much higher than the probability of this shell trick screwing you over. People have rm -rf /'d their systems, but even this isn't a good reason to advocate for say, removing rm entirely or not allowing people to type into the shell :P
- Sanddancer 13y agofor N in /*; do rm -rf $N || rm $N; done
- secstate 13y agoTribbles! Downvoted. But here's my point: http://www.linuxbsdos.com/2012/04/29/what-will-rm-rf-actually-do-to-your-linuxbsd-machine/ http://www.linuxbsdos.com/2012/04/29/what-will-rm-rf-actuall...