Archive

Archive for the ‘sysadmin’ Category

Bloquear a google bot de todos los virtualhosts

March 11th, 2011 No comments

Esto es algo muy comun, es decir, una necesidad comun entre los programadores.

Todos los programadores usan un server de desarrollo, y obviamente no estan interesados en que Google pase a indexar las paginas de desarrollo.

Es por eso, que aca va una forma muy simple de resolver el problema.

Para bloquear a Googlebot de todos los virtualhosts simplemente podemos crear una regla para un directorio parent a todos los virtualhosts.

Supongamos que nuestro escenario es: /home/virtuals/site1 , /home/virtuals/site2, N

RewriteEngine On
RewriteRule  .*robots\.txt$         /home/varios/robotsforall.txt [L]

En el robotsforall.txt simplemente ponemos

User-agent: *
Disallow: /
Categories: apache, SEO, sysadmin Tags:

Tirar servidor web usando formularios de busqueda

November 30th, 2010 3 comments

Tirar servidor web usando formularios de busqueda

Tirar servidor web usando formularios de busqueda

El ataque y los motivos

En el mundo web es comun encontrar muchos errores a la hora de asegurar nuestras aplicaciones.

Una de las situaciones mas comunes es dejar el apache sin proteccion contra request multiples (mas de cien por minuto) y dejar los formularios de busquedas sin proteccion.

Los formularios de busquedas sobre sitios con un volumen importante de informacion normalmente son una gran oportunidad para tirar un sitio abajo durante un momento, y si armamos un cron, lo dejamos abajo todo el dia.

Obviamente este ataque es simple, muy casero y no presenta complicaciones para ejecutar o defendernos.

Un proceso de busqueda requiere mas que nada de dos factures, un servidor web que atienda la peticion y un servidor de bases de datos que procese la busqueda.

Vamos a plantear el tipico escenario Linux + Apache + PHP + MySQL (lamp).

Como la mayoria sabe, mysq hace cache de las busquedas, para no procesar una y otra vez la misma query, simplemente reconoce la query y retorna el resultados, por lo que nuestra primer pista es hacer busquedas aleatorias de “cosas”.

Por otro lado, cuando hacemos una query que tarda N segundos, PHP queda a la espera del resultado, por lo que Apache queda a la espera por decante, y como sabemos, apache tiene un limite de procesos.

Entonces, si logramos llegar a ese limite de procesos, apache se “congela” dejando de atender a los usuarios.

Si le mandamos a mysql miles de querys que sean imposibles de hacer cache, procesara una y otra vez… buscando que mysql se “muera”.

El resultado de esto es un sitio muerto que deja de funcionar.

Ejemplo de un codigo simple para matar a un website sin proteccion.

function getLetra(){
$letras=array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");

$str="";
for($x=0;$x<6;$x++){
        $str.=$letras[rand(0,count($letras)-1)];
}
return $str;
}

for($x=0; $x<=100000; $x++){ $string=getLetra(); echo $r="wget 'http://www.sitio.com/buscador.php?q=$string' -O /dev/null & "; exec($r); }

Como vemos es un codigo muy simple y realmente efectivo para los sites que no han tomado las medidas de seguridad basicas.

Como protegernos

Antes que nada, configuramos el mysql con un timeout razonable.

Despues lo ideal es poner una rutina en PHP que controle los request que hace una misma ip, y bloquear la busqueda si se excede de lo “normal”.

Tambien se puede activar el modulo de proteccion mod_security y mod_evasive, el ultimo es ideal para evitar el ataque que explicamos anteriormente.

Detectar links rotos con wget

June 28th, 2010 No comments
Con wget podemos detectar todos los links rotos de un website de una forma muy simple.
#  wget –spider  –no-parent -r -o log.txt http://website.com
–spider : recorre el site indicado, sin hacer download.
- r : recursivo
- o archivo : redigimos el output del comando
–no-parent : no subir a directorios de niveles superiores
Gracias  Andres Gattinoni por compartir el tip.

Instalar htop en FreeBSD

June 4th, 2010 No comments

Para instalar HTOP en FreeBSD (7,8, da igual)

abrimos /etc/rc.conf y agregamos  linux_enable=”YES”

vamos a : cd /usr/ports/emulators/linux_base-fc4  e instalamos

make
make install install

agregamos estas linea en  /etc/fstab

linproc /compat/linux/proc linprocfs rw 0 0

ejecutamos: mount linproc

finalmente instalamos el port de htop
cd /usr/ports/sysutils/htop

make
make install

Perfecto, ya quedo instalado htop en freebsd

Categories: FreeBSD, Servidores, sysadmin Tags: ,

error /usr/ports/textproc/iso8879 freebsd 8

June 4th, 2010 No comments

Si han instalado un servidor con FreeBSD 8, y han querido instalar algun port que requiere de iso8879 seguramente se han encontrado con el siguiente error

Stop in /usr/ports/textproc/iso8879.
*** Error code 1
Stop in /usr/ports/textproc/docbook-410.
*** Error code 1
Stop in /usr/ports/textproc/docbook.
*** Error code 1
Stop in /usr/ports/textproc/docbook.
*** Error code 1
Stop in /usr/ports/textproc/docbook-xsl.
*** Error code 1
Stop in /usr/ports/textproc/docbook-xsl.
*** Error code 1
Stop in /usr/ports/graphics/liblqr-1.
*** Error code 1
Stop in /usr/ports/graphics/liblqr-1.
*** Error code 1
Stop in /usr/ports/graphics/ImageMagick.
*** Error code 1

Stop in /usr/ports/textproc/iso8879.*** Error code 1
Stop in /usr/ports/textproc/docbook-410.*** Error code 1
Stop in /usr/ports/textproc/docbook.*** Error code 1
Stop in /usr/ports/textproc/docbook.*** Error code 1
Stop in /usr/ports/textproc/docbook-xsl.*** Error code 1
Stop in /usr/ports/textproc/docbook-xsl.*** Error code 1
Stop in /usr/ports/graphics/liblqr-1.*** Error code 1
Stop in /usr/ports/graphics/liblqr-1.*** Error code 1
Stop in /usr/ports/graphics/ImageMagick.*** Error code 1

Basicamente el bug esta reportado, pero aun no hay fix.

Solucion? simplemente copie el port de un FreeBSD 7, lo tire en el FreeBSD 8 e instale. No hubo ningun problema, quedo todo operativo y problema resuelto.

mod_rewrite para cambiar imagenes segun pais de origen

May 12th, 2010 No comments

Nuestro amigo Demian Rodriguez despues de una corta discucion en la lista, nos trae una configuracion para mod_rewrite que permite servir imagenes segun el pais de origen del visitante.

Espero que les sea util a todos.

# rewrite images by language
	RewriteCond %{HTTP_COOKIE} locale=nl_NL [NC]
	RewriteCond %{REQUEST_FILENAME} /images/(.*?)$
	RewriteCond %{REQUEST_FILENAME} !/images/nl/.*?$
	RewriteCond %{DOCUMENT_ROOT}/images/nl/%1 -f
	RewriteRule ^.*$ images/nl/%1 [NC,L]

Instalar PHP 5.2.x en Centos

August 4th, 2008 1 comment

Estimado, tube un caso con un cliente al cual tube que instalar el PHP 5.2.x en su Centos 4.x, y fue una cosa que me volvio loco.

Despues de mucho googlear, encontre esta solucion que quiero compartir.

http://www.jasonlitka.com/2007/06/01/upgrading-to-php-523-on-rhel-and-centos/

[Articulo]

PHP 5.2.3 has been released. This version does not have the massive number of bug fixes that came with 5.2.2 (which included many of the patches from the Month of PHP Bugs), but it does have some useful fixes included, including the fix for the HTTP_RAW_POST_DATA bug that was introduced in PHP 5.2.2.

This build was relatively straight forward and didn’t require any modifications to the spec file from my build of 5.2.2. I’ll probably do a respin when MySQL 5.0.42 is finally marked as “released” (the source package is already available but the changelog hasn’t been updated with an official release date).

For those that like to build from source, feel free to use the Source RPM from the link below. For my repository users, the new version is already available and all you’ll need to do is run a “yum update”.

UPDATE (6/19/2007): The PHP 5.2.3 packages have been updated. The Source RPM link below has also been updated to prevent anyone from downloading an out-of-date file.

If you want compile the src rpm yourseld here are the directions.

mkdir /usr/src/redhat
chmod -R 777 /usr/src/redhat

rpm -ivh php-5.2.3-jason.1.src.rpm

cd /usr/src/redhat/SPECS/

here you have a file dot spec with the configure and build lines.

rpmbuild -bb name_of_your_package.spec (in this case i think that is PHP)

when all finish right you have one or many package in the RPMS folder, you need update your current rpms with this, with the following command.

rpm -Uvh name_of_package_output.rpm


Como crear un modulo para el kernel de FreeBSD

August 4th, 2008 No comments

Este articulo explica de forma simple, como se crea un modulo para el Kernel de FreeBSD.

La verdad, es que me parece que es muy simple de entender.

http://www.freesoftwaremagazine.com/articles/writing_a_kernel_module_for_freebsd

[Articulo]

FreeBSD 7.0 has already been released. If you are a real hacker, the best way to jump in and learn it is hacking together an introductory kernel module. In this article I’ll implement a very basic module that prints a message when it is loaded, and another when it is unloaded. I’ll also cover the mechanics of compiling our module using standard tools and rebuilding the stock FreeBSD kernel. Let’s do it!

Getting Started

There are some prerequisites for this article. I assume you have a little bit of C programming knowledge, though nothing too fancy. If I reference a pointer or a structure, I expect you to understand those concepts without much explanation. I also expect you to be familiar with UNIX-like operating systems and know your way around basic shell usage.

The first thing to do is make sure the development environment you’ll be working in includes everything and is configured properly. I’m going to assume you already have FreeBSD installed and running. If you don’t, and would like some guidance, you can read my article: Secure emails servers with FreeBSD. I’ll be doing a few things differently; so, I would recommend just using it as a resource for the installation, which is identical in both scenarios.

You will also need to make sure the sudo utility is installed and configured for your main user account. This is required to run as “root” the utilities kldload and kldunload. The FreeBSD port for sudo is in /usr/ports/security/sudo.

cd /usr/port/security/sudomake install && make clean

Now su to root and run the visudo utility. Visudo uses the EDITOR environment variable to determine which text editor to use. If you don’t like the default one, override it with setenv EDITOR vim if you are using the default CSH, or export EDITOR=vim if you are using bash. Then simply re-run visudo.

suvisudo

The visudo utility does basic sanity checking on the syntax and makes sure no two people edit the sudoers file at the same time.

# Look for this line, copy it and change the "root" user to your main users name.root    ALL=(ALL) SETENV: ALLyourabi ALL=(ALL) SETENV: ALL

Your first kernel

As I mentioned in my recent article Review of FreeBSD 7.0, the ULE scheduler brings a new level of performance and multi-processor scalability to FreeBSD. Though it is now considered stable and ready for prime-time, it will not be enabled by default until the 7.1 release. A good litmus test of your setup will be compiling a custom kernel with the ULE scheduler enabled.

If you are on an x86 based machine, the kernel is located in the /usr/src/sys/i386 directory. For amd64 machines, simply replace i386 with amd64, which becomes /usr/src/sys/amd64. The kernel configuration file is located in a directory called conf. Enter that directory and create your own custom kernel configuration file by copying the “generic” default configuration to one of our own naming.

cd /usr/src/sys/amd64/confcp GENERIC CUSTOM

Now it’s time to enable the new ULE scheduler. The new ULE scheduler brings improved performance and scalability compared to the legacy scheduler and also serves as a good demonstration of building and installing a custom kernel.

Open the “CUSTOM” file with your text editor of choice and find the line enabling the legacy 44BSD scheduler and replace it with ULE. In the stock kernel configuration file this should be around line 30 (at the time of this writing).

options     SCHED_4BSD  # 4BSD scheduler# BECOMES #options     SCHED_ULE   # ULE scheduler

Now build your new kernel and reboot so it takes effect. FreeBSD has an elegant, simple build system using the standard “make” utility. Simply change directories to the source tree and invoke the make file with the “buildkernel” and “installkernel” targets. If you call them without any parameters, the GENERIC (default) kernel will be built and installed. Since you want your custom kernel, pass in the KERNCONF flag with the name of the target kernel. In this case, it will be the name that you just copied the generic kernel to: CUSTOM.

cd /usr/srcmake buildkernel KERNCONF="CUSTOM"make installkernel KERNCONF="CUSTOM"

reboot

Congratulations! As the system boots up, it will run the new custom kernel with the ULE scheduler enabled. You have now verified that you are able to compile and install a kernel, so it’s time to take on your next task: writing a simple kernel module.

When running FreeBSD in VMWare make sure to lower the kernels timer frequency

Note: If you are running FreeBSD in VMWare there is one very important performance tweak to make to your system to follow this article. The kernel’s timer frequency needs to be lowered from ‘1000’ to ‘100’ ticks per second. Edit /boot/loader.conf with your favorite editor and add the following line.

echo kern.hz=100 >> /boot/loader.conf

Kernel Hello World

As you may have noticed, FreeBSD makes efficient use of the make utility for building and installing kernels (and the rest of the operating system). What you may not know yet, but will come as no surprise, is that the FreeBSD developers have also developed make files to ease part of the difficulty of kernel module development.

An in depth look at make files and the make utility are beyond the scope of this article. However, two points of immediate relevance are the bsd.kmod.mk make file and the ability to include other make files within each other.

The bsd.kmod.mk makefile resides in /usr/src/share/mk/bsd.kmod.mk and takes all of the pain out of building and linking kernel modules properly. As you are about to see, you simply have to set two variables:

  • the name of the kernel module itself via the “KMOD” variable;
  • the source files configured via the intuitive “SRCS” variable;

Then, all you have to do is include to build the module. This elegant setup lets you build your kernel module with only the following skeletal make file and a simple invocation of the “make” utility.

The Makefile for our introductory kernel module looks like this:

# Note: It is important to make sure you include the  makefile after declaring the KMOD and SRCS variables.

# Declare Name of kernel moduleKMOD    =  hello_fsm

# Enumerate Source files for kernel moduleSRCS    =  hello_fsm.c

# Include kernel module makefile.include

Create a new directory called kernel, under your home directory. Copy and paste the text above into a file called Makefile. This will be your working base going forward.

Creating a module

Now that you have a clue about the build environment, it’s time to take a look at the actual code behind a FreeBSD kernel module and the mechanisms for inserting and removing a module from a running kernel.

A kernel module allows dynamic functionality to be added to a running kernel. When a kernel module is inserted, the “load” event is fired. When a kernel module is removed, the “unload” event is fired. The kernel module is responsible for implementing an event handler that handles these cases.

The running kernel will pass in the event in the form of a symbolic constant defined in the /usr/include/sys/module.h () header file. The two main events you are concerned with are MOD_LOAD and MOD_UNLOAD.

How does the running kernel know which function to call and pass an event type as a parameter to? The module is responsible for configuring that call-back as well by using the DECLARE_MODULE macro.

The DECLARE_MODULE macro is defined in the header on line 117. It takes four parameters in the following order:

  1. name. Defines the name.
  2. data. Specifies the name of the moduledata_t structure, which I’ve named hello_conf in my implementation. The moduledata_t type is defined at line 55 of . I’ll talk about this briefly.
  3. sub. Sets the subsystem interface, which defines the module type.
  4. order. Defines the modules initialization order within the defined subsystem

The moduledata structure contains the name defined as a char variable and the event handler routine defined as a modeventhand_t structure which is defined at line 50 of . Finally, the moduledata structure has void pointer for any extra data, which you won’t be using.

If your head is about to explode from the overview without any code to put in context, fear not. That is the sum of what you need to know to start writing your kernel module, and so with that, “once more into the breach dear friends”. Before you get started, make sure you are in the same kernel directory where you previously created the Makefile file. Fire up your text editor of choice and open a file called hello_fsm.c.

First include the header files required for the data types used. You’ve already seen and the other includes are supporting header files.

#include #include #include #include

Next, you are going to implement the event_handler function. This is what the kernel will call and pass either MOD_LOAD or MOD_UNLOAD to via the event parameter. If everything runs normally, it will return a value of 0 upon normal completion. However, you should handle the possibility that something will go wrong and if the event parameter is neither MOD_LOAD or MOD_UNLOAD, you will set e, your error tracking variable, to EOPNOTSUPP.

/* The function called at load/unload. */static int event_handler(struct module *module, int event, void *arg) {       int e = 0; /* Error, 0 for normal return status */       switch (event) {       case MOD_LOAD:               uprintf("Hello Free Software Magazine Readers! \n");               break;       case MOD_UNLOAD:               uprintf("Bye Bye FSM reader, be sure to check http://freesoftwaremagazine.com !\n");               break;       default:               e = EOPNOTSUPP; /* Error, Operation Not Supported */               break;       }

       return(e);}

Next, you’re going to define the second parameter to the DECLARE_MODULE macro, which is of type moduledata_t. This is where you set the name of the module and expose the event_handler routine to be called when loaded and unloaded from the kernel.

/* The second argument of DECLARE_MODULE. */static moduledata_t hello_conf = {   "hello_fsm",    /* module name */    event_handler,  /* event handler */    NULL            /* extra data */};

And finally, you’re going to make a call to the much talked about DECLARE_MODULE with the name of the module and the hello_conf structure.

DECLARE_MODULE(hello_fsm, hello_conf, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);

All that is left to do is build the module. Double check that you are in the same directory as the module’s makefile you saw earlier and run:

make

Loading and unloading the module

To load the module, you have two options: the kldload utility or the load make target via the makefile. You must use both options via the “sudo” utility as loading and unloading modules requires root privileges.

sudo kldload ./hello_fsm.ko# or #sudo make load

You should see the message “Hello Free Software Magazine Readers!” on your console. To view all loaded modules, use the kldstat utility with no arguments. kldstat does not require root privileges and you can verify that the module is indeed loaded.

 kldstatId Refs Address    Size     Name1    8 0xc0400000 926ed4   kernel2    1 0xc0d27000 6a1c4    acpi.ko3    1 0xc317e000 22000    linux.ko4    1 0xc4146000 2000     hello_fsm.ko

To unload the module, use kldunload or the unload target in the make file. You should see the message printed on the MOD_UNLOAD case, which is “Bye Bye FSM reader, be sure to check http://freesoftwaremagazine.com!”

sudo kldunload hello_fsm or

sudo make unload

Conclusion

There you have it, a basic, skeletal kernel module. It prints a message when loaded and a separate message when being unloaded from the kernel. This article covered the mechanics of building, inserting, and removing the module. You know have the basic building blocks to take on more advanced projects: I would recommend looking at writing a character device writer as it is probably the next simplest device driver.

I hope this has been as much fun for you as it has been for me!

Resources

Books:

  • The Design and Implementation of the FreeBSD Operating System, by Marshall Kirk McKusick and George V. Neville-Neil
  • Designing BSD Rootkits, an Introduction to Kernel Hacking, by Joseph Kong

Configuración de ISP

July 15th, 2008 1 comment

Leyendo Linuxeando, me entero en este post que How To Forge sacó una serie de guías para la configuración de un ISP (un servidor completo que ofrezca todos los servicios necesarios para un ISP y alojamiento web: servidor web Apache (con SSL), servidor de correo Postfix con SMTP-AUTH y TLS, servidor DNS con BIND, servidor FTP con Proftpd, servidor MySQL, Dovecot POP3/IMAP, Quota, Firewall, etc.).

Sacaron versiones para distintas distribuciones. Yo estoy esperando la de Slackware.

También hace un tiempo salió un documento de Implementación de servidores con GNU/Linux por Joel Barrios Dueñas.

Con respecto a otros sistemas operativos Unix, también está disponible esta guía para instalar un ISP en FreeBSD, pero por lo que estuve hablando con Cesar a esta guía le faltarían algunas cositas. Estaría bueno que Cesar publique su versión más completa y en castellano.

De más está decir que no pongo las manos en el fuego por NINGUNA de las guías nombradas, sino que esto es meramente para compartir información.

SMF en Solaris

July 14th, 2008 No comments

Estuve investigando un poco sobre SMF en Solaris y está bastante interesante, así que comparto lo que aprendí.

Solaris 10 incorpora SMF: Service Management Facility, que básicamente es un daemon que controla los servicios que corren en el sistema operativo. Su idea es reemplazar los scripts de /etc/init.d y /etc/rc.*.d, con una utilidad bastante más robusta y simple de configurar.

A partir de Solaris 10, entonces, vemos que muchos servicios que antes estaban en /etc/init.d ahora desaparecieron de allí y si revisamos el /etc/inittab vemos que una de las primeras cosas que hace es levantar el svc.startd que es el daemon que maneja los servicios de SMF. De hecho, dicen que ahora el boot es bastante más limpito, porque todos los mensajes de los servicios que se inician se van logueando en distintos lugares, y uno termina viendo algo así:

SunOS Release 5.10 Version Generic 64-bit
Copyright 1983-2004 Sun Microsystems, Inc.  All rights reserved.
Use is subject to license terms.
Hostname: demobox
NIS domain name is testlab.example.com
checking ufs filesystems

demobox console login:

En este link hay una Quickstart Guide muy interesante, donde muestra cómo se hacían las cosas en las versiones anteriores de Solaris y cómo deberían hacerse ahora con SMF: http://www.sun.com/bigadmin/content/selfheal/smf-quickstart.jsp

Subir y bajar el apache es tan sencillo como ejecutar los siguientes comandos:

Levantar:     svcadm enable network/http:apache2
Bajar:           svcadm disable network/http:apache2
Reiniciar:     svcadm restart network/http:apache2

Como podrán observar, los servicios se agrupan en unidades más “user-friendly” (o admin-friendly), en vez de ser archivos tirados en directorios (de hecho en Solaris siempre era más molesto que en Linux, porque el archivo debía estar indefectiblemente en /etc/init.d y con hard links en /etc/rc3.d – para el caso de servicios que levantaran en runlevel 3). Además se pueden configurar facilmente variables de entorno y otras cosas locas que se deben inicializar con el servicio.

Por otro lado, al haber un daemon constantemente corriendo, si el servicio no es deshabilitado por un “restarter” habilitado, el servicio se levanta automáticamente:

[root@BOCUNOCDWB04:~]# svcadm enable network/http:apache2
[root@BOCUNOCDWB04:~]# ps -ef |grep httpd
root 23319     1   3 13:38:59 ?           0:01 /usr/local/apache2/bin/httpd -k start -DSSL
nobody 23328 23319   0 13:39:02 ?           0:00 /usr/local/apache2/bin/httpd -k start -DSSL
root 23330 22786   0 13:39:04 pts/2       0:00 grep httpd
nobody 23327 23319   0 13:39:02 ?           0:00 /usr/local/apache2/bin/httpd -k start -DSSL
root 23322     1   0 13:39:01 ?           0:00 /usr/local/apache2/bin/httpd -k start -DSSL
nobody 23326 23319   0 13:39:02 ?           0:00 /usr/local/apache2/bin/httpd -k start -DSSL
nobody 23325 23319   0 13:39:02 ?           0:00 /usr/local/apache2/bin/httpd -k start -DSSL
nobody 23324 23319   0 13:39:02 ?           0:00 /usr/local/apache2/bin/httpd -k start -DSSL
[root@BOCUNOCDWB04:~]# pkill httpd
[root@BOCUNOCDWB04:~]# ps -ef |grep httpd
root 23357     1   0 13:39:22 ?           0:00 /usr/local/apache2/bin/httpd -k start -DSSL
nobody 23360 23351   0 13:39:22 ?           0:00 /usr/local/apache2/bin/httpd -k start -DSSL
root 23365 22786   0 13:39:22 pts/2       0:00 grep httpd
root 23351     1   2 13:39:20 ?           0:01 /usr/local/apache2/bin/httpd -k start -DSSL
nobody 23359 23351   0 13:39:22 ?           0:00 /usr/local/apache2/bin/httpd -k start -DSSL
nobody 23361 23351   0 13:39:22 ?           0:00 /usr/local/apache2/bin/httpd -k start -DSSL
nobody 23362 23351   0 13:39:22 ?           0:00 /usr/local/apache2/bin/httpd -k start -DSSL
nobody 23363 23351   0 13:39:22 ?           0:00 /usr/local/apache2/bin/httpd -k start -DSSL
[root@BOCUNOCDWB04:~]#

De la misma forma, si hay algún error al levantar el programa o el mismo se muere dejando algún error, el servicio es puesto en estado “maintenance”, para poder consultar posteriormente por qué no está corriendo.

[root@BOCUNOCDWB04:~]# svcs -xv network/http:apache2
svc:/network/http:apache2 (Apache 2 HTTP server)
State: maintenance since Mon 14 Jul 2008 01:37:39 PM COT
Reason: Start method failed repeatedly, last exited with status 1.
See: http://sun.com/msg/SMF-8000-KS
See: man -M /usr/apache2/man -s 8 httpd
See: /var/svc/log/network-http:apache2.log
Impact: This service is not running.
[root@BOCUNOCDWB04:~]#

Para configurar los servicios hay una consola a la que podemos acceder con svccfg.

[root@BOCUNOCDWB04:~]# svccfg
svc:> select network/http
svc:/network/http> select apache2
svc:/network/http:apache2> listprop
httpd                              application
httpd/stability                    astring  Evolving
httpd/ssl                          boolean  true
network                            dependency
network/entities                   fmri     svc:/milestone/network:default
network/grouping                   astring  require_all
network/restart_on                 astring  error
network/type                       astring  service
filesystem-local                   dependency
filesystem-local/entities          fmri     svc:/system/filesystem/local:default
filesystem-local/grouping          astring  require_all
filesystem-local/restart_on        astring  none
filesystem-local/type              astring  service
autofs                             dependency
autofs/entities                    fmri     svc:/system/filesystem/autofs:default
autofs/grouping                    astring  optional_all
autofs/restart_on                  astring  error
autofs/type                        astring  service
startd                             framework
startd/ignore_error                astring  core,signal
general                            framework
general/enabled                    boolean  true
start                              method
start/exec                         astring  “/lib/svc/method/http-apache2 start”
start/timeout_seconds              count    60
start/type                         astring  method
stop                               method
stop/exec                          astring  “/lib/svc/method/http-apache2 stop”
stop/timeout_seconds               count    60
stop/type                          astring  method
refresh                            method
refresh/exec                       astring  “/lib/svc/method/http-apache2 refresh”
refresh/timeout_seconds            count    60
refresh/type                       astring  method
restarter                          framework    NONPERSISTENT
restarter/transient_contract       count  restarter/logfile                  astring  /var/svc/log/network-http:apache2.log
restarter/contract                 count    299148
restarter/start_pid                count    23339
restarter/start_method_timestamp   time     1216060760.150109000
restarter/start_method_waitstatus  integer  0
restarter/auxiliary_state          astring  none
restarter/next_state               astring  none
restarter/state                    astring  online
restarter/state_timestamp          time     1216060760.155996000
restarter_actions                  framework    NONPERSISTENT
restarter_actions/restart          integer
restarter_actions/maint_off        integer
svc:/network/http:apache2>

La forma en que el daemon manejará los servicios se define en un script que tiene “métodos”, que serán invocados por el daemon. Estos scripts están en /lib/svc/methods, y el daemon los llama por ejemplo de esta forma:

/lib/svc/methods/http-apache2 start

Adentro el método consulta algunas variables del servicio y lo levanta. El script es muy similar a los de /etc/init.d.

Con svcs se listan los servicios.
Con svcs -l se puede ver el estado actual de un determinado servicio. Además podes se puede ver el proceso principal y sus hijos:

 % svcs -p network/smtp:sendmail    STATE          STIME    FMRI    online         18:20:30 svc:/network/smtp:sendmail     18:20:30      655 sendmail     18:20:30      657 sendmail

Y con svcs -x se puede ver por qué un determinado servicio falló.

Tiene muchas más cosas locas. Yo creo que debe tener alguna forma de controlar servicios remotos, porque cada servicio tiene una URI que llaman FMRI (Fault Managed Resource Identifier), que puede ser algo así:

  • svc://localhost/system/system-log:default
  • svc:/system/system-log:default
  • system/system-log:default

Y en la primera opción justamente se define una location que en ese caso es localhost, pero supongo que uno podría poner una IP.

También hay otras cosas locas para el manejo de los runlevels del SO. Podés definir milestones que, si no entendí mal, serían como runlevels custom para los cuales vos podés definir qué servicios corren.

Más información sobre SMF en el System Administration Guide de Solaris: http://docs.sun.com/app/docs/doc/817-1985

Particularmente en estos dos capítulos:
http://docs.sun.com/app/docs/doc/817-1985/hbrunlevels-25516?a=view
http://docs.sun.com/app/docs/doc/817-1985/faauf?a=view

16/07/2008: Editado: Dejo un cheat-sheet de  SMF: http://www2.petervg.nl/quick_reference/SolarisSMF.pdf