Bepasty » Cronologia » Versione 1
Elena Grandi, 12-03-2020 13:54
| 1 | 1 | Elena Grandi | *attenzione, questa pagina è ancora gestita in un file salvato altrove, ed eventuali modifiche verranno perse al prossimo aggiornamento* |
|---|---|---|---|
| 2 | |||
| 3 | h1(#bepasty). Bepasty |
||
| 4 | |||
| 5 | "Bepasty":#bepasty-1 è un pastebin binario, ovvero un servizio che permette l'upload di file di vario formato e la loro successiva condivisione. |
||
| 6 | |||
| 7 | È scritto in python, e comunica con un server web tramite wsgi; per questa guida useremo apache e il relativo mod_wsgi. |
||
| 8 | |||
| 9 | h2(#installazione). Installazione |
||
| 10 | |||
| 11 | h3(#bepasty-1). Bepasty |
||
| 12 | |||
| 13 | Il pacchetto bepasty non è ancora disponibile su debian: nel frattempo lo si può prendere dall'archivio di truelite aggiungendo la seguente riga ad @/etc/apt/source.list@: |
||
| 14 | |||
| 15 | bc. deb http://archive.truelite.it/debian buster-truelite main |
||
| 16 | |||
| 17 | |||
| 18 | aggiungendo la chiave GPG con cui tale repository è firmato: |
||
| 19 | |||
| 20 | bc. # wget -qO - https://archive.truelite.it/apt.key | apt-key add - |
||
| 21 | |||
| 22 | |||
| 23 | e quindi aggiornando apt ed installando il pacchetto: |
||
| 24 | |||
| 25 | bc. # apt update |
||
| 26 | # apt install bepasty |
||
| 27 | |||
| 28 | |||
| 29 | È necessario quindi configurare bepasty creando il file @/etc/bepasty.conf@ con i seguenti contenuti: |
||
| 30 | |||
| 31 | <pre> |
||
| 32 | SITENAME="paste.example.org" |
||
| 33 | STORAGE="filesystem" |
||
| 34 | STORAGE_FILESYSTEM_DIRECTORY="/srv/bepasty/files/" |
||
| 35 | |||
| 36 | SECRET_KEY = '<a long string of random characters>' |
||
| 37 | DEFAULT_PERMISSIONS='admin,list,create,read,delete' |
||
| 38 | </pre> |
||
| 39 | |||
| 40 | In questo modo tutti gli utenti possono compiere qualunque azione, ed è consigliato solo nel caso in cui il sito stesso sia protetto da HTTPAuth; in alternativa si possono usare permessi come: |
||
| 41 | |||
| 42 | bc. DEFAULT_PERMISSIONS='read' |
||
| 43 | |||
| 44 | |||
| 45 | per permettere agli utenti non registrati la sola lettura di file esistenti, e limitare le altre operazioni ad utenti fidati; bepasty non supporta la creazione di utenti, ma associa un elenco di permessi a delle password, ad esempio: |
||
| 46 | |||
| 47 | bc. PERMISSIONS = { |
||
| 48 | # password per amministratori |
||
| 49 | 'correct horse battery staple': 'admin,list,create,read,delete', |
||
| 50 | # password per utenti semplici |
||
| 51 | 'chess observing leverage diocese': 'create,read', |
||
| 52 | } |
||
| 53 | |||
| 54 | |||
| 55 | Questo file dovrà essere letto dall'utente di apache (e contiene secrets, quindi è opportuno non sia letto dagli altri): |
||
| 56 | |||
| 57 | bc. chown root:www-data /etc/bepasty.conf |
||
| 58 | chmod 640 /etc/bepasty.conf |
||
| 59 | |||
| 60 | |||
| 61 | Similmente è necessario creare le directory per i file: |
||
| 62 | |||
| 63 | bc. mkdir -p /srv/bepasty/files |
||
| 64 | chown www-data:www-data /srv/bepasty/files |
||
| 65 | chmod 750 /srv/bepasty/files |
||
| 66 | |||
| 67 | |||
| 68 | h3(#apache). Apache |
||
| 69 | |||
| 70 | Per far caricare a bepasty il file di configurazione, è necessario passargli la variabile d'ambiente @BEPASTY_CONFIG=/etc/bepasty.conf@. |
||
| 71 | |||
| 72 | Il modo più comodo per farlo con apache è creare un file @.wsgi@, ad esempio in @/var/www/bepasty/bepasty.wsgi@ coi seguenti contenuti: |
||
| 73 | |||
| 74 | <pre> |
||
| 75 | import os |
||
| 76 | |||
| 77 | os.environ['BEPASTY_CONFIG'] = '/etc/bepasty.conf' |
||
| 78 | |||
| 79 | from bepasty.app import create_app |
||
| 80 | application = create_app() |
||
| 81 | </pre> |
||
| 82 | |||
| 83 | Quindi si può configurare apache per servire il dominio creando il file @/etc/apache2/sites-available/bepasty.conf@: |
||
| 84 | |||
| 85 | <pre> |
||
| 86 | <VirtualHost *:80> |
||
| 87 | DocumentRoot /var/www/bepasty |
||
| 88 | ServerName paste.example.org |
||
| 89 | ErrorLog /var/log/apache2/paste.example.org-error.log |
||
| 90 | CustomLog /var/log/apache2/paste.example.org-access.log combined |
||
| 91 | |||
| 92 | WSGIDaemonProcess bepasty user=bepasty group=bepasty threads=5 |
||
| 93 | WSGIScriptAlias / /var/www/bepasty/bepasty.wsgi |
||
| 94 | |||
| 95 | <Directory /var/www/bepasty> |
||
| 96 | WSGIProcessGroup bepasty |
||
| 97 | WSGIApplicationGroup %{GLOBAL} |
||
| 98 | Order deny,allow |
||
| 99 | Allow from all |
||
| 100 | </Directory> |
||
| 101 | </VirtualHost> |
||
| 102 | </pre> |
||
| 103 | |||
| 104 | e come di consueto abilitando il sito e facendo ricaricare la configurazione: |
||
| 105 | |||
| 106 | bc. # a2ensite bepasty |
||
| 107 | # service apache2 reload |