Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Page 3 of 3 FirstFirst 1 2 3
Results 31 to 42 of 42
  1. #31
    Member
    Join Date
    Jan 2007
    Posts
    113

    Default

    One suggestion would be to see why the file can't be opened. You could change line 9 so it looks like this:

    Code:
    open (OUT, '>', '/etc/valiases/$file') or die "$!";

  2. #32
    Member
    Join Date
    Mar 2002
    Posts
    175

    Default

    Quote Originally Posted by clbrack1 View Post
    I am running Chirpy's script and I am getting output stating it dies at line 9.

    Line 9 is:

    open (OUT, ">/etc/valiases/$file") or die;

    It appears the first few domains might be getting changed to fail.

    I also tried the modified version of the script that is at the end of this thread and receive the same error message.

    Appreciate any thoughts.

    Chris
    If your like me, you had a couple of accounts getting utterly hammered with dictionary attacks and set the immutable bit on the persons file so theyt couldn't reset the domain back to having a catch all address. Try checking for an "i" with the list attributes command.
    # lsattr

  3. #33
    Registered User
    Join Date
    Mar 2004
    Posts
    24

    Default

    Quote Originally Posted by chirpy View Post
    I just posted this to a thread and thought I'd make it available to anyone who wants to run it on their servers. It changes all Default Addresses (i.e. catchall aliases) for all domains on the server to :fail:

    Code:
    #!/usr/bin/perl
    print "Converting all domain Default Accounts to :fail: ...";
    opendir (DIR, "/etc/valiases/") or die;
    while (my $file = readdir (DIR)) {
    	if ($file =~ /^\./) {next}
    	open (IN, "</etc/valiases/$file") or die;
    	my @data = <IN>;
    	close (IN);
    	open (OUT, ">/etc/valiases/$file") or die;
    	foreach my $line (@data) {
    		if ($line =~ /^\*\:/) {
    			print OUT "*: :fail:\n";
    		} else {
    			print OUT $line;
    		}
    	}
    	close (OUT);
    }
    print "Done!\n";
    Use at your own risk. That means, backup /etc/valiases before running it
    great script...thanks to this i can sleep tonight with a light server load, thank you!!

  4. #34
    Member
    Join Date
    May 2008
    Posts
    1,114

    Default

    Thanks for sharing such a useful script among us!

  5. #35
    Member
    Join Date
    Nov 2007
    Posts
    861

    Arrow

    Quote Originally Posted by chirpy View Post
    I just posted this to a thread and thought I'd make it available to anyone who wants to run it on their servers. It changes all Default Addresses (i.e. catchall aliases) for all domains on the server to :fail:

    Code:
    #!/usr/bin/perl
    print "Converting all domain Default Accounts to :fail: ...";
    opendir (DIR, "/etc/valiases/") or die;
    while (my $file = readdir (DIR)) {
    	if ($file =~ /^\./) {next}
    	open (IN, "</etc/valiases/$file") or die;
    	my @data = <IN>;
    	close (IN);
    	open (OUT, ">/etc/valiases/$file") or die;
    	foreach my $line (@data) {
    		if ($line =~ /^\*\:/) {
    			print OUT "*: :fail:\n";
    		} else {
    			print OUT $line;
    		}
    	}
    	close (OUT);
    }
    print "Done!\n";
    Use at your own risk. That means, backup /etc/valiases before running it
    few questions regarding this

    1. how do i take of /etc/valiases (as i m not master of SSH)

    2. where do i edit this code & how to run this script (give example)

  6. #36
    Member
    Join Date
    Jan 2004
    Posts
    755

    Default

    Quote Originally Posted by nileshparmar View Post
    few questions regarding this

    1. how do i take of /etc/valiases (as i m not master of SSH)

    2. where do i edit this code & how to run this script (give example)
    If you're not sure of how to do either of those yet, you probably shouldn't be messing with them... especially on a production box.

  7. #37
    Member
    Join Date
    Nov 2007
    Posts
    861

    Arrow

    Quote Originally Posted by Lyttek View Post
    If you're not sure of how to do either of those yet, you probably shouldn't be messing with them... especially on a production box.
    if anyone can guide my by step by step i can do the same without any trouble

    as i have done lot of from this forum

    That's why i m telling this

  8. #38
    Member
    Join Date
    Jan 2004
    Posts
    755

    Default

    Ok, fine...

    My point there was this:

    if anyone can guide my by step by step i can do the same without any trouble
    When it comes to something as basic as making a copy of something, if you're not sure how to do that, and you mess something up, how are you going to fix it?

    So, copy the directory:
    Code:
    cp -R /etc/valiases /etc/valiases.backup
    As for the script, we'll create the file and open it in one step

    Code:
    nano -w /def2fail.sh
    Then paste or type the script into that file, press ctrl-x to save it then:

    Code:
    chmod +x /def2fail.sh
    /def2fail.sh
    That makes the script executable, then executes it.

  9. #39
    Member
    Join Date
    Nov 2007
    Posts
    861

    Arrow

    Quote Originally Posted by Lyttek View Post
    Ok, fine...

    My point there was this:



    When it comes to something as basic as making a copy of something, if you're not sure how to do that, and you mess something up, how are you going to fix it?

    So, copy the directory:
    Code:
    cp -R /etc/valiases /etc/valiases.backup
    As for the script, we'll create the file and open it in one step

    Code:
    nano -w /def2fail.sh
    Then paste or type the script into that file, press ctrl-x to save it then:

    Code:
    chmod +x /def2fail.sh
    /def2fail.sh
    That makes the script executable, then executes it.
    That's It

    now it is so easy to do this thing

    but after make this script how to execute this ??

    Let me know below thing

    Quote Originally Posted by chirpy View Post
    Yes, bascially do this as root on the server:

    pico -w defrep.pl
    (paste in the script from the thread and exit)

    perl defrep.pl

    That should be it.
    Last edited by crazyaboutlinux; 05-26-2009 at 02:15 AM.

  10. #40
    Member
    Join Date
    Jan 2004
    Posts
    755

    Default

    Whoops... ya... missed that it was a perl script, so those instructions are correct...

    pico -w defrep.pl
    (paste in the script from the thread and exit)

    perl defrep.pl

    That should be it.
    the 'pico' line is the same basic thing as the 'nano' statement, while 'perl defrep.pl' is the command that executes it...

    Sorry for the confusion there...

  11. #41
    Member
    Join Date
    Jun 2009
    Posts
    32

    Default

    Your topic was helped me a lot, thanks!

  12. #42
    Member
    Join Date
    Oct 2003
    Posts
    103

    Default

    chirpy, thank you a gazillion for saving me hours of work!

    Keep up the great job, and thanks for sharing.

Similar Threads & Tags
Similar threads

  1. Replies: 1
    Last Post: 03-30-2008, 10:37 PM
  2. :fail: does not work to stop spoofed returned addresses
    By jackie46 in forum cPanel and WHM Discussions
    Replies: 17
    Last Post: 10-04-2006, 08:14 AM
  3. Mail > Default addresses
    By MacZilla in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 07-09-2004, 07:21 AM
  4. :fail: by default?
    By ckacerguis in forum cPanel and WHM Discussions
    Replies: 7
    Last Post: 03-10-2004, 02:51 PM
  5. Where are default Mail Addresses kept?
    By silentcircuit in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 07-09-2003, 07:28 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube