Friday, March 13, 2015

SmartOS zlogin Resource temporarily unavailable

Unable to perform zlogin to a SmartOS zone

[root@gz ~]# zlogin 461026ec-a298-4172-ba14-ca392b13e471
[Connected to zone '461026ec-a298-4172-ba14-ca392b13e471' pts/6]
malloc: Resource temporarily unavailable
ld.so.1: login: fatal: /lib/libc.so.1: Resource temporarily unavailable

[Connection to zone '461026ec-a298-4172-ba14-ca392b13e471' pts/6 closed]


Dmesg says

[root@gz ~]# dmesg

2015-03-13T08:56:29.246047+00:00 gz tmpfs: [ID 518458 kern.warning] WARNING: /zones/461026ec-a298-4172-ba14-ca392b13e471/root/etc/svc/volatile: File system full, swap space limit exceeded
2015-03-13T08:56:51.747916+00:00 gz genunix: [ID 470503 kern.warning] WARNING: Sorry, no swap space to grow stack for pid 14479 (zlogin)

Solution

[root@hcn4 ~]# vmadm update 461026ec-a298-4172-ba14-ca392b13e471 max_swap=4096

Thursday, March 12, 2015

Autenticazione Apache con la carta sanitaria Regione Toscana

E' stata una tribolazione: andare a tentoni richiede del tempo.

Utilizzare questo script https://gist.github.com/3v1n0/e371f58162795e0635f2 che fa quanto scritto nei commenti:
Get Italian government Certification Authority certificates from used by
by various National Service SmartCards (Carta Nazionale dei Servizi- CNS) 

mkdir /var/tmp/certs
./parse-gov-certs.py --output-folder /var/tmp/certs

Qui ci saranno vari certificati di Certification Authority di vari enti italiani usati per firmare i certificati di varie smart card, fra cui quelli utili al nostro scopo.

cd /var/tmp/certs
cat Regione_Toscana_-_CA_Cittadini_Servizi_di_Certificazione_* >> /etc/pki/tls/certs/ca-CNS-bundle.crt

In Apache, aprire il file ssl.conf (per esempio) e nel virtualhost opportuno mettere:

<VirtualHost _default_:443>
...

SSLCACertificateFile /etc/pki/tls/certs/ca-CNS-bundle.crt
...

</VirtualHost>

Non sono riuscito a far funzionare la direttiva SSLCACertificatePath, ovvero indicare una directory dove mettere i certificati scaricati con lo script Python.

E per richiedere la verifica del certificato del client (quindi il browser chiede il PIN della carta e passa il cerificato al server), mettere sempre all'interno della definizione del virtual host, o in qualche direttiva Location o Directory:

SSLVerifyClient require
SSLOptions +ExportCertData +StdEnvVars
SSLVerifyDepth 4


Questa è certamente una configurazione di base.
Il client viene autorizzato semplicemente se il certificato che presenta è stato firmato da una di queste CA. 
E' possibile autorizzare le carte in base a specifici attributi definiti con le direttive SSLRequire, e probabilmente configurare una CRL (Certificate Revocation List).

Thursday, March 5, 2015

Installing check_mk agent on a SmartOS global zone

The check_mk agent uses inetd (or xinetd).
On Solaris, and on SmartOS, inetd is a legacy facility.
In addition, on the SmartOS GZ, the stuff configured in the /etc directory doesn't survive to reboots, as you may know.

So, since I already use a method to set the hostname at boot time, as described in this blog https://nickebo.net/creating-a-custom-motd-in-the-smartos-global-zone/, I added a pair of lines in the postboot script.


echo "check_mk        6556/tcp" >> /etc/services
echo "check_mk stream tcp nowait root /usr/sbin/tcpd /opt/custom/bin/check_mk_agent" >> /etc/inet/inetd.conf
inetconv
inetconv -e



Then download the check_mk solaris agent from github and put it in the /opt/custom/bin/ directory.


Obviously, if you don't want to reboot the GZ, but enable the service right now, issue the same commands as above.

Remember to change the MK_LIBDIR and the MK_CONFDIR variables in the /opt/custom/bin/check_mk_agent script in order to use additional plugins or configurations.