Clark's Home page

Tecnicismi vari di un Sysadmin Linux ma anche qualcosa della sua vita

Samba 4.15.3 su Devuan chimaera AD DC —

In questi giorni sto facendo il test per vedere come fare per cambiare samba sui server nuovi che installeremo il prossimo anno.
Sino al 2019 non mi preoccupavo più di tanto, siamo 44 gatti in ditta, quindi ad ogni cambio server e di conseguenza di versione SO e samba rigeneravo tutti gli utenti e i gruppi copiando pari pari le impostazioni dal vecchio server e buona notte ai suonatori.
Poi è arrivato Dynamics NAV in ditta come gestionale e li son cominciati i problemi, infatti il maledetto si mette da qualche parte il SID di ogni utente autorizzato all’uso e ovviamente se il SID cambia nonostante l’utente sia lo stesso lui non funziona, l’ho scoperto nel modo più doloroso possibile nell’agosto del 2019 durante la migrazione, quindi adesso sto preparandomi molto prima prima di avere altre sgradite sorprese.
In sostanza la situazione è la seguente,

Nuove macchine virtuali per fare AD DC e DC di supporto che avranno lo stesso IP delle vecchie ma SO attuale stable (Devuan 4) e Samba 4 al momento di questo documento 4.15.3 (in produzione c’è la 4.10.6) e nuova macchina virtuale che farà la condivisione di risorse, le tre macchine devono essere allineate come versione di samba.
I passi sono 4 e vale a dire

aggiornamento delle macchine a Devuan 4

eliminazione del vecchio codice

compilazione del samba

installazione del nuovo samba

Le macchine sono macchine virtuali da 30 GB ciascuna una urania è l’AD DC l’altra danaide e’ il DC aggiunto e sono entrambe con a bordo Devuan ascii, il primo passo è portarle a beowulf vale a dire dalla release 2 alla 3 quindi apt-get update apt-get dist-upgrade per avere l’ultima versione disponibile di ascii quindi modifica del sources list in beowulf e seguendo le indicazioni sul sito di Devuan apt-get dist-upgrade apt-get –purge autoremove apt-get autoclean e un reboot.
Cambio del sources list da beowulf a chimaera e sempre secondo le indicazioni sul sito aggiornamentoin due step apt-get update apt-get upgrade apt-get dist-upgrade apt-get –purge autoremove apt-get autoclean e le macchine sono pronte.

Fermando il demone samba entrare nella directory dei sorgenti vecchi e dare un make uninstall che elimina le librerie e quant’altro del samba vecchio, scaricare e scompattare in /usr/src/ samba 4.15.3 ./configure con le stesse opzioni del vecchio samba che si possono trovare nella directory dei sorgenti vecchi nel file .lock-wscript make e make install

Su urania samba-tool dbcheck –cross-ncs se dice che ci sono errori ripetere il comando aggiungendo –fix quindi una volta a posto /etc/init.d/samba-ac-dc start
smbstatus

Samba version 4.15.3
PID     Username     Group        Machine                                   Protocol Version  Encryption           Signing
—————————————————————————————————————————————-
27300   3000029      3000026      192.168.3.10 (ipv4:192.168.3.10:41486)    SMB3_11           –                    AES-128-CMAC
27500   3000102      3000026      192.168.2.1 (ipv4:192.168.2.1:49522)      SMB3_11           –                    AES-128-CMAC
8955    3000112      3000026      192.168.2.75 (ipv4:192.168.2.75:58985)    SMB3_11           –                    partial(AES-128-GMAC)
12494   3000202      3000026      192.168.2.159 (ipv4:192.168.2.159:59941)  SMB3_11           –                    AES-128-CMAC
27310   3000238      3000026      192.168.2.254 (ipv4:192.168.2.254:33836)  SMB3_11           –                    AES-128-CMAC

Service      pid     Machine       Connected at                     Encryption   Signing
———————————————————————————————
IPC$         27300   192.168.3.10  gio gen 13 04:08:37 2022 CET     –            AES-128-CMAC
IPC$         27500   192.168.2.1   gio gen 13 04:11:59 2022 CET     –            –
IPC$         8955    192.168.2.75  gio gen 13 09:21:30 2022 CET     –            AES-128-GMAC
IPC$         27310   192.168.2.254 gio gen 13 04:08:57 2022 CET     –            AES-128-CMAC
IPC$         12494   192.168.2.159 gio gen 13 10:31:47 2022 CET     –            AES-128-CMAC

No locked files

una situazione di questo tipo va bene, la prova del nove è fare login con un utenza e una macchina windows per vedere se il tutto funziona a dovere, vale a dire se il login avviene regolarmente, se le unita’ remote vengono mappate correttamente se le stampe vanno senza creare code.

Su danaide stessi passi per la configurazione e compilazione di samba, poi mv /usr/local/samba/etc/smb.conf smb.bak  cancellare da /usr/local/samba/private/ secrets.ldb e secrets.tdb  e quindi un

samba-tool domain join myfirm.local DC -U”MYFIRM\administrator”

INFO 2022-01-12 11:14:24,376 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/join.py #105: Finding a writeable DC for domain ‘myfirm.local’
INFO 2022-01-12 11:14:24,385 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/join.py #107: Found DC urania.myfirm.local
Password for [MYFIRM\administrator]:
INFO 2022-01-12 11:14:29,579 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/join.py #1527: workgroup is MYFIRM
INFO 2022-01-12 11:14:29,579 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/join.py #1530: realm is myfirm.local
Adding CN=DANAIDE,OU=Domain Controllers,DC=myfirm,DC=local
Adding CN=DANAIDE,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=myfirm,DC=local
Adding CN=NTDS Settings,CN=DANAIDE,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=myfirm,DC=local
Adding SPNs to CN=DANAIDE,OU=Domain Controllers,DC=myfirm,DC=local
Setting account password for DANAIDE$
Enabling account
Calling bare provision
INFO 2022-01-12 11:14:30,048 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/provision/__init__.py #2105: Looking up IPv4 addresses
INFO 2022-01-12 11:14:30,049 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/provision/__init__.py #2122: Looking up IPv6 addresses
WARNING 2022-01-12 11:14:30,050 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/provision/__init__.py #2129: No IPv6 address will be assigned
INFO 2022-01-12 11:14:30,205 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/provision/__init__.py #2275: Setting up secrets.ldb
INFO 2022-01-12 11:14:30,258 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/provision/__init__.py #2280: Setting up the registry
INFO 2022-01-12 11:14:30,294 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/provision/__init__.py #2283: Setting up the privileges database
INFO 2022-01-12 11:14:30,360 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/provision/__init__.py #2286: Setting up idmap db
INFO 2022-01-12 11:14:30,406 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/provision/__init__.py #2293: Setting up SAM db
INFO 2022-01-12 11:14:30,423 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/provision/__init__.py #880: Setting up sam.ldb partitions and settings
INFO 2022-01-12 11:14:30,426 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/provision/__init__.py #892: Setting up sam.ldb rootDSE
INFO 2022-01-12 11:14:30,436 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/provision/__init__.py #1305: Pre-loading the Samba 4 and AD schema
Unable to determine the DomainSID, can not enforce uniqueness constraint on local domainSIDs

INFO 2022-01-12 11:14:30,574 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/provision/__init__.py #2345: A Kerberos configuration suitable for Samba AD has been generated at /usr/local/samba/private/krb5.conf
INFO 2022-01-12 11:14:30,574 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/provision/__init__.py #2347: Merge the contents of this file with your system krb5.conf or replace it with this one. Do not create a symlink!
Provision OK for domain DN DC=myfirm,DC=local
Starting replication
Schema-DN[CN=Schema,CN=Configuration,DC=myfirm,DC=local] objects[402/1550] linked_values[0/0]
Schema-DN[CN=Schema,CN=Configuration,DC=myfirm,DC=local] objects[804/1550] linked_values[0/0]
Schema-DN[CN=Schema,CN=Configuration,DC=myfirm,DC=local] objects[1206/1550] linked_values[0/0]
Schema-DN[CN=Schema,CN=Configuration,DC=myfirm,DC=local] objects[1550/1550] linked_values[0/0]
Analyze and apply schema objects
Partition[CN=Configuration,DC=myfirm,DC=local] objects[402/1624] linked_values[0/1]
Partition[CN=Configuration,DC=myfirm,DC=local] objects[804/1624] linked_values[0/1]
Partition[CN=Configuration,DC=myfirm,DC=local] objects[1206/1624] linked_values[0/1]
Partition[CN=Configuration,DC=myfirm,DC=local] objects[1608/1624] linked_values[0/1]
Partition[CN=Configuration,DC=myfirm,DC=local] objects[1624/1624] linked_values[36/36]
Failed to commit objects: DOS code 0x000021bf
Missing target object – retrying with DRS_GET_TGT
Partition[CN=Configuration,DC=myfirm,DC=local] objects[2026/1624] linked_values[37/1]
Partition[CN=Configuration,DC=myfirm,DC=local] objects[2428/1624] linked_values[37/1]
Partition[CN=Configuration,DC=myfirm,DC=local] objects[2830/1624] linked_values[37/1]
Partition[CN=Configuration,DC=myfirm,DC=local] objects[3232/1624] linked_values[37/1]
Partition[CN=Configuration,DC=myfirm,DC=local] objects[3248/1624] linked_values[72/36]
Replicating critical objects from the base DN of the domain
Partition[DC=myfirm,DC=local] objects[97/97] linked_values[27/27]
Partition[DC=myfirm,DC=local] objects[402/509] linked_values[0/548]
Partition[DC=myfirm,DC=local] objects[509/509] linked_values[548/548]
../../lib/ldb/ldb_key_value/ldb_kv_index.c:2955: duplicate attribute value in CN=PC25,CN=Computers,DC=myfirm,DC=local for index on servicePrincipalName, duplicate of objectGUID 97a8a94e-9e88-4c6b-9e9e-52b2a35f1b24 in @INDEX:SERVICEPRINCIPALNAME:TERMSRV/PC25.MYFIRM.LOCAL
../../lib/ldb/ldb_key_value/ldb_kv_index.c:2955: duplicate attribute value in CN=PC68,CN=Computers,DC=myfirm,DC=local for index on servicePrincipalName, duplicate of objectGUID f128c15a-5cf2-4557-a5f9-0054909cf046 in @INDEX:SERVICEPRINCIPALNAME:TERMSRV/PC68.MYFIRM.LOCAL
Done with always replicated NC (base, config, schema)
Replicating DC=DomainDnsZones,DC=myfirm,DC=local
Partition[DC=DomainDnsZones,DC=myfirm,DC=local] objects[132/132] linked_values[0/0]
Replicating DC=ForestDnsZones,DC=myfirm,DC=local
Partition[DC=ForestDnsZones,DC=myfirm,DC=local] objects[19/19] linked_values[0/0]
Exop on[CN=RID Manager$,CN=System,DC=myfirm,DC=local] objects[3] linked_values[0]
Committing SAM database
Repacking database from v1 to v2 format (first record CN=ms-DFSR-FileFilter,CN=Schema,CN=Configuration,DC=myfirm,DC=local)
Repack: re-packed 10000 records so far
Repacking database from v1 to v2 format (first record CN=msCOM-Partition-Display,CN=804,CN=DisplaySpecifiers,CN=Configuration,DC=myfirm,DC=local)
Repacking database from v1 to v2 format (first record DC=PC16,DC=myfirm.local,CN=MicrosoftDNS,DC=DomainDnsZones,DC=myfirm,DC=local)
Repacking database from v1 to v2 format (first record DC=_msdcs.myfirm.local,CN=MicrosoftDNS,DC=ForestDnsZones,DC=myfirm,DC=local)
Repacking database from v1 to v2 format (first record CN=eos-users,CN=Users,DC=myfirm,DC=local)
INFO 2022-01-12 11:14:38,593 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/join.py #1100: Adding 1 remote DNS records for DANAIDE.myfirm.local
INFO 2022-01-12 11:14:38,685 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/join.py #1163: Adding DNS A record DANAIDE.myfirm.local for IPv4 IP: 192.168.2.228
INFO 2022-01-12 11:14:38,711 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/join.py #1191: Adding DNS CNAME record 0d02264e-39b7-44d7-81fd-5cc6c76529bb._msdcs.myfirm.local for DANAIDE.myfirm.local
INFO 2022-01-12 11:14:38,742 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/join.py #1216: All other DNS records (like _ldap SRV records) will be created samba_dnsupdate on first startup
INFO 2022-01-12 11:14:38,743 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/join.py #1222: Replicating new DNS records in DC=DomainDnsZones,DC=myfirm,DC=local
Partition[DC=DomainDnsZones,DC=myfirm,DC=local] objects[3/3] linked_values[0/0]
INFO 2022-01-12 11:14:38,780 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/join.py #1222: Replicating new DNS records in DC=ForestDnsZones,DC=myfirm,DC=local
Partition[DC=ForestDnsZones,DC=myfirm,DC=local] objects[2/2] linked_values[0/0]
INFO 2022-01-12 11:14:38,798 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/join.py #1237: Sending DsReplicaUpdateRefs for all the replicated partitions
INFO 2022-01-12 11:14:38,832 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/join.py #1267: Setting isSynchronized and dsServiceName
INFO 2022-01-12 11:14:38,850 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/join.py #1282: Setting up secrets database
INFO 2022-01-12 11:14:38,941 pid:3166 /usr/local/samba/lib/python3.9/site-packages/samba/join.py #1544: Joined domain MYFIRM (SID S-1-5-21-722562639-1834358410-470000291) as a DC

Verifichiamo che il joining abbia creato i record giusti

host -t A DANAIDE.myfirm.local
danaide.myfirm.local has address 192.168.2.228

ldbsearch -H /usr/local/samba/private/sam.ldb ‘(invocationId=*)’ –cross-ncs objectguid
# record 1
dn: CN=NTDS Settings,CN=DANAIDE,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=myfirm,DC=local
objectGUID: ab082391-d712-4aea-bef7-d3130a48dcc2

# record 2
dn: CN=NTDS Settings,CN=URANIA,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=myfirm,DC=local
objectGUID: d9ad3f1e-a3d0-48bf-8d69-1de4b667ed06

# returned 2 records
# 2 entries
# 0 referrals
host -t CNAME ab082391-d712-4aea-bef7-d3130a48dcc2._msdcs.myfirm.local.
ab082391-d712-4aea-bef7-d3130a48dcc2._msdcs.myfirm.local is an alias for DANAIDE.myfirm.local.
il tutto è andato a posto

Su  urania

tdbbackup -s .bak /usr/local/samba/private/idmap.ldb 
scp idmap.ldb.bak root@danaide:/usr/local/samba/private/

su danaide

mv /usr/local/samba/private/idmap.ldb.bak

/usr/local/samba/private/idmap.ldb

N.B.

come spiegato qui:
https://wiki.samba.org/index.php/Upgrading_a_Samba_AD_DC#Samba_AD_DC_Database_Check

una volta aggiornato il samba al riavvio questo NON parte, effettivamente la cosa non è chiarissima, perche dice anche di togliere prima la vecchia installazione, quindi la logica mi direbbe che il make uninstall pulisce tutto, evidentemente la mia logica non è quella degli sviluppatori di samba, per altro la cosa “buffa” è che se si lavora col samba pacchettizzato questo problema non c’è.

Ad ogni modo dopo diversi giorni e prove da manicomio con conseguenti mal di testa e di stomaco la soluzione è come quasi sempre la piiù semplice, e vale a dire una volta finito aggiungere in /etc/rc.local una riga con /etc/init.d/samba-ac-dc start
Al riavvio tutto gira a dovere.

 

 

 


Categorised as: Linux | Samba | Work

Comments are disabled on this post


Comments are closed.


Hide picture