Disallow removing SOA record

This commit is contained in:
nemunaire 2020-06-14 23:12:42 +02:00
parent 4a19149b51
commit 35fbb1625e
2 changed files with 5 additions and 1 deletions

View File

@ -74,7 +74,7 @@
<b-icon icon="check" />
Save those modifications
</b-button>
<b-button type="button" size="sm" variant="outline-danger" class="mx-1" @click="deleteObject()">
<b-button v-if="type !== 'svcs.Origin'" type="button" size="sm" variant="outline-danger" class="mx-1" @click="deleteObject()">
<b-icon icon="trash" />
Delete
</b-button>

View File

@ -78,6 +78,10 @@ func (z *Zone) EraseService(subdomain string, origin string, id []byte, s *Servi
for k, svc := range services {
if bytes.Equal(svc.Id, id) {
if s == nil {
// Disallow removing SOA
if subdomain == "" && svc.Type == "svcs.Origin" {
return errors.New("You cannot delete this service. It is mandatory.")
}
z.Services[subdomain] = append(z.Services[subdomain][:k], z.Services[subdomain][k+1:]...)
} else {
s.Comment = s.GenComment(origin)