Re: EXTERNAL: Virus that deletes everything under c:/cygwin?
* Christopher Faylor (Tue, 29 Mar 2011 11:35:33 -0400) On Tue, Mar 29, 2011 at 05:33:05PM +0200, Thorsten Kampe wrote: * Dave Korn (Tue, 29 Mar 2011 14:46:13 +0100) On 29/03/2011 10:12, Thorsten Kampe wrote: As for rm, it already does kind-of have safeguards against this, and that's what the -f option is for - it turns them off. As far as I know -f is already the default... If you're saying that -f is always active when you type rm then, no that is not true. I'm saying that ignore nonexistent files, never prompt is the default behaviour if you're running plain unaliased /usr/bin/rm.exe. Thorsten -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Re: EXTERNAL: Virus that deletes everything under c:/cygwin?
* Dave Korn (Wed, 30 Mar 2011 00:11:05 +0100) And I just learnt about the `--preserve-root' option, that I didn't even know about before. You mean --preserve-root do not remove `/' (default) (quoting the man page)? I wonder whether I will receive another If you're saying that -- preserve-root is always active when you type rm then, no that is not true response. Thorsten -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Re: EXTERNAL: Virus that deletes everything under c:/cygwin?
On 30 March 2011 09:27, Thorsten Kampe wrote: * Christopher Faylor (Tue, 29 Mar 2011 11:35:33 -0400) On Tue, Mar 29, 2011 at 05:33:05PM +0200, Thorsten Kampe wrote: As far as I know -f is already the default... If you're saying that -f is always active when you type rm then, no that is not true. I'm saying that ignore nonexistent files, never prompt is the default behaviour if you're running plain unaliased /usr/bin/rm.exe. It isn't. $ rm foo; echo $? rm: cannot remove `foo': No such file or directory 1 $ rm -f foo; echo $? 0 Andy -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Re: EXTERNAL: Virus that deletes everything under c:/cygwin?
* Dante Allegria (Mon, 28 Mar 2011 10:07:32 -0700 (PDT)) No, turns out it was because someone committed this into the nightly build scripts: rm -rf $(DOES_NOT_EXIST)/* sigh Should cygwin's rm have some built-in safeguards for this? :) Sure, it does. It's called intelligent scripting and it includes setting errexit and nounset in bash or Z Shell. If you are scripting and not using those above, then you got exactly what you deserved. Thorsten -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Re: EXTERNAL: Virus that deletes everything under c:/cygwin?
Thorsten Kampe wrote: Sure, it does. It's called intelligent scripting and it includes setting errexit and nounset in bash or Z Shell. If you are scripting and not using those above, then you got exactly what you deserved. Thanks for the tip, Thorsten! Any ideas what the best practice is for doing this in Makefile rules? It seems rather onerous to put this in *every* rule. dante -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Re: EXTERNAL: Virus that deletes everything under c:/cygwin?
On 3/29/2011 08:30, Dante Allegria wrote: Thorsten Kampe wrote: Sure, it does. It's called intelligent scripting and it includes setting errexit and nounset in bash or Z Shell. If you are scripting and not using those above, then you got exactly what you deserved. Thanks for the tip, Thorsten! Any ideas what the best practice is for doing this in Makefile rules? It seems rather onerous to put this in *every* rule. Set the SHELLOPTS environment variable before calling make. Set each option you wish to enable in a colon separated list. Read the bash manpage for more details about that environment variable and the set builtin command. -Jeremy -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Re: EXTERNAL: Virus that deletes everything under c:/cygwin?
On 29/03/2011 10:12, Thorsten Kampe wrote: * Dante Allegria (Mon, 28 Mar 2011 10:07:32 -0700 (PDT)) No, turns out it was because someone committed this into the nightly build scripts: rm -rf $(DOES_NOT_EXIST)/* sigh Should cygwin's rm have some built-in safeguards for this? :) Sure, it does. It's called intelligent scripting and it includes setting errexit and nounset in bash or Z Shell. If you are scripting and not using those above, then you got exactly what you deserved. Judging by those brackets being round rather than curly, I wouldn't have thought we're dealing with a bash variable here but a makefile one, so nounset isn't going to help if make just hands it a well-formed rm -rf /* command. As for rm, it already does kind-of have safeguards against this, and that's what the -f option is for - it turns them off. So, what you'd really need to avoid this problem is some kind of safeguards that can't possibly be turned off... which would somewhat limit the general usability of rm. That's why it doesn't have any built-in; but you can get the same effect by replacing rm with a wrapper script in your build environment, and put any safeguards you want (e.g.: disallow -f option, check for sane paths correctly located under build dir, etc. etc.) into that. You could use coding standards and repository commit hooks to make sure that every script uses $(RM) rather than invoking rm explicitly, and set that to point to your wrapper in some central include file, and bingo. An alternative possibility: do all your builds in a chroot'ed jail. Jails may not be effective as security measures since it's possible to deliberately break out of them, but they'd certainly work to protect against this kind of unfortunate accident. cheers, DaveK -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Re: EXTERNAL: Virus that deletes everything under c:/cygwin?
* Dave Korn (Tue, 29 Mar 2011 14:46:13 +0100) On 29/03/2011 10:12, Thorsten Kampe wrote: As for rm, it already does kind-of have safeguards against this, and that's what the -f option is for - it turns them off. As far as I know -f is already the default... Thorsten -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Re: EXTERNAL: Virus that deletes everything under c:/cygwin?
On Tue, Mar 29, 2011 at 05:33:05PM +0200, Thorsten Kampe wrote: * Dave Korn (Tue, 29 Mar 2011 14:46:13 +0100) On 29/03/2011 10:12, Thorsten Kampe wrote: As for rm, it already does kind-of have safeguards against this, and that's what the -f option is for - it turns them off. As far as I know -f is already the default... If you're saying that -f is always active when you type rm then, no that is not true. cgf -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Re: EXTERNAL: Virus that deletes everything under c:/cygwin?
On 29/03/2011 16:35, Christopher Faylor wrote: On Tue, Mar 29, 2011 at 05:33:05PM +0200, Thorsten Kampe wrote: * Dave Korn (Tue, 29 Mar 2011 14:46:13 +0100) On 29/03/2011 10:12, Thorsten Kampe wrote: As for rm, it already does kind-of have safeguards against this, and that's what the -f option is for - it turns them off. As far as I know -f is already the default... If you're saying that -f is always active when you type rm then, no that is not true. And I just learnt about the `--preserve-root' option, that I didn't even know about before. (Not that that helps when you've typed '/*' rather than '/' though... and in fact that trailing '/*' probably wasn't actually deliberately intended to leave files beginning with a period behind) cheers, DaveK -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Re: EXTERNAL: Virus that deletes everything under c:/cygwin?
On 3/28/2011 10:43 AM, Dante Allegria wrote: We just discovered that a whole bunch of our Windows machines had everything under their c:/cygwin directories deleted over the weekend. You said we and bunch which leads me to believe that you are using this at a company. Is that so? Do you have an aggressive IS department who might have decided they don't like Cygwin? Damon Register -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Re: EXTERNAL: Virus that deletes everything under c:/cygwin?
--- On Mon, 3/28/11, Damon Register damon.w.regis...@lmco.com wrote: this at a company. Is that so? Do you have an aggressive IS department who might have decided they don't like Cygwin? No, turns out it was because someone committed this into the nightly build scripts: rm -rf $(DOES_NOT_EXIST)/* sigh Should cygwin's rm have some built-in safeguards for this? :) Thanks for all those who replied! dante -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Re: EXTERNAL: Virus that deletes everything under c:/cygwin?
On 3/28/2011 12:07, Dante Allegria wrote: --- On Mon, 3/28/11, Damon Register damon.w.regis...@lmco.com wrote: this at a company. Is that so? Do you have an aggressive IS department who might have decided they don't like Cygwin? No, turns out it was because someone committed this into the nightly build scripts: rm -rf $(DOES_NOT_EXIST)/* sigh Should cygwin's rm have some built-in safeguards for this? :) Probably the only way to get this protection would be to remove the ability of the user running your build automation to delete the Cygwin installation in the first place. Otherwise, this could just as easily happen somewhere else such as a Perl script that doesn't even use rm. Depending on your situation, that may be easier said than done unfortunately. -Jeremy -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple