Rss

  • youtube
  • linkedin
  • google

Correcting modules not loaded error on Centos 6. x

A common problem after upgrading a kernel via yum on Centos is not creating the new kernel modules.
An example of this error happens when you try to use grep as in the print below.


# iptables-L-n | grep "my ip"
FATAL: Could not load/lib/modules/2.6.32-042stab123.9/modules.dep: No such file or directory


#
This indicates that the directory 2.6.32-042stab 123.9 and therefore any module in your content can be loaded.

To correct this problem, the simplest way is this recipe:


# mkdir -p /lib/modules/uname -r


# cd /lib/modules/uname -r
[root@vps3 2.6.32-042stab123.9]# depmod
[root@vps3 2.6.32-042stab123.9]# ls -lah
total 64K
drwxr-xr-x 2 root root 4.0K Oct 18 16:11 .
dr-xr-xr-x 10 root root 4.0K Oct 18 16:11 ..
-rw-r--r-- 1 root root 45 Oct 18 16:11 modules.alias
-rw-r--r-- 1 root root 12 Oct 18 16:11 modules.alias.bin
-rw-r--r-- 1 root root 69 Oct 18 16:11 modules.ccwmap
-rw-r--r-- 1 root root 0 Oct 18 16:11 modules.dep
-rw-r--r-- 1 root root 12 Oct 18 16:11 modules.dep.bin
-rw-r--r-- 1 root root 73 Oct 18 16:11 modules.ieee1394map
-rw-r--r-- 1 root root 141 Oct 18 16:11 modules.inputmap
-rw-r--r-- 1 root root 81 Oct 18 16:11 modules.isapnpmap
-rw-r--r-- 1 root root 74 Oct 18 16:11 modules.ofmap
-rw-r--r-- 1 root root 99 Oct 18 16:11 modules.pcimap
-rw-r--r-- 1 root root 43 Oct 18 16:11 modules.seriomap
-rw-r--r-- 1 root root 131 Oct 18 16:11 modules.softdep
-rw-r--r-- 1 root root 49 Oct 18 16:11 modules.symbols
-rw-r--r-- 1 root root 12 Oct 18 16:11 modules.symbols.bin
-rw-r--r-- 1 root root 189 Oct 18 16:11 modules. usbmap
[root@vps3 2.6.32-042stab123.9]# iptables-L-n | grep "my ip"
[root@vps3 2.6.32-042stab123.9]#
This will create the directory and dependencies to modules for the kernel currently in use (uname -r).

If the problem is not resolved with the above commands. Try to reinstall the kernel via yum with the commands below.

mv /boot/grub/grub.conf /boot/grub/grub.conf.bak yum -y reinstall kernel

And then try the commands listed earlier.

I hope you find it useful both when it was for me.

Samsung USB Drivers for Mobile Phones

I advise you read the whole page before download.

This page is actually a kind of backup of the files that I need. To avoid becoming a searching and seeing hundreds of pages full of advertising available here for my own use and thus is available for you also.

The Samsung drivers that allow

Continue Reading >>

How to retrieve a cell phone Samsung Galaxy using the hardware-download mode

I play enough with cell phones. Currently I'm investing in equipment to do more than open an iPhone to replace battery or set Touch + Screen.

Had it in my hands not long ago a cell phone Samsung Galaxy Ace model GT-S5830C. I played a lot with him flashing ROMs and I taught my teenage son to do the basics and the phone ended up with him.

One day he came to tell me that there was flashed a wrong in the device ROM

Continue Reading >>

Using Notepad++ to remove accents

Today I share a tip to facilitate the replacement of accented characters using only Notepad++ and your HTML Tag Plugin.

Let’s do it!

First of all, we must have HTML Tag Plugin installed. If you already have it, jump to step 4.

  1. Open Notepad++ and look for Plugins in Main Menu.
    Notepad Plugins Menu Item
  1. If HTML Tag is absent, open Plugin Manager->Show Plugin Manager and find HTML Tag Plugin on the list.
    HTML Tag Plugin on Notepad++ Plugin Manager
  2. Select the desired Plugins and hit Install button. Notepadd++ will restart to complete the install.
    Now we can translate special characters to yours HTML entities. We need to do it first to remove accents from our text.
  3. Put your text on the window and make Select All with Ctrl + A or Edit -> Select All in Main Menu.
  4. Open Plugins->HTML Tag->Encode Entities in Main Menu or CTRL + E.
    Now, all special characters will be in html entities.
    Notepad++ With Special Characters Encoded in HTML
  5. Open the Replace Form (CTRL + H or Search->Replace) and fill the Find What field with
    &([a-zA-Z])(grave|acute|circ|uml|aring|cedil|slash|tilde); and Replace with field with

    $1

    Select Regular Expression in Search Mode and hit Replace All button.
    Notepad++ Replace Form
    The text will be replaced with no accents characters, but all other special chars will be in HTML entity.
    Notepad++ HTML replaced text

  6. Now we can return all other chars to your originals but is better to use your text in UTF-8 encoding. Go to Encoding Menu and change text encoding if is not Utf-8. You can return to another encoding after this step.
    To decode HTML use CTRL + Shift + E or Plugins->HTML Tag->Decode Entities.
    Notepad++ Final Text convertion

I Hope that help someone.

Relembrando o passado…

Mexendo nos meus arquivos pessoais encontrei esta mensagem que escrevi logo após o término das eleições presidenciais de 2014. Não sei porque não estava publicada no meu blog pessoal, mas lembro de ter publicado no Facebook. Como quase não estou mais usando Facebook vou [re]publicar o texto na íntegra.

Principais Candidatos Eleições 2014

Principais Candidatos Eleições 2014

 

Acho engraçado que algumas pessoas usem o Facebook para tentar me convencer de alguma coisa subjetiva como se ela fosse bem mais esperta que os outros (e que eu, já que isso aqui “lemos” sozinho e não em grupo) e não aceitam discordâncias. Alguns, após 2 ou 3 comentários contrários apelam para “ESSA CONTA DE FB é MINHA, POSTO O QUE EU QUISER”.
Será que nunca entenderam o que quer dizer “COPO MEIO CHEIO OU MEIO VAZIO?”
Tudo que é subjetivo costuma não ter escolha certa ou errada. Se uma coisa ou situação tem fatos comprobatórios, já não é mais subjetivo, é concreto e nesse caso é questão de aceitar ou não, como uma demissão que você não imaginava ou seu time que está bem, perder do lanterna. O que é subjetivo é alcançado a conclusão mediante experiência pessoal e estado de espírito.
Talvez porque eu “quase” nunca tente convencer ninguém de que estou certo e me abro a discussão para que argumente seu ponto de vista, fico indignado quando vejo intolerantes, preconceituosos, arrogantes e inflexíveis disseminando sua inteligência superior.
Antes de tentar convencer alguém com argumentos tirados de capas de revistas, títulos de artigos ou vídeos de usuários do facebook a qual a conta nunca é confirmada, dê-se trabalho ao menos de ler esses conteúdos sob um prisma crítico. As pessoas para quem você vai se dirigir podem ser aquelas que leem 20 livros por ano, diversos jornais nacionais e internacionais em português ou outro[s] idioma[s] e podem derrubar seus argumentos em poucos segundos se você não estiver embasado em algo concreto.
Estou escrevendo isso pensando nas mensagens sobre divisão do país divulgadas principalmente por paulistas. Quando vêem torcedores do Rio Grande do Sul cantarem o hino do RS sobre o hino nacional em algum evento acham absurdo. Pregam união, e repudiam as atitudes separatistas, mas quando uma grande parte do país não segue sua ideologia política a primeira coisa que começa a defender é algo que repudia nos outros.

Reprodução da postagem do deputado eleito Coronel Telhada (PSDB) que gerou polêmica

Reprodução da postagem do deputado eleito Coronel Telhada (PSDB) que gerou polêmica

Essa indignação seletiva paulista é nojenta, atrasada e maléfica.
Aconselho a você que se deu ao trabalho de ler até aqui e se irritou com minhas palavras a ler Vidas Secas, Grande Sertão Veredas e ouvir histórias do Suassuna. Vai se tornar uma pessoa bem melhor.

How to clear deferred messages from Postfix Queue

Today I was watching the log file from Postfix (in CentOS 6.X default is /var/log/maillog) and saw a lot of messages being deferred.

Jan 5 15:02:03 vps3 postfix/smtp[27441]: 3187E2180015: to=<undesired@domain.com>, relay=domain.com[167.114.XXX.XXX]:25, delay=254553, delays=254538/0.2/15/0, dsn=
4.4.2, status=deferred (conversation with domain.com[167.114.XXX.XXX] timed out while receiving the initial server greeting)
Jan 5 15:02:03 vps3 postfix/smtp[27442]: CDED02180014: to=<undesired@domain.com.br>, relay=domain.com[167.114.XXX.XXX]:25, delay=258753, delays=258738/0.13/15/0, dsn
=4.4.2, status=deferred (conversation with domain.com[167.114.XXX.XXX] timed out while receiving the initial server greeting)
Jan 5 15:02:03 vps3 postfix/smtp[27443]: C8EE72180012: to=<undesired@domain.com.br>, relay=domain.com[167.114.XXX.XXX]:25, delay=258753, delays=258738/0.14/15/0, dsn
=4.4.2, status=deferred (conversation with domain.com[167.114.XXX.XXX] timed out while receiving the initial server greeting)
Jan 5 15:02:03 vps3 postfix/smtp[27444]: CDCE32180013: to=<undesired@domain.com.br>, relay=domain.com[167.114.XXX.XXX]:25, delay=258753, delays=258738/0.15/15/0, dsn
=4.4.2, status=deferred (conversation with domain.com[167.114.XXX.XXX] timed out while receiving the initial server greeting)

and these messages did repeat from time to time.

Continue Reading >>

Naming files using list from 0 to Z

Today I was coding some scripts and found a little trouble to use a defined pattern.

The pattern is to create files where the sequence starts in 0 (zero) and cannot be repeated until Z.

Example:

myfile0.ext, myfile1.ext, myfile2.ext, (...), myfile9.ext, myfileA.ext, myfileB.txt, (...), myfileZ.txt

Well, this is not a big trouble so I did use this code.

// Filename
$seq = $last_used_seq = '';
$seqs = array_merge(range('0','9'), range('A', 'Z'));]
$l = 1;
while (!in_array($seq, $seqs)) {
    $seq = chr(ord($last_used_seq) + $l++);
}

But

$seq

did not gave the expected value of 0 (zero) on first run. Instead, it was blank.

Debugging the variables, I saw that the while never evaluates to true. Attempting to reproduce on command line I saw that

in_array($seq, $seqs);

always return true. I tryed to use “”, “R” and no matter what value I used, still returning true.

So I change to use STRICT argument for in_array to true and works for ‘A’ through ‘Z’, but not for ‘0’ through ‘9’.

while (!in_array($seq, $seqs, true)) {
    $seq = chr(ord($last_used_seq) + $l++);
}

Damn… PHP is right, “0” is not strictly equals to 0. The Chr function return string and

range('0', '9')

creates an array with integer values.

So, I changed the approach to evaluate all values with STRICT, because I would like to create a nice and clean code without no other functions to be used.

This is the final code that I’m using:

// Initial values 
$seq = '';
$seqs = array_merge(range(ord('0'),ord('9')), range(ord('A'), ord('Z')));
$seqs = array_map('chr', $seqs);
$l = 1;
while (!in_array($seq, $seqs, true)) {
    $seq = chr(ord($infos['last_seq']) + $l++);
}

// Filenames
foreach ($itens_for_files as $key => $itens) {
    // ... Another codes to fill file    
    $seq = chr(ord($seq) + 1);
    while (!in_array($seq, $seqs, true)) {
    $seq = chr(ord($seq) + 1);
    $filename = 'myfile' . $seq . '.ext';
    // ...
}

How you can see, I changed the $seqs initial values from ‘0’ to your ASCII code and get back to your value that gave me an array with all values in string type.

See you!

PHP Comparison Error

Today, I was writing a script in PHP to be used in the command line when I came across unexpected behavior (at least on my part).
The script should receive three arguments, the last of them a list containing one or more numeric codes.
Trying to validate this last argument was getting a different result than imagined.
See the code snippet that I was using:

// test.php
if (php_sapi_name() == 'cli') {
    $di = isset($argv[1]) ? $argv[1] : date('Y-m-d'); // Initial Date
    $df = isset($argv[2]) ? $argv[2] : date('Y-m-d'); // Final Date
    $prods = isset($argv[3]) ? explode(',', $argv[3]) : array(); // Code List

    ##### Validating
    // Initial Date
    if ($di != date('Y-m-d', strtotime($di))) {
        echo "\n";
        echo "ERROR! Invalid INITIAL DATE!\n";
        exit;
    }
    // Final Date
    if ($df != date('Y-m-d', strtotime($df))) {
        echo "\n";
        echo "ERRO! Invalid FINAL DATE!\n";
        exit;    
    }

    // Codes
    if (count($prods) > 0) {
        foreach ($prods as $prod) {
            if ($prod != (int)$prod) {
                echo "\n";
                echo "ERROR! The CODE " . $prod . " is invalid!\n" ;
                exit;
            }
        }
    }
    echo "DONE!";
}

Continue Reading >>

Como corrigir Data/hora no Centos 6.X para seu timezone inclusive nos logs

Hoje eu me deparei com um problema ao utilizar o Fail2ban que me ajuda demais a manter o servidor no ar mesmo sob ataques de brute-force.

Um dos meus filtros não estavam barrando as diversas tentativas de autenticação em um dos meus serviços embora estivesse tudo certo. Resolvi aumentar o tempo de Findtime na configuração comum e ele começou a barrar.

Então era hora de entender porque com um findtime baixo ele não conseguia barrar. Comecei a checar detalhadamente as configurações e percebi que mesmo tendo alterado a hora para meu timezone para o horario oficial de Brasilia, os logs continuavam a exibir o horario em UTC. Desconfiei que pudesse ser isso e resolvi alterar o horário que é colocado nos logs (/var/log/messages).

Bingo!

Após a alteração e confirmar que os logs estavam usando o mesmo horario que o reportado em

date 

mudei o findtime para os valores que desejava e tudo funcionou como esperado.

Segue a receita para alterar o horario.

As informações de Timezone ficam no arquivo /etc/localtime e caso ele não esteja no que você quer basta substitui-lo pelo que deseja e que esteja presente em /usr/share/zoneinfo/. No meu caso, como queria o horario de Brasília, utilizei /usr/share/zoneinfo/America/Sao_Paulo.

# ln -sf /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime

Agora é só testar usando o comando date e verificar a saída que deverá ser algo como:

# date
Wed Dec 9 15:55:58 BRST 2015

Mesmo após essas mudanças, os logs continuarão a terem o horário da forma antiga. Para alterar isso edite o arquivo /etc/sysconfig/clock e adicione as linhas abaixo para refletir também o seu timezone.

ZONE="America/Sao_Paulo"
UTC=false
ARC=false

No meu caso, precisei reiniciar o servidor para que as alterações surtissem efeito mas pode ser que apenas reiniciando o serviço rsyslog já resolva.

# service rsyslog restart

Até a próxima.

Como corrigir erro de LOCALE no Linux Debian/Ubuntu

Hoje precisei olhar os logs de um servidor FTP que roda sob o pure-ftp e percebi que os horários estavam todos em UTC .
Como eu precisava enviar parte dos logs a um terceiro que faz uso dele e não está familiarizado com sistemas, poderia acabar ocorrendo algum mal entendido. Resolvi então que deveria manter os logs de todas as aplicações no fuso horário brasileiro.
De acordo com a documentação do pure-ftp ele utiliza as variáveis de ambiente para determinar qual será o horário incluído nos logs

Continue Reading >>