Re: [PLUG] One-liners to empty all files in a directory?
> "Jameson" == Jameson Williams writes: Jameson> Hm, I'll be damned. Truncate is part of coreutils, but /is/ relatively new Jameson> (2008)! Here's where it got merged: Jameson> http://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=75e0047c4b916393b6be3cb985c4c4d4a2d1a836 Wait... *GNU* coreutils. I haven't installed *GNU* coreutils in years. That's *not* unix. Please don't pretend it is. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 http://www.stonehenge.com/merlyn/> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.posterous.com/ for Smalltalk discussion ___ PLUG mailing list PLUG@lists.pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] One-liners to empty all files in a directory?
On 08/17/2011 08:51 PM, Randal L. Schwartz wrote: > Daniel> truncate -s0 * > > "man truncate" > > Not found. > > You're using some weird OS. Hm, I'll be damned. Truncate is part of coreutils, but /is/ relatively new (2008)! Here's where it got merged: http://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=75e0047c4b916393b6be3cb985c4c4d4a2d1a836 And a rationale thread on Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=467378 ___ PLUG mailing list PLUG@lists.pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] One-liners to empty all files in a directory?
> "Jameson" == Jameson Williams writes: Jameson> Agreed. /var/log definitely has some nesting, though (below). But that's no Jameson> excuse for me not to learn Perl. :-) Then why did you asy "a directory"? The subject line already says it. Please be more precise. A directory tree is *not* a directory. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 http://www.stonehenge.com/merlyn/> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.posterous.com/ for Smalltalk discussion ___ PLUG mailing list PLUG@lists.pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] One-liners to empty all files in a directory?
> "Jameson" == Jameson Williams writes: Jameson>find . -type f -exec truncate -s 0 {} \; Jameson> rm * might otherwise work well in most settings, but probably doesn't meet the Jameson> spec of the original one-liner problem statement. :-) Find is overkill if you're not descending directories. perl -e 'open F, ">$_" for @ARGV' * -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 http://www.stonehenge.com/merlyn/> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.posterous.com/ for Smalltalk discussion ___ PLUG mailing list PLUG@lists.pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] One-liners to empty all files in a directory?
On 08/17/2011 06:52 PM, Randal L. Schwartz wrote: > Jameson> I haven't been able to get this one yet. > Jameson> Challenge: A one-line statement (pipes okay, but explicit loops not) > Jameson> that empties all found files (as for debugging with /var/log, > Jameson> perse). > Randal> In a single directory? > Randal> > Randal> "rm *". > Randal> > Randal> What's hard with that? Well, to meet the problem at hand in /var/log: various log utilities expect the existence of files, or will complain. So, the best solution I've come up with (using Sam Hart's truncate suggestion) is: find . -type f -exec truncate -s 0 {} \; rm * might otherwise work well in most settings, but probably doesn't meet the spec of the original one-liner problem statement. :-) - Jameson ___ PLUG mailing list PLUG@lists.pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] One-liners to empty all files in a directory?
On 08/17/2011 08:10 PM, Randal L. Schwartz wrote: > Find is overkill if you're not descending directories. > >perl -e 'open F, ">$_" for @ARGV' * Agreed. /var/log definitely has some nesting, though (below). But that's no excuse for me not to learn Perl. :-) jameson@orange:/var/log$ sudo find /var/log -type d | sort /var/log /var/log/apache2 /var/log/apparmor /var/log/apt /var/log/ConsoleKit /var/log/cups /var/log/dist-upgrade /var/log/fsck /var/log/gdm /var/log/installer /var/log/installer/cdebconf /var/log/mysql /var/log/news /var/log/samba /var/log/samba/cores /var/log/samba/cores/winbindd /var/log/speech-dispatcher /var/log/tomcat6 /var/log/unattended-upgrades ___ PLUG mailing list PLUG@lists.pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] One-liners to empty all files in a directory?
On Wed, Aug 17, 2011 at 06:52:20PM -0700, Randal L. Schwartz wrote: > > "Jameson" == Jameson Williams writes: > > Jameson> I haven't been able to get this one yet. > Jameson> Challenge: A one-line statement (pipes okay, but explicit loops not) > Jameson> that empties all found files (as for debugging with /var/log, > Jameson> perse). > > In a single directory? > > "rm *". > > What's hard with that? That's not: michael@bivy:~/tme$ ls -l total 0 -rw-r--r-- 1 michael michael 0 2011-08-17 20:14 a -rw-r--r-- 1 michael michael 0 2011-08-17 20:14 b -rw-r--r-- 1 michael michael 0 2011-08-17 20:14 c -rw-r--r-- 1 michael michael 0 2011-08-17 20:14 d -rw-r--r-- 1 michael michael 0 2011-08-17 20:14 e michael@bivy:~/tme$ that's michael@bivy:~/tme$ ls -l total 0 michael@bivy:~/tme$ > -- > Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 > http://www.stonehenge.com/merlyn/> > Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. > See http://methodsandmessages.posterous.com/ for Smalltalk discussion > > ___ > PLUG mailing list > PLUG@lists.pdxlinux.org > http://lists.pdxlinux.org/mailman/listinfo/plug > -- Michael Rasmussen, Portland Oregon Other Adventures: http://www.jamhome.us/ or http://westy.saunter.us/ Fortune Cookie Fortune du jour: Dogs kill more humans than any animal except for other humans. ~ Bruce Schneier ___ PLUG mailing list PLUG@lists.pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] Using DNS information to close smtp port...
Hmm, people are being kinda quiet... There is code at the beginning of this thread, but trust me when I say there isn't a lot of code. Well, the DNS checking is increasing my rejection rate. Figuring out if I'm blocking at the right times is another issue. Is there ever a situation where a PTR record that doesn't resolve back to the IP you started with is legitimate? For example, one popular PTR record is localhost which obviously will not resolve to a remote IP address. ___ PLUG mailing list PLUG@lists.pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] One-liners to empty all files in a directory?
> "Jameson" == Jameson Williams writes: Jameson> I haven't been able to get this one yet. Jameson> Challenge: A one-line statement (pipes okay, but explicit loops not) Jameson> that empties all found files (as for debugging with /var/log, Jameson> perse). In a single directory? "rm *". What's hard with that? -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 http://www.stonehenge.com/merlyn/> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.posterous.com/ for Smalltalk discussion ___ PLUG mailing list PLUG@lists.pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] Looking for a Mid-Sr Perl Developer for Ops group
> "Kevin" == Kevin K writes: Kevin> My manager is opening a new req for a mid-sr level perl developer Kevin> for a operations group, supporting RHEL and FreeBSD servers. We Kevin> are still working with HR to get the job listed on the website, Kevin> but here is a job description: Please please please... post this to jobs.perl.org. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 http://www.stonehenge.com/merlyn/> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.posterous.com/ for Smalltalk discussion ___ PLUG mailing list PLUG@lists.pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] Why some sites no PTR record???
> "Michael" == Michael C Robinson writes: Michael> Should I go ahead and block if there's no reverse PTR record? Only if you want to lose about 10% of legitmate mail. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 http://www.stonehenge.com/merlyn/> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.posterous.com/ for Smalltalk discussion ___ PLUG mailing list PLUG@lists.pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
[PLUG] Using DNS information to close smtp port...
My perl based subroutine that does Net::DNS based checking follows, comments please... sub dns_rev_resolve() { # Check for a PTR record and try to match it up with an A query... ($ipsrc)=@_; my $target_IP = join('.', reverse split(/\./, $ipsrc)).".in-addr.arpa"; my $res = Net::DNS::Resolver->new; my $query = $res->query("$target_IP", "PTR"); if ( $query ) # Okay, there is a PTR record... { foreach my $rr ($query->answer) { next unless $rr->type eq "PTR"; $rev_addr = $rr->rdatastr; } my $res2 = Net::DNS::Resolver->new; my $forward_query = $res2->query("$rev_addr"); if ( $forward_query ) # Okay, the PTR record forward resolved... { foreach my $rr2 ($forward_query->answer) { next unless $rr2->type eq "A"; $forward_addr = $rr2->address; } } } else # NO PTR record will be treated as a match for now... { return "YES"; } if ( $forward_addr =~ /$ipsrc/ ) # Check for a real match in this case... { return "YES"; } else { return "NO"; } } # END of dns_rev_resolve... ___ PLUG mailing list PLUG@lists.pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] The problem with DNS blacklists...
On Wed, 2011-08-17 at 09:34 -0700, Russell Johnson wrote: > On Aug 16, 2011, at 11:20 PM, Michael C. Robinson wrote: > > > Is it > > legitimate for their to be no reverse record when one site is hosted on > > the IP block of another? > > Unfortunately, there are a lot of DNS admins out there that don't reverse > list their forward tables. > > Russell Johnson > r...@dimstar.net I think my Postfix implementation uses a third party SPF checking Perl script already where I question whether SPF checks are simple enough to do for a should we close the door or not script. Remember, I'm a Perl novice where one of my goals is to write something that a fellow Perl novice would pick up. To improve my script, I've written a second function and I've moved the Net::DNS stuff to it. I have the standard is the IP listed check and I've added a call to my function when the answer is NO. I try a PTR record check on the IP where failing that, the DNS test passes. On success, I take the host name answer and do an A record query. If the IP I started with for the PTR query shows up when the A query is done, there is a match. If no match and a PTR record exists, this test fails. I noticed doing DNS checking that the PTR record is sometimes absurd. The worst I have seen is localhost. Is it sensible to reject based on there being an absurd PTR record? There is more than just SPF checking, there are encrypted signatures where you use public key cryptography... This is beyond simple, but is there anything I can use??? If I can provide an English explanation that a novice would be able to follow, I think I can bend the simple rule a bit. My other thought is, there has to be an MX record to tell you where to reply to. Okay, can I use that information somehow in deciding whether or not to close the door? In other words, is it more informative to look at MX records than PTR records? ___ PLUG mailing list PLUG@lists.pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] The problem with DNS blacklists...
On Aug 16, 2011, at 11:20 PM, Michael C. Robinson wrote: > Is it > legitimate for their to be no reverse record when one site is hosted on > the IP block of another? Unfortunately, there are a lot of DNS admins out there that don't reverse list their forward tables. Russell Johnson r...@dimstar.net ___ PLUG mailing list PLUG@lists.pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] The problem with DNS blacklists...
On Aug 16, 2011, at 10:09 PM, Michael C. Robinson wrote: > A curious question, shouldn't I be able to look up any IP that is > claiming to be a mail server via the DNS system? In theory, yes. In practice, no. The only mail server records that have to be there are MX records, and those only say that the server there accepts email for the domain listed. A system administrator can set up any number of systems to send mail for their domain and doesn't have to list them at all in DNS. There are other mechanisms that are supposed to verify what servers send mail for a domain, such as SPF records. However, their implementation is spotty at best. Russell Johnson r...@dimstar.net ___ PLUG mailing list PLUG@lists.pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] Why some sites no PTR record???
:~$ dig ebay.com mx ; <<>> DiG 9.7.2-P2 <<>> ebay.com mx ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16443 ;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;ebay.com. IN MX ;; ANSWER SECTION: ebay.com. 3311IN MX 10 lore.ebay.com. ebay.com. 3311IN MX 10 data.ebay.com. ebay.com. 3311IN MX 10 gort.ebay.com. On Tue, Aug 16, 2011 at 11:09 PM, Michael C. Robinson < plu...@robinson-west.com> wrote: > Ebay, St Helens Community Federal Credit Union, ... > > Question I have, why aren't these email sources reverse resolvable? > > *:~$ dig ebay.com mx* > > ; <<>> DiG 9.7.2-P2 <<>> ebay.com mx > ;; global options: +cmd > ;; Got answer: > ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16443 > ;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0 > > ;; QUESTION SECTION: > ;ebay.com. IN MX > > ;; ANSWER SECTION: > *ebay.com. 3311IN MX 10 lore.ebay.com.* > *ebay.com. 3311IN MX 10 data.ebay.com.* > *ebay.com. 3311IN MX 10 gort.ebay.com.* > *:~$ dig 10 lore.ebay.com.* ; <<>> DiG 9.7.2-P2 <<>> 10 lore.ebay.com. ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 14750 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;10.IN A *;; ANSWER SECTION:* *10. 0 IN A 208.68.143.50* ;; Query time: 19 msec ;; SERVER: 68.87.69.150#53(68.87.69.150) ;; WHEN: Wed Aug 17 02:04:54 2011 ;; MSG SIZE rcvd: 36 Also, what about checking SPF records? This is a common tactic of many a spam filter. http://www.mxtoolbox.com/spf.aspx ___ PLUG mailing list PLUG@lists.pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
[PLUG] Can I modify email headers with Perl script...
Apparently I'm not supposed to reject email when there is no reverse PTR record. Can I have my Perl script add a line to the email headers that says essentially, reverse resolution failed? I'm using iptables QUEUE on SMTP connection packets. What I'm asking is, what is the extent of what I have to work with? If I have headers, how do I access them to change them? I know I can grab the destination and source IP addresses, but do I have email headers yet? Maybe I should just query a list of IP's which don't reverse resolve that I should relay, a white list. Is there a Perl module that will allow me to query DNS blacklist servers? If so, what is the module called and which DNS blacklist server do I want to query? ___ PLUG mailing list PLUG@lists.pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug