quarta-feira, 28 de maio de 2008

Programas Interessantes do Ubuntu


Para quem experimenta o Ubuntu, sempre fica a dúvida de qual aplicativo usar para escutar música, ver DVD's ou queimar um CD/DVD.

Aqui vai a lista de aplicativos que eu acho essencial e que sempre irei instalar/atualizar no meu Ubuntu.

Claro que existem dezenas de outras alternativas para cada ação, mas estes aplicativos são os que melhores responderam às minhas expectativas, depois de conhecer o Ubuntu. E esta lista é dinâmica, pois sempre haverão coisas novas e melhores.

Vamos lá!


Avidemux
Editor de vídeo
download: http://www.getdeb.net/app/Avidemux
info: http://ubuntudicas.blogspot.com/2008/01/avidemux-editor-de-vdeo.html

Qdvdauthor

Aplicativo para criar dvds com suporte a subtitulos, menus, etcc....

http://qdvdauthor.sourceforge.net/

VUZE
Torrents
donwload: http://www.vuze.com/app


Emesene
Instant Messenger tipo MSN
info: http://ubuntudicas.blogspot.com/2007/12/emesene-clone-do-msn.html

Exaile
Player de mp3 e CD
download: via Adicionar/Remover Programas...

Frostwire
P2P
download: via Adicionar/Remover Programas...

Gmount-ISO
Leia imagens ISO
download: Via Synaptic
via terminal: sudo apt-get install gmountiso

PyTube
Baixar vídeos do YouTube
info: http://bashterritory.com/pytube/index.php
download

VLC
Player de vídeo divx ou dvd
download: Via Synaptic
info: http://ubuntudicas.blogspot.com/2007/10/vlc-no-mostra-as-legendas.html

Wifi Radar
Buscador de redes wireless
donwload: Via Synaptic
info: http://ubuntudicas.blogspot.com/2008/01/wifi-radar.html

sexta-feira, 23 de maio de 2008

Refinando os logs do Gentoo





From Gentoo Linux Wiki


As it is stated in the Gentoo Security Guide, syslog-ng provides some of the same features as syslog and metalog with a small difference. It can filter messages based on level and content (like metalog), provide remote logging like syslog, handle logs from syslogd (even streams from Solaris), write to a TTY, execute programs, and it can act as a logging server. Basically it is the best of both loggers combined with advanced configuration.










Quick Start


First, you have to emerge syslog-ng and add it to the default runlevel. If you want to start syslog-ng just now, execute the init script. Also, it is recomended to unmerge any system logger you have previously installed as loggers often use /dev/log (see this thread):


# emerge -av syslog-ng
# rc-update add syslog-ng default
# /etc/init.d/syslog-ng start

Also, you may want logrotate to rotate your logs


# emerge -av logrotate

For a quick start, here there is a classic configuration file slightly modified from Gentoo Security Guide.






File: /etc/syslog-ng/syslog-ng.conf




# /etc/syslog-ng/syslog-ng.conf
# From the Gentoo Linux Security Guide
# http://www.gentoo.org/doc/en/gentoo-security.xml
# Creative Commons - Attribution / Share Alike License
# http://creativecommons.org/licenses/by-sa/2.0

options { chain_hostnames(off); create_dirs (yes); sync(0); stats(43200); };

#source where to read log
source src { unix-stream("/dev/log"); internal(); };
source kernsrc { file("/proc/kmsg"); };

#define destinations
destination authlog { file("/var/log/auth.log"); };
destination syslog { file("/var/log/syslog"); };
destination cron { file("/var/log/cron.log"); };
destination daemon { file("/var/log/daemon.log"); };
destination kern { file("/var/log/kern.log"); };
destination lpr { file("/var/log/lpr.log"); };
destination user { file("/var/log/user.log"); };
# Should be maillog (Without dot) as it was the default on logwatch
destination mail { file("/var/log/maillog"); };

destination mailinfo { file("/var/log/mail.info"); };
destination mailwarn { file("/var/log/mail.warn"); };
destination mailerr { file("/var/log/mail.err"); };

destination newscrit { file("/var/log/news/news.crit"); };
destination newserr { file("/var/log/news/news.err"); };
destination newsnotice { file("/var/log/news/news.notice"); };

destination debug { file("/var/log/debug"); };
destination messages { file("/var/log/messages"); };
destination console { usertty("root"); };
destination console_all { file("/dev/tty12"); };
destination xconsole { pipe("/dev/xconsole"); };

#create filters
filter f_auth { facility(auth); };
filter f_authpriv { facility(auth, authpriv); };
filter f_syslog { not facility(authpriv, mail); };
filter f_cron { facility(cron); };
filter f_daemon { facility(daemon); };
filter f_kern { facility(kern); };
filter f_lpr { facility(lpr); };
filter f_mail { facility(mail); };
filter f_user { facility(user); };
filter f_debug { not facility(auth, authpriv, news, mail); };
filter f_messages { level(info..warn)
and not facility(auth, authpriv, mail, news); };
filter f_emergency { level(emerg); };

filter f_info { level(info); };
filter f_notice { level(notice); };
filter f_warn { level(warn); };
filter f_crit { level(crit); };
filter f_err { level(err); };
filter f_failed { match("failed"); };
filter f_denied { match("denied"); };

#connect filter and destination
log { source(src); filter(f_authpriv); destination(authlog); };
log { source(src); filter(f_syslog); destination(syslog); };
log { source(src); filter(f_cron); destination(cron); };
log { source(src); filter(f_daemon); destination(daemon); };
log { source(kernsrc); filter(f_kern); destination(kern); };
log { source(src); filter(f_lpr); destination(lpr); };
log { source(src); filter(f_mail); destination(mail); };
log { source(src); filter(f_user); destination(user); };
log { source(src); filter(f_mail); filter(f_info); destination(mailinfo); };
log { source(src); filter(f_mail); filter(f_warn); destination(mailwarn); };
log { source(src); filter(f_mail); filter(f_err); destination(mailerr); };

log { source(src); filter(f_debug); destination(debug); };
log { source(src); filter(f_messages); destination(messages); };
log { source(src); filter(f_emergency); destination(console); };

#default log
log { source(src); destination(console_all); };




You will see your defined log files in /var/log. In the following sections we will explain this configuration file in order to understand how syslog-ng works.


Sources


Syslog-ng receives log messages from a source. To define a source you should follow the following syntax:


source <identifier> { source-driver(params); source-driver(params); ... };


You can look at the identifiers and source-drivers in the manuals. This will follow the manual to explain the configuration file above.

The unix-stream() source-driver opens the given AF_UNIX socket and starts listening on it for messages. The internal() source-driver gets messages generated by syslog-ng.
Therefore,


source src { unix-stream("/dev/log"); internal(); };

Means: src gets messages from /dev/log socket and syslog-ng.

The kernel sends log messages to /proc/kmsg and the file() driver reads log messages from files. Therefore:


source kernsrc { file("/proc/kmsg"); };

Means: kernsrc gets messages from file /proc/kmsg

In the default configuration file after emerging syslog-ng, the source is defined as:


source src { unix-stream("/dev/log"); internal(); pipe("/proc/kmsg"); };

Reading messages by pipe("/proc/kmsg") gives a better performance but because it opens its argument in read-write mode can be a security hazard as the syslog-ng admin guide states in section 7.1.6:


Pipe is very similar to the file() driver, but there are a few
differences, for example pipe() opens its argument in read-write
mode, therefore it is not recommended to be used on special files
like /proc/kmsg." (You can follow this discussion in this post.)

Destinations



syslog-ng sends log messages to files. The syntax is very similar to sources:


destination <identifier> {destination-driver(params); destination-driver(params); ... };

You will be normally logging to a file, but you could log to a different destination-driver: pipe, unix socket, TCP-UDP ports, terminals or to specific programs. Therefore:


destination authlog { file("/var/log/auth.log"); };

Means sent authlog messages to /var/log/auth.log

usertty() sends messages to the terminal of the specified user, if the user is logged in. Then:


destination console { usertty("root"); };

Sends console messages to root's terminal if it is logged in.

pipe() sends messages to a pipe /dev/xconsole. Then:


destination xconsole { pipe("/dev/xconsole"); };

Sends xconsole messages to the pipe /dev/xconsole. This needs some more configuration, so you could look at the sub-section xconsole below.

udb() sends on the network


destination remote_server { udp("10.0.0.2" port(514)); };

this will send your log data out to a another server


xconsole



ATTENTION: this part is not yet finished.
You can look and contribute at this thread discussing the topic,
and have a look at this explanation
.

syslog-ng can send messages to the pipe /dev/xconsole. You should create it with mkfifo, giving the appropriate access and owner permissions:


# mkfifo /dev/xconsole
# chmod 644 /dev/xconsole
# chown root.tty /dev/xconsole

Afterwards, you need a program to read the messages sent to /dev/xconsole. xconsole is a console that monitors system messages with X. Frist step is to emerge xconsole:


emerge -av xconsole

And tell xconsole to read /dev/xconsole



# xconsole -file /dev/xconsole

You can modify the text window space editing /usr/share/X11/app-defaults/XConsole:


*text.width: 900
*text.height: 100

And the geometry:


xconsole -file /dev/xconsole -geometry +67+640

Creating Filters for Messages



Syntax for the filter statement:


filter <identifier> { expression; };

Functions can be used in the expression, such as the fuction facility() which selects messages based on the facility codes (look at the sub-section below for a list of facility codes). Therefore, the filter


filter f_auth { facility(auth); };

filters those messages coming from authorisation, like:


May 11 23:42:31 mimosinnet su(pam_unix)[18569]: session opened for user root by (uid=1000)


Expression can use the boolean operators and, or, not, so the filter:


filter f_debug { not facility(auth, authpriv, news, mail); };

selects those messages not coming from authorisation, network news or mail.

The funciont level() selects messages based on its priority level, therefore:


filter f_info { level(info); };

selects informational levels.

Functions and boolean operators can be combined in more complex expressions like:


filter f_messages { level(info..warn)
and not facility(auth, authpriv, mail, news); };

that filters messages with a priority level from informational to warning not coming from atuh, authpriv, mail and news facilities.

Messages can also be selected by matching a regular expression in the message with the function match(regexp). For example:


filter f_failed { match("failed"); };

Facilities and log-levels


The linux kernel has a few facilities you can use for logging. Each facility has a log-level; where debug is the most verbose, and panic only shows serious errors. You can find the facilities, log levels and priority names in /usr/include/sys/syslog.h:






File: /usr/include/sys/syslog.h




/* facility codes */
#define LOG_KERN (0<<3) /* kernel messages */
#define LOG_USER (1<<3) /* random user-level messages */
#define LOG_MAIL (2<<3) /* mail system */
#define LOG_DAEMON (3<<3) /* system daemons */
#define LOG_AUTH (4<<3) /* security/authorization messages */
#define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
#define LOG_LPR (6<<3) /* line printer subsystem */
#define LOG_NEWS (7<<3) /* network news subsystem */
#define LOG_UUCP (8<<3) /* UUCP subsystem */
#define LOG_CRON (9<<3) /* clock daemon */
#define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */
#define LOG_FTP (11<<3) /* ftp daemon */
/* other codes through 15 reserved for system use */
#define LOG_LOCAL0 (16<<3) /* reserved for local use */
#define LOG_LOCAL1 (17<<3) /* reserved for local use */
#define LOG_LOCAL2 (18<<3) /* reserved for local use */
#define LOG_LOCAL3 (19<<3) /* reserved for local use */
#define LOG_LOCAL4 (20<<3) /* reserved for local use */
#define LOG_LOCAL5 (21<<3) /* reserved for local use */
#define LOG_LOCAL6 (22<<3) /* reserved for local use */
#define LOG_LOCAL7 (23<<3) /* reserved for local use */

#ifdef SYSLOG_NAMES
CODE facilitynames[] =
{
{ "auth", LOG_AUTH },
{ "authpriv", LOG_AUTHPRIV },
{ "cron", LOG_CRON },
{ "daemon", LOG_DAEMON },
{ "ftp", LOG_FTP },
{ "kern", LOG_KERN },
{ "lpr", LOG_LPR },
{ "mail", LOG_MAIL },
{ "mark", INTERNAL_MARK }, /* INTERNAL */
{ "news", LOG_NEWS },
{ "security", LOG_AUTH }, /* DEPRECATED */
{ "syslog", LOG_SYSLOG },
{ "user", LOG_USER },
{ "uucp", LOG_UUCP },
{ "local0", LOG_LOCAL0 },
{ "local1", LOG_LOCAL1 },
{ "local2", LOG_LOCAL2 },
{ "local3", LOG_LOCAL3 },
{ "local4", LOG_LOCAL4 },
{ "local5", LOG_LOCAL5 },
{ "local6", LOG_LOCAL6 },
{ "local7", LOG_LOCAL7 },

* priorities (these are ordered)
*/
#define LOG_EMERG 0 /* system is unusable */
#define LOG_ALERT 1 /* action must be taken immediately */
#define LOG_CRIT 2 /* critical conditions */
#define LOG_ERR 3 /* error conditions */
#define LOG_WARNING 4 /* warning conditions */
#define LOG_NOTICE 5 /* normal but significant condition */
#define LOG_INFO 6 /* informational */
#define LOG_DEBUG 7 /* debug-level messages */

CODE prioritynames[] =
{
{ "alert", LOG_ALERT },
{ "crit", LOG_CRIT },
{ "debug", LOG_DEBUG },
{ "emerg", LOG_EMERG },
{ "err", LOG_ERR },
{ "error", LOG_ERR }, /* DEPRECATED */
{ "info", LOG_INFO },
{ "none", INTERNAL_NOPRI }, /* INTERNAL */
{ "notice", LOG_NOTICE },
{ "panic", LOG_EMERG }, /* DEPRECATED */
{ "warn", LOG_WARNING }, /* DEPRECATED */
{ "warning", LOG_WARNING },




Log Paths


syslog-ng connects sources, filters and destinations with log statements. The syntax is:


log {source(s1); source(s2); ...
filter(f1); filter(f2); ...
destination(d1); destination(d2); ...
flags(flag1[, flag2...]); };

For example:


log { source(src); filter(f_mail); filter(f_info); destination(mailinfo); };


Sends messages from 'src' source to 'mailinfo' destination filtered by 'f_info' filter.


Tips and Tricks


After understanding the logic behind syslog-ng, many possible and complex configuration are possible. Here there are some examples.


[edit] Move log to another file



in order to move some log from messages to another file:


#sshd configuration
destination ssh { file("/var/log/ssh.log"); };
filter f_ssh { program("sshd"); };
log { source(src); filter(f_ssh); destination(ssh); };

Configuring as a loghost


Configuring your system to be a loghost is quite simple.
Drop the following into your configuration, and create the needed directory.






File: /etc/syslog-ng/syslog-ng.conf




source net { udp(); };
destination remote { file("/var/log/remote/$FULLHOST"); };
log { source(net); destination(remote); };



With this simple configuration, log filenames will be based on the FQDN of the remote host, and located in; /var/log/remote/

After creating the remote directory, reload your syslog-ng.configuration.


Use pipe("/proc/kmsg") or file("/proc/kmsg")



In the default configuration file after emerging syslog-ng, the source is defined as:


source src { unix-stream("/dev/log"); internal(); pipe("/proc/kmsg"); };

It is not clear if we should use pipe("/proc/kmsg") or file("/proc/kmsg")- As the syslog-ng admin guide states in section 7.1.6:


Pipe is very similar to the file() driver, but there are a few
differences, for example pipe() opens its argument in read-write
mode, therefore it is not recommended to be used on special files
like /proc/kmsg."

(You can follow this discussion in this post.


Improve Performance



syslog performance can be improved in different ways:


Avoid redundant processing and disk space with flag(final)


A single log message can be sent to different log files several times. For example, in the initial configuration file, we have the following definitions:


destination cron { file("/var/log/cron.log"); };
destination messages { file("/var/log/messages"); };
filter f_cron { facility(cron); };
filter f_messages { level(info..warn)
and not facility(auth, authpriv, mail, news); };
log { source(src); filter(f_cron); destination(cron); };
log { source(src); filter(f_messages); destination(messages); };

The same message from the 'cron' facility will end up in both the cron.log and messages file. To change this behavior we can use the final flag, ending up further processing with the message. Therefore, in this example, if we want messages from the 'cron' facility not ending up in the messages file, we should change the cron's log sentence by:


log { source(src); filter(f_cron); destination(cron); flags(final); };

Postgresql Destination


Some of this information was obtained from http://www.kdough.net/docs/syslog_postgresql/.

Please note that this is a work in progress. For one, psql never gets killed when you restart syslog-ng. I just got this going today, so I haven't had a chance to look into it. For another, there are security implications.

Also, I'm still debating with myself whether there's really value in putting syslog logs into an RDBM.


[edit] syslog-ng-pgsql-pipe.sh



The following file can reside in /usr/local/sbin/syslog-ng-pgsql-pipe.sh


#!/bin/bash
#
# File: syslog-ng-pgsql-pipe.sh
#
# Take input from a FIFO and run execute it as a query for
# a PostgreSQL database.
#
# IMPORTANT NOTE: This could potentially be a huge security hole.
# You should change permissions on the FIFO accordingly.
#

ERROR_CODE=0

if [ -e /var/run/syslog-ng.pgsql.pipe ]; then
while [ -e /var/run/syslog-ng.pgsql.pipe ] && [ "$ERROR_CODE" -ne "143" ]
do
psql -q -h localhost -U syslog syslog < /var/run/syslog-ng.pgsql.pipe
/usr/local/bin/syslog-ng-parse.awk < /var/run/syslog-ng.pgsql.pipe
done
else
mkfifo /var/run/syslog-ng.pgsql.pipe
fi

syslog-ng.conf



#
# SQL logging support
#
destination d_pgsql {
pipe("/var/run/syslog-ng.pgsql.pipe"
template("INSERT INTO logs (host, facility, priority, level, tag, date,
time, program, msg) VALUES ( '$HOST', '$FACILITY', '$PRIORITY', '$LEVEL', '$TAG',
'$YEAR-$MONTH-$DAY', '$HOUR:$MIN:$SEC', '$PROGRAM', '$MSG' );\n"
)
template-escape(yes)
);
};
# make a filter if you like
# filter postfix {program ("postfix");};
log { source(src); destination(d_pgsql); };

syslog-ng (init.d)


I still can't figure out how to make the psql process die, during a stop or a restart of syslog-ng. pidof returns nothing, when run inside the syslog-ng init script. And using --make-pidfile of start-stop-daemon is almost useless, because it only kills the shell script that start psql, not psql itself.



start()


+ start-stop-daemon --start --background --quiet --exec /usr/local/sbin/syslog-ng-pgsql-pipe.sh
+ echo `pidof psql` > /var/run/syslog-ng-pgsql-pipe.pid
start-stop-daemon --start --quiet --exec /usr/sbin/syslog-ng ${SYSLOG_NG_OPTS}

[edit] stop()



  start-stop-daemon --stop --quiet --pidfile /var/run/syslog-ng.pid
+ start-stop-daemon --stop --quiet --pidfile /var/run/syslog-ng-pgsql-pipe.pid

PostgreSQL


In order for this to work, you're going to need a TRUST rule in pg_hba.conf, or a password, for the syslog user. There's obviously security implications for this, if you're using a TRUST rule. Although INSERTS into syslog will be possible, reads/modifications of existing log entries will not be. If you use a password, you may be able to restrict the init script to root access only. I'm not sure if that will work though. I'll have to try it. :) Alternatively, you can use the ~/.pgpass file to supply the credentials. See the reference, http://www.postgresql.org/docs/current/interactive/libpq-pgpass.html

~/.pgpass


hostname:port:database:username:password


su - postgres
createdb syslog
psql -h localhost -U postgres syslog
CREATE USER syslog WITH PASSWORD 'syslogXXXXXXX';
CREATE TABLE logs (
host varchar(32) default NULL,
facility varchar(10) default NULL,
priority varchar(10) default NULL,
level varchar(10) default NULL,
tag varchar(10) default NULL,
date date default NULL,
time time default NULL,
program varchar(15) default NULL,
msg text,
seq serial,
PRIMARY KEY (seq)
);
GRANT INSERT ON logs TO syslog; # security so people can't update the logs

[edit] Links





























quarta-feira, 21 de maio de 2008

10 coisas que podemos fazer com linux e não podemos com outros sistemas

Artigo Citado no VivaLinux.com.ar.
Original aqui.

Cada sistema possui particularidades que o fazem um sistema único. Os usuários possuem necessidades diferentes e não existe um sistema que seja perfeito para todos. O Linux é um excelente sistema em muitos aspectos e possui características que o fazem o melhor sistema em determinados aspectos. A seguinte lista é uma seleção de 10 destas características (muito boas) que o fazem diferente de outros sistemas operacionais. A ordem dos itens não importa, já que todas juntas dão ao Linux a essência de ser rápido, seguro, bonito e livre.

1 - Obter e manter atualizado um sistema completo legalmente sem pagar nada. A maioria das distribuições de Linux são completamente gratuitas, e em alguns custam uma quantidade muito pequena em comparação ao preço do Windows. Isso ocorre em função de suporte e de alguns produtos próprios da empresa.

2 - Poder rodar diferentes interfaces gráficas caso você não goste da que veio por padrão ou por ela não se adequar as suas necessidades. Há interfaces gráficas para todos os gostos, leves, inovadoras, capazes de imitar outras, muito atrativas, etc. Só em Linux contamos com essa variedade de interfaces, e como se fosse pouco, cada uma delas é completamente personalizável. Inclusive, há a possibilidade de trabalhar em modo texto e realizar muitas tarefas comuns, como escutar música, trocar mensagens, navegar na internet, baixar arquivos e várias coisas mais.

3- Ter total controle sobre o hardware do computador e saber que não há backdoors no meu software, colocados por companhias de software mal-intencionadas. Por ser um sistema GNU/Linux composto em sua maioria por software livre, o código está disponível para quem quiser vê-lo, por isso é possível assegurar-se que cada aplicação faz somente o que deve fazer.

4 - Não sentir falta de desfragmentar o disco-rígido, nunca. Os sistemas de arquivos utilizados pelo Linux não se fragmentam, já que foram planejados como sistema multi-usuários, armazenando os dados no disco de maneira seqüencial, por isso é raro se fragmentar um arquivo se o disco não estiver muito cheio.

5 - Experimentar diferentes programas, decidir os que não gosto, desinstalá-los e saber que não há lixo em um registro que pode deixar minha máquina lenta. Não acontece como no sistema da Microsoft que o registro sempre se enche de lixo e se estraga, ocasionando a necessidade de várias formatações anuais.

6 - Usar o SO sem necessidade de usar antivírus nem nenhum outro tipo de software anti-malware e não precisar reiniciar meu computador durante meses, sempre que pego as últimas atualizações de segurança. Com se fala em todo lugar: Linux é muito seguro e estável.

7 - Personalizar o que quiser, legalmente, incluindo meus programas favoritos. Eu posso perguntar aos mantenedores, propor idéias e participar do processo de desenho e programação do software que quiser. Estas são algumas das maravilhas do software livre, por que isso não se aplicar somente o Linux, mas também a toda a aplicação e projeto de software que de desenvolva sobre esta filosofia. Com o Software Livre, o software de nosso PC é realmente nosso.

8 - Usar o mesmo hardware durante mais de 5 anos até que realmente precise substituí-lo. Eu disse milhões de vezes nesse blog: Uma das mais grandes maravilhas do Linux é poder usar um sistema não pré-histórico em equipamentos com baixos recursos, em muitos casos considerados obsoletos (como exemplo, veja o Pentium II que graças ao Linux pode acompanhar-me por 7 anos como meu principal ferramenta de trabalho).

9 - Receber ajuda de centenas de usuários, especialistas e novatos de maneira gratuita e
desinteressada.
Um dos pontos mais fortes do Linux são as comunidades que se formam, ainda que existam o problema dos fanáticos, tem muitos que ajudam da maneira que podem a não deixar que o Linux seja um “sistema difícil” e aos poucos vão levando-o à todos.

10 - Ter um desktop com efeitos espetaculares, e muito superiores ao do Windows Vista em um computador de 3 anos atrás. E isso, a diferença do “Vista Capable” é certa. A atração gráfica do Linux deixou para trás por muito outros sistemas. Só há que melhorar um pouco as capacidades do Compiz Fusion com as do ambientes Enlightenment.

O texto se originou de posts sobre listas de coisas possíveis somente em Linux. Disponíveis aqui, aqui e aqui.

terça-feira, 6 de maio de 2008

Squid com Autenfificação Active Directoy

Esse é um roteiro simples e objetivo de como fazer a coisa acontecer. Não entro em detalhes porque estou sem tempo:

  • Instale o samba com suporte a AD pelo winbind, Compile ou use gentoo :-) Utilizando o gentoo ficaria:
/etc/make.conf

USE="samba pam ldap kerberos winbind"

emerge samba

gateway ~ # emerge samba

  • Instale o squid com suporte a autentificação ntlm compile ou use gentoo
  • Configure o kerberos em /etc/krb5.conf (há um exemplo no blog)
  • Configure o samba (há um exemplo no blog)
  • Inicie o servidor samba
  • Inicie o winbindd
  • Adicione o samba no dominio AD: gateway ~ # net rpc join soed -S domai1 -Uadministrator
  • Teste com o comando: gateway ~ # wbinfo -t
  • Confira os usuarios do dominio com o comando: gateway ~ # wbinfo -u
  • Configure o squid (há um exemplo no blog, substitua o caminho do ntlm_auth pelo caminho correto)

Ok Esse é o roteiro

Smb.conf

Arquivo /etc/samba/smb.conf


[global]
workgroup = SOED
server string = Servidor de Proxy
netbios name = srvproxy
log file = /var/log/samba/%m.log
max log size = 50
debug level = 1
security = domain
encrypt passwords = yes
smb passwd file = /etc/samba/smbpasswd
username map = /etc/samba/smbusers
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
unix charset = iso-8859-1
password server = *
winbind uid = 10000-20000
winbind gid = 10000-20000
winbind enum users = yes
winbind enum groups = yes
template homedir = /dev/null
template shell = /dev/null
winbind use default domain = yes
passdb backend = smbpasswd


[mrtg]
comment = "Graficos SERVIDOR"
path = /var/www/mrtg
public = yes
read only = yes

Kerberos.conf

Arquivo /etc/krb5.conf


/etc/krb5.conf

[libdefaults]
ticket_lifetime = 600
default_realm = SOED.LOCAL
default_tkt_enctypes = des3-hmac-sha1 des-cbc-crc
default_tgs_enctypes = des3-hmac-sha1 des-cbc-crc
dns_lookup_realm = false
dns_lookup_kdc = false

[realms]
soed.local = {
kdc = domain1.soed.local
admin_server = domain1.soed.local
kpasswd_server = domain1.soed.local
default_domain = SOED.LOCAL
}

[domain_realm]
.soed.local = SOED.LOCAL

#[kdc]
# profile = /etc/krb5kdc/kdc.conf

[logging]
kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmin.log
default = FILE:/var/log/krb5lib.log
~

Squid conf

Aqui vai o meu squid.conf

# Porta onde o squid esta rodando
http_port 8080

# Esta linha diz ao squid para utilizar o dansguardian na porta 3120 para filtro de conteúdo

cache_peer 127.0.0.1 parent 3120 3130 proxy-only no-netdb-exchange no-query

# Repassar para o dansguardian o ip dos clientes
# Configure o dansguardian com a opcao usexforwardedfor = no ; e forwardefor = off

forwarded_for on

hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
cache deny QUERY
acl apache rep_header Server ^Apache
broken_vary_encoding allow apache
access_log /var/log/squid/access.log squid
hosts_file /etc/hosts
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320


cache_dir ufs /cache 4000 16 256
cache_mem 128 MB
shutdown_lifetime 10 seconds
maximum_object_size 200 MB
minimum_object_size 1 kb



#NTLM
auth_param ntlm program /usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp -d 2
auth_param ntlm children 30
auth_param ntlm keep_alive on

#Básico
auth_param basic program /usr/bin/ntlm_auth --helper-protocol=squid-2.5-basic
auth_param basic children 10
auth_param basic realm CPD - Login
auth_param basic credentialsttl 2 hours

# Insira isto se você precisar que os usuários estejam contidos em grupos
external_acl_type nt_group ttl=0 concurrency=5 %LOGIN /usr/libexec/squid/wbinfo_group.pl


# Acls e configurações


acl autenticar proxy_auth REQUIRED
acl all src 0.0.0.0/0.0.0.0

acl rede_interna src 192.168.5.0/255.255.255.0
acl rede_laboratorios src 192.168.0.0/255.255.255.0
acl madrugada time 22:40-23:59
acl compl_madrugada time 00:00-06:30
acl almoco_sabado time A 12:30-13:30
#bloqueio por palavras

#acl bloqueio_palavras url_regex "/etc/squid/bloqueio_palavras.txt"
#acl libera_palavras url_regex "/etc/squid/libera_palavras.txt"

acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443 # https
acl SSL_ports port 563 # snews
acl SSL_ports port 873 # rsync
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl Safe_ports port 631 # cups
acl Safe_ports port 873 # rsync
acl Safe_ports port 901 # SWAT
acl Safe_ports port 808 # MYAUTH
acl purge method PURGE
acl CONNECT method CONNECT

# regras de bloqueio desbloqueio

#http_access allow libera_palavras
#http_access deny bloqueio_palavras
http_access deny madrugada
http_access deny compl_madrugada
http_access allow manager localhost
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
#http_access allow rede_interna autenticar
http_access allow rede_interna !madrugada !compl_madrugada
http_access allow rede_laboratorios !madrugada !compl_madrugada !almoco_sabado
http_access deny all
icp_access allow all
visible_hostname cpd.soed.local
coredump_dir /var/spool/squid
extension_methods REPORT MERGE MKACTIVITY CHECKOUT

segunda-feira, 5 de maio de 2008

Configuração Servidor Openfire - Gentoo

Openfire é um servidor de mensagens instantâneas poderoso, que utiliza o protocolo jabber para comunicação.

Aqui segue um pegueno tutorial para instalá-lo no gentoo linux ou outra distribuição qualquer:


Primeiro instale o mysql, o openfire utilizá-o para guardar informações (não é obrigatório mas é altamente recomendado:

gateway ~ # emerge mysql

Após instalar rode o comando:

gateway
~ # emerge --config =dev-db/mysql-5.0.54

inicie o servidor:

gateway ~ # /etc/init.d/mysql start



e configure o mysql pela primeira vez. Defina uma senha de root

No debian o comando seria:

# apt-get install mysql-server

Após a intalação vamos criar um banco de dados para o openfire


gateway ~ # mysqladmin -u root -p create openfire
Enter password: ******

Após Criarmos a base de dados vamos criar um usuário com permisão para acessar o banco
Logue no banco:

gateway ~ # mysql -u root -p

Rode o comando no shel do mysql:

mysql> grant all privileges on openfire.* to
usuario@localhost identified by 'password'


Onde: usuario é o usuário que você que criar e password o password
que você quer dar

Agora vamos ajustar o arquivo /etc/conf.d/openfire (no gentoo)

adicione a seguinte linha após a linha OPENFIRE_HOME=/opt/openfire:


OPENFIRE_USER="root"

Copie o arquivo de configuração no diretório:
/opt/openfire/conf/openfire.xml.sample
para

/opt/openfire/conf/openfire.xml

gateway ~ # cp /opt/openfire/conf/openfire.xml.sample
/opt/openfire/conf/openfire.xml



Se nao fizer o proximo comando vai dar pau na hora de configurar:

gateway ~ # chown jabber:jabber
/opt/openfire/conf/openfire.xml

após isso inicie o servidor com o comando


gateway ~ # /etc/init.d/openfire start

Acesse o console de instalação em:

http://localhost:9090


Você verá uma imagem como está:
























Escolha sua linguagem e clique em continuar:

Na próxima tela você terá a oportunidade de mudar a porta do console de administração do openfire e mudar o nome do servidor eu deixo tudo como está

Clique em next

Nessa tela temos duas opções:
Utilize um banco de dados externo com o pool de conexão interno.

Utilize um banco de dados interno, mantido por HSQLDB. Esta opção não requer nenhuma configuração de um banco de dados externo e é um modo fácil de rodar o serviço rapidamente. Todavia, ele não oferece o mesmos nível de performance que um banco de dados externo.


Se você instalou o mysql ou vai usar qualquer outro banco de dados selecione a primeira opção. Se não pretende utilizar banco de dados selecione a segunda


Bom eu creio que você deve ter instalado o mysql então deixe como está e clique em continuar

Selecione o banco de dados mysql

Em URL do banco de dados coloque as configurações do seu banco, no lugar de hos-tname coloque localhost e no lugar de dadabase-name coloque openfire.
No nome de usuário coloque o nome do usuario com acesso a base de dados do openfire e em senha coloque sua senha


Após isso o resto é fácil, configure uma senha para o admin e divirta-se com as opções do openfire

Documentando - Funções do Servidor Gentoo

  1. Configurações de Hardware

Como servidor de internet tenho a seguinte máquina:


processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Celeron(R) CPU 2.26GHz
stepping : 9
cpu MHz : 2266.852
cache size : 256 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe constant_tsc up pebs bts sync_rdtsc pni monitor ds_cpl cid xtpr lahf_lm
bogomips : 4538.47
clflush size : 64

1 GB RAM -
HD 160 GB SAMSUNG HD161HJ Seviços Configurados:


Sistema Operacional:

Gentoo - GNU/Linux 2007.0

2. Serviços Ofertados:


  • Servidor DHCP
  • Proxy Squid com autentificação No Active Directory atraves do samba e winbind
  • SAMBA - Principal função é logar no Active Directory
  • Firewall e Roteamento de Pacotes
  • MRTG - Monitoramento do uso da internet
  • Open SSH - Acesso remoto para manutenção
  • Openfire - Comunicação Interna através do protocolo JABBER
  • Dansguardian - Controle de conteúdo