Il Blog di Fabrizio Mondo

Configurazione di Gnump3d su Linux, Security and Authorisation Options

novembre 12, 2007 1:39 pm

Manette di sicurezza
Quarantacinquesimo articolo dedicato alle web radio.

Riprendiamo lo studio del file gnump3d.conf, passando alle opzioni di sicurezza.

# If there is a user value setup below then the server will become that
# user, after creating the listening socket and after opening the logfiles
# for writing.
#
# If you want to run this server via init.d, (which has the effect of
# starting the daemon as root), you should make sure you have this set
# to an appropriate value.
# Otherwise you will have the server running as root, which is clearly
# not a good idea – even in the unlikely event that this application is
# 100% bug free.
#
# You may comment the line out if you are running the daemon from your home
# directory, and you are the only user with read access to the server root.
# Although this is not recommended way of running the server.
#
# For the benefit of fellow computer users is recommended that you run the
# server as a user such as ‘nobody’, and allow people read-only access to
# your audio files.
#
user = gnump3d

In questa opzione si setta quale user diventerà il server al momento in cui verrà creata la socket e i file di log. Sebbene Steve consigli di non utilizzare il server come root, non c’è da preoccuparsi. Per i nostri scopi, con la dovuta oculatezza, agire da root non causa nessun problema. Per questo motivo è bene lasciare questa riga esattamente com’è. Si può commentare soltanto se l’utente che utilizzerà il server è l’unico user con privilegi di lettura alla directory radice del server. Un modo non proprio ortodosso di utilizzare il server, ma fattibile.

# The following section allows you to specify which clients
# are allowed to connect to your server.
#
# If you are leaving this server out on an Internet-accessible
# machine then you will probably want to setup something here,
# or at least make use of the password protection system.
#
# The following entries are commented out, so they have no effect,
# but they should serve as good examples of the things which
# are possible.

La seguente sezione, permette di specificare quali clients hanno i permessi per connettersi al server. Sono tutte opzioni commentate, che servono da esempio, ma è opportuno considerare il loro utilizzo e il loro settaggio ai fini della realizzazione di un server accessibile da internet, che è il nostro obiettivo.

Estrapoliamo le righe che mostrano le varie possibilità e commentiamole.

allowed_clients = 192.168.2.0/8

Da i permessi a tutta la rete locale, ovvero tutti gli indirizzi da 192.168.2.0 a 192.168.2.255

allowed_clients = 10.0.0.0/16

Da i permessi a tutta la rete di classe B, ovvero tutti gli indirizzi da 10.0.0.0 a 10.0.255.255

allowed_clients = 192.168.2.12

Da i permessi ad un singolo client

allowed_clients = none

Non da i permessi a nessuno!

allowed_clients = 192.168.2.0/8; 194.247.82.33

Da i permessi sia alla rete locale di classe C (vedi sopra) che al client 194.247.82.33

allowed_clients = 192.168.2.0/8; 194.237.82.0/8

Da i permessi a due sottoreti.

allowed_clients = all

Da il permesso a tutti.

La scelta tocca a chi configura, in base alle esigenze. Senza incollare testo inutile, l’impostazione successiva permette di impedire l’accesso ad altri utenti, è pedissequa all’opzione allowed, anzi è proprio la sua opzione speculare, e si setta come essa stessa.

##
#
# This section controls whether we will prompt clients for
# a username and password prior to granting access to the
# server.
#
# This is enabled by default; all you need to do is create
# a password file in the MP3 directory called ‘.password’.
#
# (To disable this uncomment the ‘enable_password_protection’ line).
#
# The password file should be of the following format:
#
# username:password
# username2:password2
# …:….
# usernameN:passwordN
#
# OR, for Digest authentification, the password file should be of
# the following format:
#
# username:hash
# username2:hash2
#
# hash or hash2 represent MD5(login:GNUMP3d:password)
# To generate an hash string, type:
# $> echo -n ‘username:GNUMP3d:password’ | md5sum
#
# NOTE
# —-
#
# The password file must be readable to the user the server is running
# as.
#
###
# enable_password_protection = 0
# authentication_type = Basic # Basic or Digest
###

Gnump3d predispone, di default, di un meccanismo di sicurezza attivo, ma latente. E’ possibile impostare una password ed un username, per potere entrare e utilizzare il server. Per fare questo, è sufficiente creare, nella directory dei media files, un file nascosto chiamato .password che conterrà al suo interno una serie di righe, nella forma:

username:password

O, se preferite (e sarebbe anche meglio) potete utilizzare i meccanismi di Digest authentication, che permette al server di identificare e validare password ottenute tramite MD5. Esse devono essere nella forma:

username:hash

dove hash è il risultato di un MD5(login:GNUMP3d:password).

Un buon modo per calcolare la password è usare questi comandi BASH:

echo -n ‘username:GNUMP3d:password’ | md5sum

come del resto già scritto da Steve.

E’ chiaro che il file delle password deve essere leggibile da parte dell’utente che ha intenzione di usufruire del server gnump3d.

Decommentando la riga

# enable_password_protection = 0

si disabilità il meccanismo di protezione, e il file .password, anche se esistente diventerebbe inutile.

Decommentando invece la riga

# authentication_type = Basic # Basic or Digest

si può scegliere quale delle due modalità di autenticazione utilizzare, Basic o Digest, in base alle preferenze.

# Referrer check
#
##
#
# The last security option is the ability to block clients that don’t
# contain a specific ‘Referrer:’ header.
#
# Note that referrer protection isn’t terribly reliable, as many clients
# will not send a referrer header when making a connection. This is
# especially likely when clients are connecting via a ‘privacy enhancing’
# proxy server; such as Internet Junkbuster, etc.
#
# Similarly malicious clients may deliberately stop sending referrers
# if they realise what is going on.
#
#
#
###
# If you wish to only allow a particular referring URL then specify it
# here.
# valid_referrers = http://somesite.com/

Questa opzione permette di bloccare i clients che non hanno un header contenente un particolare referrer, ovvero che non provengono da un altro sito. Tale opzione non è proprio il massimo della sicurezza, ed è facile capirlo dal fatto che non tutti i client necessariamente inviano referrer, come ad esempio nel caso in cui ci si connetta tramite un server proxy come Internet JunkBuster.

Senza considerare il fatto che si può anche evitare di mandare i referrrer anche a comando, il che rende l’opzione sicura come mettere un cartello “non calpestare le aiuole”

Per abilitare comunque quest’opzione, basta decommentare la riga valid_referrers e impostare l’url preferito.

No Responses to “Configurazione di Gnump3d su Linux, Security and Authorisation Options”

Care to comment?