Sep 15

Hi,

Today I’m going to show you a very small script that allows you to convert any video (as long as it is supported by mplayer) to a GIF.

Required tools:

* mplayer

* convert

 

mplayer is popular media player available for multiple operating systems that support a wide range of video formats. The convert tool is an utility that lets you convert between multiple image formats among other definitions.  Since the mplayer takes screenshots using jpeg format, we need to use the convert tool to do the convertion to aGIF format.

 

Copy the following code, save it to a file and change its permissions (chmod a+x) and you are ready to roll :)

 

 

#!/bin/sh
TMPDIR=/tmp/animated
shopt -s nocaseglob
if [ ! -d "$TMPDIR" ]
then
        mkdir $TMPDIR
fi
 
\rm $TMPDIR/* &> /dev/null
 
if [ $# -lt 3 ]
then
        echo -e "Usage: $0 <start> <length> <inputfile> [<with:height>]\nExample:\n$0 00:15:11 10 myvideo.avi 320:240"
        exit 1
fi
 
if [ -n "$4" ]
then
        SCALE="scale=$4"
fi
 
echo "Generating screenshots. Please be patitent..."
mplayer -ao null -ss $1 -endpos $2 $3 -vo jpeg:outdir=$TMPDIR/ -vf $SCALE &> /dev/null
if [ -f $TMPDIR/00000001.jpg ]
then
        echo "Finished generating frames. Assembling the animated GIF..."
        convert -delay 5 $TMPDIR/*.jpg $TMPDIR/output.gif
        echo "Done! Please check the $TMPDIR/output.gif"
        exit 0
else
        echo -e "Oops\! Something went wrong and the frames were not generated. Check your parameters\!"
        exit 1
fi

Just try it and let me know ;-)

Tagged with:
Aug 22

As a sysadmin, I should always search and check for errors on every machine that I manage. Unfortunately one of them has an Adaptec 5405 which I forgot to monitor using nagios and just like Murphy’s Law says – “Anything that can go wrong will go wrong” – something went wrong and I have lost information. Not a really big problem because I have backups of everything but it could have been avoided if I had monitored the status of the Adaptec just the way I do with software raid arrays (/proc/mdstat rules!).

So I developed another simple script using Perl (again :-P ) to check the status of all the available arrays.

#!/usr/bin/perl -w
use strict;
use warnings;
 
my $adaptec_tool = "/usr/src/cmdline/arcconf";
 
my $dump = `$adaptec_tool getconfig 1 ld`;
my @raids = ();
 
while ($dump =~ /Logical device name.*?:.*?([a-z0-9]+).*?raid level.*?:.*?([0-9]+).*?status of logical device.*?:.*?([a-z0-9]+)/gsi) {
        push @raids, {"name" => $1, "raidlevel" => $2, "status" => $3};
 
}
 
foreach my $raid (@raids)
{
        if ( $$raid{status} ne "Optimal" )
        {
                print "Critical: Raid not Optimal! (Array Name: $$raid{name}, Level: $$raid{raidlevel}, Status: $$raid{status})\n";
                exit(1);
        }
}
 
print "OK: All arrays in optimal shape\n";
exit (0);

You just need to download the “Adaptec Storage Manager” to connect to the RAID card and read the status. You can use this link to do it.

Tagged with:
Apr 23

This is probably a common problem among all the people trying to get audio over HDMI under Linux using an EN210 graphics card (or similar).

Even though the HDMI may appear in your available cards listed in proc (/proc/asound/cards) you will probably see that you cannot find it using the aplay utility. Just check it running the command “aplay -l”. The HDMI device isn’t listed here isn’t it?

The reason for this issue is related to the ALSA driver version 1.0.21 (or older) which is quite buggy for these graphics cards.

You can check which version you are using by executing the following command:

cat /proc/asound/version

If you get a version older than 1.0.21 then you need to upgrade it. You can check your favourite distribution’s repository for an update or you can try to compile it from source code.

If you can’t find an update, check this page: http://ubuntuforums.org/showthread.php?t=1681577

It might help you ;-)

Tagged with:
Apr 23

If you are running the latest version of Ubuntu and tried to mount a NTFS filesystem you probably already know that you can’t and maybe you have even seen an error like “mount exited with exit code 21″.

This seems to be due to a bug in libfuse2 and/or fuse-utils package. To fix this temporarly you can downgrade both packages to a prior version. libfuse2 and fuse-utils version 2.8.1-1.1ubuntu2.2 seem to be OK but 2.8.1-1.1ubuntu3.2 is useless.

Just download both packages and install them:

http://launchpadlibrarian.net/60433788/libfuse2_2.8.1-1.1ubuntu2.2_i386.deb

http://launchpadlibrarian.net/60433786/fuse-utils_2.8.1-1.1ubuntu2.2_i386.deb

Don’t forget that these are 32bit packages. If you are using 64bit OS then download the needed packages.

sudo dpkg -i libfuse2_2.8.1-1.1ubuntu2.2_i386.deb
sudo dpkg -i fuse-utils_2.8.1-1.1ubuntu2.2_i386.deb

Problem solved :-)

Tagged with:
Sep 02

After upgrading my HTPC to Ubuntu 10.04, nvidia drivers stopped working without any reason. After googling a bit, all the answers pointed to a problem related with Ubuntu upgrade system not updating restricted drivers. I have tried manually to update and use all the available versions, but without any success…until I found the cause and solution.

It happens that Ubuntu does not remove old drivers correctly, leaving you with multiple versions which were confusing the operating system. The solution was to purge the system from all nvidia drivers and reinstall just one of them.

You can run the following commands to clean the system:

sudo dpkg --get-selections | grep nvidia | grep -v deinstall | awk '{print $1}' | xargs sudo apt-get remove -y
sudo apt-get install nvidia-current
sudo nvidia-xconfig

sudo reboot

The system will then reboot and if everything is OK, Ubuntu will be as good as new.

Tagged with:
Jun 28

O port do sistema operativo Android está cada vez mais perto do HTC HD2. Depois de ultrapassados os problemas relacionados com o kernel (que aparentemente estavam relacionados com algumas instruções extra do processador) foi uma questão de dias – mais concretamente dois – até que conseguissem inicializar o Android. Nesta fase ainda há muitos drivers que não se encontram a funcionar e que fazem com que ainda seja inútil para qualquer utilizador, mas foi mais um passo na direcção certa.

Podem inclusive ver um video do processo de inicialização do sistema:

O próximo passo parece estar relacionado com os drivers do touchscreen, o famigerado ELAN B81 que mesmo após alguma insistência sobre o fabricante, este não libertou a informação necessária para ser criado o driver para linux.

Mais informações na thread oficial do port deste sistema operativo:

http://forum.xda-developers.com/showthread.php?t=651632

Tagged with:
May 04

I believe I have found a vulnerability in ClipBucket 2.0.6 (haven’t tested with prior versions).

ClipBucket is an open source and free script that will let you start your own Video Sharing (Youtube Clone) website in matter of minutes, ClipBucket is fastest growing script with most video sharing websites and social networking features.
current version: 2.0.6

Summary:
The script handling the search features is not sanitizing user input properly making it possible to produce XSS attacks.

Proof of Concept:

Use the search box of your ClipBucket 2.0.6 installation and Input:

 <script>alert(document.cookie);</script>

This will produce an alert with contents of your cookie.

Problem:
$search->key in search_result.php (line 18) is being directly assigned to the title of the search page without sanitizing its value first.

$search->key = $_GET['query'];

Workaround:
Open file search_result.php. Go to line 39:

Replace this:

Assign('search_type_title',sprintf(lang('searching_keyword_in_obj'),$search->key,$search->search_type[$type]['title']));

By this:

Assign('search_type_title',sprintf(lang('searching_keyword_in_obj'),htmlentities($search->key),$search->search_type[$type]['title']));

The ClipBucket team was already notified and the bug was corrected. Either apply this patch or upgrade your version to 2.0.7

Tagged with:
Apr 15

Estive com uns problemas na empresa relacionados com o sendmail.
Quando nada fazia prever, o sendmail simplesmente crasha começando a recusar activamente todos os pedidos de envio de email.

Criei um script genérico para verificar se uma determinada porta de um servidor está a responder. Basta editar o endereço, porta e opcionalmente definir um timeout máximo para o pedido.

#!/usr/bin/php -q
<?
 
/*****************************************************
 
    Check For Open Ports - David Gouveia
 
*****************************************************/
 
$address = '127.0.0.1';
$port = 25;
$timeout = 5;  //Max time to wait before give up.
 
$checkport = fsockopen($address, $port, $errnum, $errstr, $timeout);
 
if(!$checkport){
        print "CRITICAL: Host $address at port $port not responding!\n";
        fclose($checkport);
        exit(2);
}
 
print "OK: Host $address at port $port is responding!\n";
fclose($checkport);
exit(0);
 
?>

Coloquem na pasta dos plugins e não se esqueçam de dar as permissões correctas (755).
Alternativamente podem passar o valor do IP e porta como argumentos via consola.

basta trocar isto :

    $address = ’127.0.0.1′;
    $port = 25;

por isto :

    $address = $argv[1];
    $port = $argv[2]
Tagged with:
Apr 09

Para quem está a pensar em adquirir uma placa de rede gigabit da Asus para utilizar em sistemas operativos *nix que pense duas vezes em fazê-lo.

O chipset utilizado é o IP1000 que além de não ser suportado directamente pelo kernel e os drivers fornecidos no cd de instalação são tão antigos que é impossível compilar com um kernel relativamente recente (2.6.22 e superiores pelo menos).

Se mesmo assim vão comprar uma placa destas, usem a ultima versão dos drivers que está no site do fabricante do chipset, descomprimam para uma pasta  e executem os seguintes comandos :

make all

cp ipg.ko /lib/modules/`uname -r`/kernel/drivers/net

depmod

modprobe ipg

Podem sacar a ultima versão aqui.

Tagged with:
Mar 31

Se usam o Fedora Core 12 e tentarem compilar algum programa que use extensões fornecidas pelo OpenSSL, poderão deparar-se com erros como estes :

/usr/src/php-4.4.9/ext/openssl/openssl.c:182: error: expected specifier-qualifier-list before ‘LHASH’
/usr/src/php-4.4.9/ext/openssl/openssl.c:343: error: expected declaration specifiers or ‘…’ before ‘LHASH’
/usr/src/php-4.4.9/ext/openssl/openssl.c: In function ‘php_openssl_config_check_syntax’:
/usr/src/php-4.4.9/ext/openssl/openssl.c:348: error: ‘config’ undeclared (first use in this function)
/usr/src/php-4.4.9/ext/openssl/openssl.c:348: error: (Each undeclared identifier is reported only once
/usr/src/php-4.4.9/ext/openssl/openssl.c:348: error: for each function it appears in.)
/usr/src/php-4.4.9/ext/openssl/openssl.c: In function ‘add_oid_section’:
/usr/src/php-4.4.9/ext/openssl/openssl.c:366: error: ‘struct php_x509_request’ has no member named ‘req_config’
/usr/src/php-4.4.9/ext/openssl/openssl.c:370: error: ‘struct php_x509_request’ has no member named ‘req_config’
/usr/src/php-4.4.9/ext/openssl/openssl.c: In function ‘php_openssl_parse_config’:
/usr/src/php-4.4.9/ext/openssl/openssl.c:416: error: ‘struct php_x509_request’ has no member named ‘config_filename’
/usr/src/php-4.4.9/ext/openssl/openssl.c:416: error: ‘struct php_x509_request’ has no member named ‘config_filename’
/usr/src/php-4.4.9/ext/openssl/openssl.c:417: error: ‘struct php_x509_request’ has no member named ‘section_name’
/usr/src/php-4.4.9/ext/openssl/openssl.c:417: error: ‘struct php_x509_request’ has no member named ‘section_name’
/usr/src/php-4.4.9/ext/openssl/openssl.c:418: error: ‘struct php_x509_request’ has no member named ‘global_config’
/usr/src/php-4.4.9/ext/openssl/openssl.c:419: error: ‘struct php_x509_request’ has no member named ‘req_config’
/usr/src/php-4.4.9/ext/openssl/openssl.c:419: error: ‘struct php_x509_request’ has no member named ‘config_filename’
/usr/src/php-4.4.9/ext/openssl/openssl.c:421: error: ‘struct php_x509_request’ has no member named ‘req_config’
/usr/src/php-4.4.9/ext/openssl/openssl.c:426: error: ‘struct php_x509_request’ has no member named ‘req_config’
/usr/src/php-4.4.9/ext/openssl/openssl.c:437: error: ‘struct php_x509_request’ has no member named ‘digest_name’

No inicio pensei que pudesse estar relacionado  com o facto de estar a tentar compilar uma versão do php bastante antiga provocando alguma incompatibilidade entre com as extensões actuais, mas na verdade existem mais pessoas com o mesmo problema utilizando software mais recente.

A forma de resolver (ainda que temporariamente) o problema foi copiar as extensões de outra máquina, no meu caso um servidor com Fedora Core 9.

Para o caso de alguém precisar, ficam aqui. Basta descomprimir para o directório /usr/include/openssl.

Tagged with:
preload preload preload