User Tools

Site Tools


doc:appunti:linux:sa:nis

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
doc:appunti:linux:sa:nis [2020/12/16 12:58] – [NIS users unable to poweroff/reboot or manage printers] niccolodoc:appunti:linux:sa:nis [2020/12/16 16:27] (current) niccolo
Line 1: Line 1:
-====== Installazione NIS server ======+====== Network Information Service ======
  
-Installato il pacchetto **nis**, si è specificato come nome di dominio il dominio DNS dell'host, in questo esempio **mydomain.org**. Viene salvato in ''**/etc/defaultdomain**'' (vedi avanti come cambiarlo).+Pages relate to **[[wp>Network_Information_Service]]**.
  
-Fare attenzione al contenuto dei seguenti file: +  * **[[nis_server]]** 
- +  * **[[nis_user_shutdown_problem]]**
-  * **/etc/defaultdomain** +
-  * **/etc/default/nis** +
-  * **/etc/hosts** +
-  * **/etc/ypserv.securenets** +
- +
-Conviene che in **''/etc/hosts''** i nomi dei server NIS siano presenti sia nella versione breve che in quella completa, qualcosa del tipo: +
- +
-<file> +
-127.0.0.1       localhost.localdomain localhost +
-10.0.1.47       nisserver.mydomain.org nisserver +
-</file> +
- +
-Poiché vogliamo essere **NIS master server**, in ''**/etc/default/nis**'' si imposta +
-<file> +
-NISSERVER=master +
-</file> +
- +
-Per decidere chi ha accesso al server NIS si mette in ''**/etc/ypserv.securenets**'' una riga come segue (commentando la riga che garantisce accesso a tutti): +
- +
-<file> +
-255.255.255.0 10.0.1.0 +
-</file> +
- +
-**NOTA:** se il server NIS ha più di una interfaccia di rete e si vuole rispondere a richieste broadcast da parte dei client, è opportuno aggiungere in ''**/etc/ypserv.securenets**'' anche tutti gli indirizzi alternativi del server NIS, oltre all'indirizzo loopback: +
- +
-<file> +
-# Always allow access for localhost +
-255.0.0.0       127.0.0.0 +
- +
-# Allow access from localhost (when proxying broadcast requests?+
-# See Debian bugs: +
-# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=280537 +
-# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=126177 +
-# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=329382 +
-255.255.255.255 192.168.144.2 +
-</file> +
- +
-infatti pare che ''ypserv'' - in risposta ad una richiesta broadcast di un client - inoltri a sé stesso una richiesta broadcast utilizzando l'indirizzo IP aggiuntivo che non è nelle securenets, facendo fallire la richiesta del client e generando questo errore in syslog: +
- +
-<code> +
-ypserv[9960]: refused connect from 192.168.144.2:46594 to procedure ypproc_domain_nonack (mydomain.org,;0) +
-</code> +
- +
-Bisogna **inizializzare il database** del dominio NIS, che verrà tenuto nella directory **''/var/yp/mydomain.org/''**. Si usa il comando +
- +
-<code> +
-/usr/lib/yp/ypinit -m +
-</code> +
- +
-Per testare il corretto funzionamento del server si può usare il comando ''**ypcat passwd**''. Mostra tutte le voci del database "passwd" presente nel server NIS. Quali database ci sono sul server NIS lo si vede dal file ''/var/yp/nicknames''. Per es. le shadow password si vedono con **''ypcat shadow.byname''**. +
- +
-Per modificare il nome del dominio NIS da //mydomain.org// a //newdomain.org//: +
- +
-<code> +
-/etc/init.d/nis stop +
-vi /etc/defaultdomain +
-rm -r /var/yp/mydomain.org +
-domainname newdomain.org +
-/usr/lib/yp/ypinit -m +
-/etc/init.d/nis start +
-</code> +
- +
-====== Utenti NIS separati da quelli di sistema ====== +
- +
-Invece di usare i file in **''/etc/''** (passwd, group, ...), si vogliono usare delle copie in **''/var/yp/ypfiles''**. Modificare ''**/var/yp/Makefile**'': +
- +
-<file> +
-YPSRCDIR = /var/yp/ypfiles +
-YPPWDDIR = /var/yp/ypfiles +
-</file> +
- +
-Si deve editare anche **''/etc/default/nis''**: +
- +
-<file> +
-YPPWDDIR=/var/yp/ypfiles +
-</file> +
- +
-Per fare in modo che **ypinit** riesca a generare i database necessari bisogna creare i seguenti file nella directory **/var/yp/ypfiles/**: +
- +
-^ group      | Inizialmente vuoto. +
-^ hosts      | Contiene almeno una riga per 127.0.0.1 localhost. +
-^ netgroup   | Copiato da ''/etc/netgroup''+
-^ passwd     | Inizialmente vuoto. +
-^ protocols  | Copiato da ''/etc/protocols''+
-^ rpc        | Copiato da ''/etc/rpc''+
-^ services   | Copiato da ''/etc/services''+
-^ shadow     | Inizialmente vuoto. +
- +
-Dopo aver modificato il contenuto di tali file bisogno aggiornare lo stato del server NIS: +
- +
-<code> +
-make -C /var/yp +
-</code> +
- +
-Per far partecipare gli utenti NIS a gruppi di sistema (ad esempio plugdev, lpadmin, ecc. di Ubuntu) bisogna aggiungere le voci opportune in **''/var/yp/ypfiles/group''** e modificare il valore di **''MINGID''** in ''/var/yp/Makefile'' in modo che tali gruppi siano esportati via NIS. +
-====== NIS client ====== +
- +
-Si installa il pacchetto **nis**. Chiunque voglia essere NIS client (eventualmente anche il NIS server stesso) deve impostare **''NISCLIENT=true''** nel file **''/etc/default/nis''**. +
- +
-===== Name Service Switch ===== +
- +
-La **GNU C Library** fornisce i servizi ad esempio per avere l'elenco degli utenti. Bisogna **integrare** gli utenti standard **Unix** con quelli **NIS**, il file di configurazione da verificare è **/etc/nsswitch.conf**. +
- +
-=== Integrazione in modalità "compat" === +
- +
-Per integrare gli utenti e i gruppi NIS in quelli standard unix si devono modificare i file **''/etc/passwd''**, **''/etc/shadow''** e **''/etc/group''** aggiungendo le seguenti righe rispettivamente: +
- +
-<code>+::::::</code> +
-<code>+::::::::</code> +
-<code>+:::</code> +
- +
-Verificare nel file **/etc/nsswitch.conf** che i servizi **passwd**, **group**, e **shadow** includano la sorgente **compat**, che significa utilizzare la sorgente **files** (i tradizionali file Unix ''/etc/passwd'', ecc) con l'estensione NIS dovuta alle righe aggiuntive vista sopra. +
- +
-=== Integrazione in modalità "nis" === +
- +
-In alternativa si può indicare in **/etc/nsswitch.conf** la sorgente **files** ed esplicitamente la sorgente **nis**, in questo caso le righe aggiuntive con il prefisso **+** non sono necessarie. In questo caso il file **/etc/nsswitch.conf** contiene qualcosa del genere: +
- +
-<file> +
-passwd:         files systemd nis +
-group:          files systemd nis +
-shadow:         files nis +
-</file> +
- +
-:!: **ATTENZIONE**: Questa modalità non è compatibile con il demone **accountsservice** utilizzato ad esempio da **Ubuntu 20.4**. In questo caso l'elenco degli utenti non viene integrato con le informazioni NIS e quindi **gli utenti NIS non vengono elencati** nel greeter di **LightDM**. +
- +
-===== Ricerca del server NIS ===== +
- +
-La ricerca del NIS server avviene tramite richieste broadcast sulla rete locale. Per evitarle (potrebbero fallire per regole di firewall) si dichiarano esplicitamente i server in **''/etc/yp.conf''**: +
- +
-<file> +
-# We states NIS servers explicitly to avoid broadcast requests. +
-ypserver bianca.rigacci.org +
-ypserver neve.rigacci.org +
-</file> +
- +
-Un altro motivo per cui la **richiesta broadcast potrebbe fallire** è se il server NIS è **multihomed** (ha più di una interfaccia di rete), vedi la nota sopra riguardo ''ypserv.securenets''+
- +
-L'utente autenticato via NIS può cambiare la propria password con **''yppasswd''**. Durante il cambio password **il server NIS indica al client il nome dello stesso server**, quindi il client deve poterlo **risolvere in indirizzo IP**. Verificare le opportune impostazioni di **/etc/hosts**, ecc. +
-====== NIS slave server ====== +
- +
-Configurare l'host che dovrà essere **slave server** come se fosse un NIS client, quindi mettere in **''/etc/default/nis''** la riga **''NISSERVER=slave''**. +
- +
-Sul **master** modificare **''/var/yp/Makefile''** mettendo **''NOPUSH="false"''**, quindi eseguire **''/usr/lib/yp/ypinit -m''**.  +
- +
-Riavviare NIS sullo slave ed eseguire **''/usr/lib/yp/ypinit -s <master_server>''** per trasferire il contenuto dei file. +
- +
-Le repliche dovrebbero avvenire automaticamente dal master allo slave. Nel caso qualcosa vada storto è opportuno configurare un **cron job** sullo **slave** come suggerito dal file nis.debian.howto: +
- +
-<file> +
-20 *    * * *    root  /usr/lib/yp/ypxfr_1perhour >/dev/null 2>&+
-40 6    * * *    root  /usr/lib/yp/ypxfr_1perday  >/dev/null 2>&+
-55 6,18 * * *    root  /usr/lib/yp/ypxfr_2perday  >/dev/null 2>&+
-</file> +
- +
-====== Firewall ====== +
- +
-Se il server NIS è protetto da firewall che filtra in base al numero di porta si deve avere l'accortezza di impostare i vari server su porte predefinite (non su porte dinamiche come sarebbe l'impostazione predefinita) ed aprire di conseguenza il firewall. Come per il servizio NFS la gestione delle porte è affidata a **portmapper**, vedere in proposito la [[nfs|pagina relativa]]+
- +
-In particolare si devono indicare le porte per **ypserv**, **yppasswdd**, FIXME ypbind, fypxfrd. +
- +
-In un sistema Debian vedere **''/etc/default/nis''**: +
- +
-<file> +
-YPSERVARGS="--port 808" +
-YPPASSWDDARGS="--port 600" +
-</file> +
- +
-====== Directory home su NFS ====== +
- +
-Attenzione al percorso delle home directory, se si sceglie qualcosa di diverso da **''/home/''** potrebbe essere necessario aggiustare qualcosa, come la configurazione di **''apparmor''** nelle recenti versioni Ubuntu GNU/Linux (es. 12.04). +
- +
-Il rischio è di incappare in errori "Permission denied" nella lettura o scrittura di file della propria home directory, nonostante che i permessi sembrino a posto, vedere ad esempio il [[https://bugs.launchpad.net/ubuntu/+source/evince/+bug/778638|bug 778638]]. +
- +
-Ad esempio se le home directory sono state montate su **''/nfshome/''**, lanciando **''evince''** si può notare l'errore: +
- +
-<code> +
-(evince:21345): Gtk-WARNING **: Attempting to read the recently used resources file at +
-    `/nfshome/francesco/.local/share/recently-used.xbel', +
-    but the parser failed: Failed to open file '/nfshome/francesco/.local/share/recently-used.xbel': Permission denied. +
-</code> +
- +
-contestualmente il kernel logga: +
- +
-<code> +
-Jan  9 11:35:02 nisclient kernel: [ 5422.898561] type=1400 audit(1357727702.213:1085): +
-    apparmor="DENIED" operation="chmod" parent=12077 profile="/usr/bin/evince" +
-    name="/nfshome/francesco/.local/share/recently-used.xbel" pid=12470 comm="evince" +
-    requested_mask="w" denied_mask="w" fsuid=1003 ouid=1003 +
-</code> +
- +
-In questo caso è sufficiente modificare il file **''/etc/apparmor.d/tunables/home''** impostando: +
- +
-<file> +
-@{HOMEDIRS}=/home/ /nfshome/ +
-</file> +
- +
-====== Login Time Too Long in Ubuntu 18.04 ====== +
- +
-After installing an **Ubuntu 18.04 as a NIS client** with home directories mounted over NFS, we noticed very long times required to complete the login. Even on the tty1 console, there was a **wait time of about 25 seconds** after typing the passowrd, before to get the command line prompt. +
- +
-The only apparent error message found in the **syslog** was: +
- +
-<code> +
-systemd-logind[2133]: do_ypcall: clnt_call: RPC: Unable to send; errno = Operation not permitted +
-</code> +
- +
-A nice solution was to **install the nscd package**. The complete story was a bit more complicated, the right direction was found in the following posts:  +
- +
-  * **[[https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1774417|systemd-logind: do_ypcall: clnt_call: RPC: Unable to send; errno = Operation not permitted]]** +
-  * **[[https://github.com/systemd/systemd/issues/7074|systemd-logind's IP sandbox breaks nss-nis and suchlike #7074]]** +
- +
-One user pointed out that the bug affects also what is reported in **/run/user/**, where the NIS user logged-in (after the long wait) was missing. Other users suggested to edit the file **/lib/systemd/system/systemd-logind.service**, commentig-out a line from the **[Service]** section: +
- +
-<code> +
-IPAddressDeny=any +
-</code> +
- +
-====== NIS users unable to poweroff/reboot or manage printers ====== +
- +
-We experienced a problem with an **Ubuntu 20.04** Focal Fossa used as **NIS client**: some tasks were inhibited because the user - despite it was **logged-in locally** on the physical machine - it was considered **as a remote** one. +
- +
-FIXME What the errors? +
- +
-It turned out that the **[[https://wiki.debian.org/PolicyKit|PolicyKit]]** authorization manager is enabled, according to the default policies that problematic tasks are reserved to **local users** only, whereas users **authenticated by the NIS** server are considered somehow remote. +
- +
-One solution is to create a file on the NIS client, name **/var/lib/polkit-1/localauthority/50-local.d/10-nis-users.pkla**. The ''/var/lib/polkit-1/localauthority/'' directory is intended for 3rd party packages, the ''50-local.d'' subdirectory is intended for local usage. +
- +
-<file> +
-[Allow Printer administration for NIS users] +
-Identity=unix-group:lpadmin;unix-group:adm +
-Action=org.opensuse.cupspkhelper.mechanism.* +
-ResultAny=yes +
- +
-[Allow halt power-off and reboot for NIS users] +
-Identity=unix-group:adm +
-Action=org.freedesktop.login1.halt*;org.freedesktop.login1.power-off*;org.freedesktop.login1.reboot* +
-ResultAny=yes +
-</file> +
- +
-The syntax of the file is explained into the **[[https://www.freedesktop.org/software/polkit/docs/0.105/pklocalauthority.8.html|pklocalauthority man page]]**. +
- +
-First of all usint the **Identity** option we select the users interested into that policy. For managing printers we required the user to belong to the **lpadmin** and **adm** groups. The first group is the standard Debian group to manage printers, whereas the **adm** group is an arbitrary group assigned to some users by the NIS server (see the page **[[https://wiki.debian.org/SystemGroups|Debian system groups]]**). +
- +
-For the **Action** part we had to discover the name of the printer management and the poweroff/halt/reboot. You can use the **pkaction** command and browse its output; also searching on the Net is a big resource. The **org.opensuse.cupspkhelper.mechanism.** is OpenSUSE and Ubuntu specific (I don't have it in my Debian box): +
- +
-<code> +
-pkaction | grep cupspkhelper +
-org.opensuse.cupspkhelper.mechanism.all-edit +
-org.opensuse.cupspkhelper.mechanism.class-edit +
-org.opensuse.cupspkhelper.mechanism.devices-get +
-org.opensuse.cupspkhelper.mechanism.job-edit +
-org.opensuse.cupspkhelper.mechanism.job-not-owned-edit +
-org.opensuse.cupspkhelper.mechanism.printer-enable +
-org.opensuse.cupspkhelper.mechanism.printer-local-edit +
-org.opensuse.cupspkhelper.mechanism.printer-remote-edit +
-org.opensuse.cupspkhelper.mechanism.printer-set-default +
-org.opensuse.cupspkhelper.mechanism.printeraddremove +
-org.opensuse.cupspkhelper.mechanism.server-settings +
-</code> +
- +
-For the reboot/poweroff/halt etc we have the following PolKit nodes: +
- +
-<code> +
-org.freedesktop.login1.halt +
-org.freedesktop.login1.hibernate +
-org.freedesktop.login1.power-off +
-org.freedesktop.login1.reboot +
-org.freedesktop.login1.suspend +
-</code> +
- +
-each of them have some sub-actions: +
- +
-<code> +
-pkaction | grep org.freedesktop.login1.power-off +
-org.freedesktop.login1.power-off +
-org.freedesktop.login1.power-off-ignore-inhibit +
-org.freedesktop.login1.power-off-multiple-sessions +
-</code> +
- +
-Finally the problem-solving option is **ResultAny**, which means that the policy is applicable for users logged-in in any status. The default policy is instead something like this: +
- +
-<code> +
-ResultAny=no +
-ResultInactive=no +
-ResultActive=yes +
-</code>+
doc/appunti/linux/sa/nis.1608119902.txt.gz · Last modified: 2020/12/16 12:58 by niccolo