25 oct 2010

mounting /usr read-only

Luego de actualizar paquetes puede suceder que obtengamos el siguiente error al intentar montar nuevamente la partición /usr como read only.

mount: /usr is busy

mount: /usr está ocupado
E: Problem executing scripts DPkg::Post-Invoke 'mount /usr -o remount,ro'
E: Sub-process returned an error code


Para liberar los archivos modificados que impiden que remontemos como solo lectura, debemos reiniciar todos los procesos que los estén utilizando. Para ello podemos listarlos haciendo:

lsof -a +L /usr | grep -v " [[:digit:]] "

COMMAND PID USER FD TYPE DEVICE SIZE NLINK NODE NAME
vmtoolsd 2454 root mem REG 8,49 245811 /usr/lib/gconv/gconv-modules.cache (path inode=246019)
cron 3109 root mem REG 8,49 245811 /usr/lib/gconv/gconv-modules.cache (path inode=246019)
cron 3109 root DEL REG 8,49 245819 /usr/lib/locale/locale-archive
bash 24051 xxxx mem REG 8,49 245811 /usr/lib/gconv/gconv-modules.cache (path inode=246019)
bash 24051 xxxx DEL REG 8,49 245819 /usr/lib/locale/locale-archive
su 24073 root mem REG 8,49 245811 /usr/lib/gconv/gconv-modules.cache (path inode=246019)
su 24073 root DEL REG 8,49 245819 /usr/lib/locale/locale-archive
bash 24074 root mem REG 8,49 245811 /usr/lib/gconv/gconv-modules.cache (path inode=246019)
bash 24074 root DEL REG 8,49 245819 /usr/lib/locale/locale-archive

16 oct 2009

Cambio de hora suspendido

Como sabrán, quedó suspendido el cambio horario que se iba a realizar este fin de semana.

Para las distribuciones Debian/Ubutu aún no hay actualización del paquete tzdata.

Para ver cuales son los cambios programados ejecutar el siguiente comando:


zdump /etc/localtime -v

...

/etc/localtime Sun Mar 16 01:59:59 2008 UTC = Sat Mar 15 23:59:59 2008 ARST isdst=1 gmtoff=-7200
/etc/localtime Sun Mar 16 02:00:00 2008 UTC = Sat Mar 15 23:00:00 2008 ART isdst=0 gmtoff=-10800
/etc/localtime Sun Oct 19 02:59:59 2008 UTC = Sat Oct 18 23:59:59 2008 ART isdst=0 gmtoff=-10800
/etc/localtime Sun Oct 19 03:00:00 2008 UTC = Sun Oct 19 01:00:00 2008 ARST isdst=1 gmtoff=-7200
/etc/localtime Sun Mar 15 01:59:59 2009 UTC = Sat Mar 14 23:59:59 2009 ARST isdst=1 gmtoff=-7200
/etc/localtime Sun Mar 15 02:00:00 2009 UTC = Sat Mar 14 23:00:00 2009 ART isdst=0 gmtoff=-10800
/etc/localtime Sun Mar 21 01:59:59 2010 UTC = Sat Mar 20 23:59:59 2010 ARST isdst=1 gmtoff=-7200
/etc/localtime Sun Mar 21 02:00:00 2010 UTC = Sat Mar 20 23:00:00 2010 ART isdst=0 gmtoff=-10800
/etc/localtime Sun Oct 17 02:59:59 2010 UTC = Sat Oct 16 23:59:59 2010 ART isdst=0 gmtoff=-10800
/etc/localtime Sun Oct 17 03:00:00 2010 UTC = Sun Oct 17 01:00:00 2010 ARST isdst=1 gmtoff=-7200
...
/etc/localtime Sun Oct 18 02:59:59 2037 UTC = Sat Oct 17 23:59:59 2037 ART isdst=0 gmtoff=-10800
/etc/localtime Sun Oct 18 03:00:00 2037 UTC = Sun Oct 18 01:00:00 2037 ARST isdst=1 gmtoff=-7200
/etc/localtime Mon Jan 18 03:14:07 2038 UTC = Mon Jan 18 01:14:07 2038 ARST isdst=1 gmtoff=-7200
/etc/localtime Tue Jan 19 03:14:07 2038 UTC = Tue Jan 19 01:14:07 2038 ARST isdst=1 gmtoff=-7200


Para evitar el cambio que ya está programado hay que modificar el archivo correspondiente a Sudamérica (en el source de tzdata) y compilarlo.

Esto es lo que hay que modificar:

diff southamerica southamerica.nuevo

217,218c217,218
< Rule Arg 2008 2009 - Mar Sun>=15 0:00 0 -
< Rule Arg 2008 only - Oct Sun>=15 0:00 1:00 S
---
> Rule Arg 2008 max - Mar Sun>=15 0:00 0 -
> Rule Arg 2008 max - Oct Sun>=15 0:00 1:00 S



Luego de esto compilar:

zic -l /usr/share/zoneinfo/America/Argentina/Buenos_Aires southamerica.nuevo


Para ver cuales son los cambios programados luego de la modificación ejecutar nuevamente:

zdump /etc/localtime -v
...
/etc/localtime Sun Mar 16 01:59:59 2008 UTC = Sat Mar 15 23:59:59 2008 ARST isdst=1 gmtoff=-7200
/etc/localtime Sun Mar 16 02:00:00 2008 UTC = Sat Mar 15 23:00:00 2008 ART isdst=0 gmtoff=-10800
/etc/localtime Sun Oct 19 02:59:59 2008 UTC = Sat Oct 18 23:59:59 2008 ART isdst=0 gmtoff=-10800
/etc/localtime Sun Oct 19 03:00:00 2008 UTC = Sun Oct 19 01:00:00 2008 ARST isdst=1 gmtoff=-7200
/etc/localtime Sun Mar 15 01:59:59 2009 UTC = Sat Mar 14 23:59:59 2009 ARST isdst=1 gmtoff=-7200
/etc/localtime Sun Mar 15 02:00:00 2009 UTC = Sat Mar 14 23:00:00 2009 ART isdst=0 gmtoff=-10800

28 ago 2009

Preferencias de usuario en mysql para cuentas con alias

En el caso de tener varias cuentas redireccionadas o que sean alias de otra cuenta, podemos evitar cargar preferencias personales para cada una de ellas, ahorrando trabajando principalmente si tenemos alguna automatización que maneje black/whitelist personalizadas.

Si tuviésemos un encadenamiento de alias o redirecciones, el ahorro sería aún mayor. Por ejemplo:

account_3 es un alias de account_2, esta a su ves está redireccionada a account_1

Si account_1 ya tiene cargadas sus preferencias, al ser procesado un mail para cualquiera de las otras dos cuentas, estas preferencias no son tomadas en cuenta por SpamAssassin. Si agregamos la nueva preference ' alias_of ' a las cuentas account_2 y account_3, esta puede ser interpretada por un el procedure ' users_pref ' que le devolverá a SpamAssassin las preferencias de la cuenta en cuestión más las de la cuenta que le hayamos indicado.

username preference value

account_3 alias_of account_2
... ...
account_2 alias_of account_1
... ...
account_1 required_score 5.5
blaclist_from spam@spam.spam
... ...


En este caso hay un encadenamiento de 3 cuentas pero el número puede variar y el limite de recursión se puede establecer en user_scores_sql_custom_quer para evitar loops infinitos con cuentas que se definan como alias mutuamente.

local.cf


user_scores_sql_custom_query CALL spamassassin.users_pref(_USERNAME_ , _DOMAIN_ , 3)



Procedure users_pref


PROCEDURE `users_pref`(
IN `SPusername` varchar(128),
IN `SPdomain` varchar(68),
IN `SPdep` integer
)
BEGIN


IF (`SPdomain` <> 'noDomain' OR `SPdomain` is NULL ) THEN

SET max_sp_recursion_depth=`SPdep`;

create temporary table if not exists MyArray (
`prefid` integer,
`username` varchar(128),
`preference` varchar(64),
`value` varchar(128)
) engine = MEMORY;

END IF;

INSERT INTO MyArray (SELECT prefid, username, preference, value
FROM spamassassin.userpref
WHERE username = `SPusername`
OR (username = '@GLOBAL' AND `SPdomain` <> 'noDomain' )
OR username = CONCAT('@',`SPdomain`)
);

IF (EXISTS (SELECT value as `username`
FROM `spamassassin`.`userpref`
WHERE `username` = `SPusername`
and preference = 'alias_of')
AND `SPdep` > 0 )THEN

CALL spamassassin.users_pref((SELECT value as `username`
FROM `spamassassin`.`userpref`
WHERE `username` = `SPusername`
and preference = 'alias_of'),'noDomain',`SPdep`-1
);
ELSE

Select preference, value from MyArray
WHERE preference <> 'alias_of'
ORDER BY username DESC, prefid asc;

END IF ;

END $$



Tabla userpref


CREATE TABLE `spamassassin`.`userpref` (
`prefid` int(8) unsigned NOT NULL auto_increment,
`username` varchar(128) NOT NULL default '',
`preference` varchar(64) NOT NULL default '',
`value` varchar(128) default NULL,
`descript` varchar(128) default NULL,
`added` datetime NOT NULL default '2003-01-01 00:00:00',
`added_by` varchar(128) NOT NULL default '',
`modified` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
UNIQUE KEY `prefid` USING BTREE (`prefid`),
KEY `type` (`preference`),
KEY `added_by` (`added_by`),
KEY `preference` (`preference`),
KEY `username` (`username`)
) ENGINE=MyISAM AUTO_INCREMENT=1037 DEFAULT CHARSET=latin1 COMMENT='Spamassassin Preferences';


UsingSQL

http://wiki.apache.org/spamassassin/UsingSQL

WebUserPrefs by patrickbores

http://sourceforge.net/projects/webuserprefs/

6 ago 2009

Policyc:


Policyc trabaja en forma similar a un proxy para Postfix policy delegation protocol. En este caso ajustado para el funcionamiento de Policyd

master.cf

#################### Policyc #######################
#
policyc unix    -    n    n    -    150    spawn
        user=filter argv=/path/to/policyc.pl
#


main.cf

policyc_time_limit = 3600

...

smtpd_recipient_restrictions =
        check_policy_service unix:private/policyc,
        ...

...

smtpd_end_of_data_restrictions =
        check_policy_service unix:private/policyc,
        ...

Policyc.pl

http://mail.utn.edu.ar/spamassassin/policyc.pl



Santiago Liz

3 jul 2009

Error Plugin DKIM Reputation - SpamAssassin

Descarga original de http://www.dkim-reputation.org:


Mail-SpamAssassin-3.2.5-DKIM-Reputation-Plugin-V3.tgz

Error:

Use of uninitialized value in numeric eq (==) at /usr/share/perl5/Mail/SpamAssassin/Plugin/AWL.pm line 342.
Use of uninitialized value in numeric eq (==) at /usr/share/perl5/Mail/SpamAssassin/PerMsgStatus.pm line 365.


spamd[8001]: spamd: connection from 172.16.1.20 [172.16.1.20] at port 33783
spamd[8001]: spamd: processing message <4B.8C.18013.1D90F5A4@xxx> for xxxx@xxx.xxx.xxx.xx:1000
spamd[8001]: DKIMRep: id=mensajes3$iglesia, aweber.com$presenciadedios.com, aweber.com sel=dkim_s1024 rep=403.2 info=bad
spamd[8001]: Use of uninitialized value in numeric eq (==) at /usr/share/perl5/Mail/SpamAssassin/Plugin/AWL.pm line 342.
spamd[8001]: Use of uninitialized value in numeric eq (==) at /usr/share/perl5/Mail/SpamAssassin/PerMsgStatus.pm line 365.
spamd[8001]: spamd: clean message (5.0/5.5) for xxxx@xxx.xxx.xxx.xx:1000 in 6.2 seconds, 48831 bytes.
spamd[8001]: spamd: result: . 4 -AWL,BAYES_50,DKIMREP,DKIM_SIGNED,DKIM_VERIFIED,DOMAINKEY_DOMAIN,FUZZY_AMBIEN,HS_INDEX_PARAM,HTML_MESSAGE,RCVD_IN_JMF_W,SPF_HELO_PASS,SPF_PASS scantime=6.2,size=48831,user=xxxxx@xxx.xxx.xxx.xx,uid=1000,required_score=5.5,rhost=172.16.1.20,raddr=172.16.1.20,rport=33783,mid=<4B.8C.18013.1D90F5A4@xxx>,bayes=0.500000,autolearn=ham


Solución:



diff DKIM.pm DKIM.pm.ori
1135,1139d1134
< for my $set (0..3) {
< $permsgstatus->{conf}->{scoreset}->[$set]->{"DKIMREP"} =
< sprintf("%0.3f", $score);
< }
<

http://mail.utn.edu.ar/spamassassin/DKIM.pm

Plugin-Writing Tips


http://wiki.apache.org/spamassassin/PluginWritingTips