вторник, 16 февраля 2010 г.

sudo tips

chroot allow

>sudoers
user  ALL = NOPASSWD: /usr/sbin/chroot -u user  /workdirectory
>command
 sudo /usr/sbin/chroot -u user /workdirectory

allow only service restart and edit config
>sudoers
user ALL=NOPASSWD: /etc/init.d/lighttpd restart, /usr/bin/vim /etc/lighttpd/lighttpd.conf

четверг, 11 февраля 2010 г.

linux i/o monitoring

некоторый полезные команды  linux   для мониторинга различного in\out подсистем

vmstat  -  дисковая подситема  и swap ,очень похожа по поведению на iostat во FreeBSD
sar  -  информация о io событиях происходивших в системе


sysctl.conf
vm.swappiness - параметр определяющий приоритет хранение памяти в свап, 0..100, чем больше тем больше лезет в swap. изменить мгновенно можно командой  
 echo 50 > /proc/sys/vm/swappiness

пятница, 5 февраля 2010 г.

ipfw enable

в очередной раз наступив на свои любимые грабли.
как включить ipfw

firewall_logging="YES"
firewall_enable="YES"
firewall_quiet="YES"  #  если это не вписать то в случае если в /etc/ipfw.conf есть flush  будет запрос на рутовой консоли, и сервер не загрузится.
firewall_type="/etc/ipfw.conf"

четверг, 4 февраля 2010 г.

mason + lighttpd fastcgi

включаем mason в lighttpd

сначало готовим скрипт mason.cgi


#!/usr/bin/perl
use CGI::Fast;
use HTML::Mason::CGIHandler;
use URI;

{
package HTML::Mason::Commands;

## anything you want available to components
use Storable qw(freeze thaw);
use HTTP::BrowserDetect;

## An example of how to keep a $dbh persistent
##our $dbh = DBI->connect_cached(
## 'dbi:Pg:dbname=dbname'
## , 'username'
## , 'password'
## , {AutoCommit=>0, RaiseError=>1, PrintError=>1}
##) || die "Could not Connect to DB".$dbi::errstr ;

}

# lazily-instantiated variables
my $cgi;
my $h;

while ($cgi = new CGI::Fast())
{
## make sure it is alive! (if not it will reconnect)
## $HTML::Mason::Commands::dbh->ping;

my $uri = URI->new( $ENV{REQUEST_URI} );

## this is a hack, that emulates mod_perl behavior see notes at bottom
## You might not want this hack, and it might be worse than not having it
$uri->path( $uri->path . 'index.html' )
if $uri->path =~ /\/$/
;

$ENV{PATH_INFO} = $uri->path;
$ENV{QUERY_STRING} = $uri->query;
$ENV{REQUEST_URI} = "$uri";

# this is lazily instantiated because %ENV is not set at startup time
if (! $h) {
$h = HTML::Mason::CGIHandler->new(
comp_root => $ENV{MASON_COMP_ROOT}
, data_dir => $ENV{MASON_DATA_ROOT}
, error_mode => 'fatal'
, error_format => 'line'
## Three good globals dbh user and session
, allow_globals => [qw/$dbh $U $S/]
);
}

## hand off to mason
eval { $h->handle_cgi_object($cgi) };

## catch error
if ( my $raw_error = $@ ) {
warn $raw_error;
# print out a pretty system error page and log $raw_error
}
## things went well
else {
$HTML::Mason::Commands::dbh->commit;
}

}

exit 0;


добавляем в lighttpf.conf

fastcgi.map-extensions = ( ".css" => ".html", "/" => ".html" )
        index-file.names = ( "index.html" )
        url.access-deny = ( ".mhtml" ) ## add autohandler/dhandler if you'd like
        fastcgi.server = ( ".html" =>
        ((
                "socket" => "/tmp/fastcgi.socket",
                "bin-path" => "/etc/lighttpd/bin/mason.cgi",   # пусть до скрипта
                "check-local" => "disable",
                "bin-environment" => (
                "MASON_COMP_ROOT" => "/www/myproject",
                "MASON_DATA_ROOT" => "/www/myproject/data",
                ),
        ))
        )


index.html кладем в comp_root
простенький helloworld
<HTML>
   <HEAD>
   <TITLE> Hello <% $worldname %> world!!</TITLE>
   </HEAD>
   <BODY bgcolor="#FFFFFF">
   Hello World<BR>
   This is my <B><% $count %></B> Mason component.
   </BODY>
</HTML>
<%init>
   my $worldname = "Great";
   my $count = "first";
</%init>
<%args>
</%args>

freebsd kernel 6.x -> 7.2

в FREEBSD 7 поменялись опции ядра касательно IPSEC

эти опции отсутствуют

options     IPSEC_ESP       #IP security (crypto; define w/ IPSEC)
options     IPSEC_FILTERGIF # Enbale to filter IPSEC GIF packets


ipsec теперь требует device crypto



device crypto
device enc
options IPSEC
options IPSEC_FILTERTUNNEL
 
 
 
*some notes 
# Set IPSEC_FILTERTUNNEL to change the default of the sysctl to force packets
# coming through a tunnel to be processed by any configured packet filtering
# twice. The default is that packets coming out of a tunnel are _not_ processed;
# they are assumed trusted.