home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1999 March B
/
SCO_CASTOR4RRT.iso
/
inet
/
root.2
/
usr
/
lib
/
scoadmin
/
netosa
/
dnsOsa
/
dnsOsa~
Wrap
Text File
|
1998-08-19
|
123KB
|
4,721 lines
# Copyright (c) 1992-1998 The Santa Cruz Operation, Inc.. All Rights Reserved.
#
# THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF THE
# SANTA CRUZ OPERATION INC.
#
# The copyright notice above does not evidence any actual or intended
# publication of such source code.
#******************************************************************************
#
# Copyright (C) 1992-1998 The Santa Cruz Operation, Inc.
# All Rights Reserved.
#
# The information in this file is provided for the exclusive use of
# the licensees of The Santa Cruz Operation, Inc. Such users have the
# right to use, modify, and incorporate this code into other products
# for purposes authorized by the license agreement provided they include
# this notice and the associated copyright notice with any such product.
# The information in this file is provided "AS IS" without warranty.
#
#===============================================================================
#@package: SCO_DNSOSA_MSGS SCO_DNSOSA_MSGS
proc SCO_DNSOSA_MSGS {} {}
global SCO_DNSOSA_MSGS
set SCO_DNSOSA_MSGS(@catalog@) {dnsOsa.cat@sa 1}
set SCO_DNSOSA_MSGS(MSG_HELPBOOK) {1 NetAdminG}
set SCO_DNSOSA_MSGS(ERR_UNIX) {2 %s}
set SCO_DNSOSA_MSGS(ERR_ATTRIBUTE) {3 {Attribute %1$s must be specified for operation %2$s}}
set SCO_DNSOSA_MSGS(ERR_FMT_BAD_LINE) {4 {file format: %1$s: bad line %2$s}}
set SCO_DNSOSA_MSGS(ERR_FMT_BAD_DIR) {5 {file format: bad directory %s}}
set SCO_DNSOSA_MSGS(ERR_FMT_BAD_CACHE) {6 {file format: bad cache line %s}}
set SCO_DNSOSA_MSGS(ERR_MV) {7 {could not move %1$s to %2$s}}
set SCO_DNSOSA_MSGS(ERR_CP) {8 {could not copy %1$s to %2$s}}
set SCO_DNSOSA_MSGS(ERR_ILLEGAL) {9 {%1$s: bad index %2$s}}
set SCO_DNSOSA_MSGS(ERR_BAD_ADDR) {10 { bad address %s}}
set SCO_DNSOSA_MSGS(ERR_NO_CACHE) {11 {no cache defined in named.boot}}
set SCO_DNSOSA_MSGS(ERR_OPEN_WR) {12 {cannot open write to file %s}}
set SCO_DNSOSA_MSGS(ERR_OPEN_RD) {13 {cannot open read from file %s}}
set SCO_DNSOSA_MSGS(ERR_MULT_SOA) {14 {%s: multiple SOA records!}}
set SCO_DNSOSA_MSGS(ERR_BAD_SOA) {15 {%s: bad SOA record}}
set SCO_DNSOSA_MSGS(ERR_BAD_LINE) {16 {bad line %s}}
set SCO_DNSOSA_MSGS(ERR_RM_LAST_ADDR) {17 {%s: cannot remove last address}}
set SCO_DNSOSA_MSGS(ERR_NO_ADDR) {18 {no address %1$s for %2$s}}
set SCO_DNSOSA_MSGS(ERR_NO_ALIAS) {19 {no alias %1$s for %2$s}}
set SCO_DNSOSA_MSGS(ERR_NO_MX) {20 {no mx record %1$s for %2$s}}
set SCO_DNSOSA_MSGS(ERR_NO_RP) {21 {no rp record %1$s for %2$s}}
set SCO_DNSOSA_MSGS(ERR_NO_TXT) {22 {no txt record %1$s for %2$s}}
set SCO_DNSOSA_MSGS(ERR_NO_HINFO) {23 {no hinfo record %1$s for %2$s}}
set SCO_DNSOSA_MSGS(ERR_HOSTS) {24 {hosts file supports one address per entry}}
set SCO_DNSOSA_MSGS(ERR_NO_HOST) {25 {host was not specified}}
set SCO_DNSOSA_MSGS(ERR_FILE) {26 {no such file %s}}
set SCO_DNSOSA_MSGS(ERR_DOMAIN) {27 {no such domain %s}}
set SCO_DNSOSA_MSGS(ERR_INVALID_ATTR) {28 {invalid naming attribute: %s}}
set SCO_DNSOSA_MSGS(ERR_BAD_VAL) {29 {bad value %1$s for parameter %2$s}}
set SCO_DNSOSA_MSGS(ERR_NO_PARAM) {30 {missing required parameter %s}}
set SCO_DNSOSA_MSGS(ERR_SCOPE) {31 {scope type $s is not supported}}
set SCO_DNSOSA_MSGS(MSG_TIME) {32 {year week day hour minute second}}
set SCO_DNSOSA_MSGS(MSG_TIMES) {33 {years weeks days hours minutes seconds}}
set sco_hostTabEntry_CDT(attributes) {
{
name
{
{ validOperations {get} }
{ validFilters {} }
{ dataType {single} }
}
}
{
aliasList
{
{ validOperations {get add remove replace} }
{ validFilters {} }
{ dataType {set} }
}
}
{
addrList
{
{ validOperations {get add remove replace} }
{ validFilters {} }
{ dataType {set} }
}
}
{
comment
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType {single} }
}
}
{
mxList
{
{ validOperations {get replace add remove} }
{ validFilters {} }
{ dataType set }
{ description {list of MX records per host} }
}
}
{
rpList
{
{ validOperations {get replace add remove} }
{ validFilters {} }
{ dataType set }
{ description {list of RP records per host} }
}
}
{
txtList
{
{ validOperations {get replace add remove} }
{ validFilters {} }
{ dataType set }
{ description {list of TXT records per host} }
}
}
{
hinfoList
{
{ validOperations {get replace add remove} }
{ validFilters {} }
{ dataType set }
{ description {list of HINFO records per host} }
}
}
}
set sco_hostTabEntry_CDT(groups) {}
set sco_hostTabEntry_CDT(operations) {
{
get
{
{ function {hostTabEntry_get} }
{ granularity {perAttribute} }
}
}
{
replace
{
{ function {hostTabEntry_replace} }
{ granularity {perAttribute} }
}
}
{
add
{
{ function {hostTabEntry_add} }
{ granularity {perAttribute} }
}
}
{
remove
{
{ function {hostTabEntry_remove} }
{ granularity {perAttribute} }
}
}
{
create
{
{ function {hostTabEntry_create} }
{ granularity {perObject} }
}
}
{
delete
{
{ function {hostTabEntry_delete} }
{ granularity {perObject} }
}
}
{
list
{
{ function {hostTabEntry_list} }
{ granularity {perObject} }
}
}
}
set sco_hostTabEntry_CDT(class) {sco hostTabEntry}
set sco_hostTabEntry_CDT(superior) {sco hostTab}
set sco_hostTabEntry_CDT(subordinates) {}
set sco_dNSystem_CDT(attributes) {
{
name
{
{ validOperations {get} }
{ validFilters {} }
{ dataType {single} }
}
}
{
dNSMode
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType {single} }
}
}
{
dNSForwarders
{
{ validOperations {get add remove replace} }
{ validFilters {} }
{ dataType {set} }
{ description {forwarders entries
from named.boot} }
}
}
{
dNSBogusns
{
{ validOperations {get add remove replace} }
{ validFilters {} }
{ dataType {set} }
{ description {bogusns entries from named.boot} }
}
}
{
dNSXfrnets
{
{ validOperations {get add remove replace} }
{ validFilters {} }
{ dataType {set} }
{ description {xfrnets entries from named.boot} }
}
}
{
dNSSortlist
{
{ validOperations {get add remove replace} }
{ validFilters {} }
{ dataType {set} }
{ description {sortlist entries from named.boot} }
}
}
{
slave
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType {single} }
{ description {slave entry from named.boot -- options forward-only} }
}
}
{
OptsNoRecursion
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType {single} }
{ description {options no-recursion entry from named.boot} }
}
}
{
OptsQueryLog
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType {single} }
{ description {options query-log entry from named.boot} }
}
}
{
OptsFetchGlue
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType {single} }
{ description {options no-fetch-glue entry from named.boot} }
}
}
{
XferIn
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType {single} }
{ description {limits transfers-in entry from named.boot} }
}
}
{
XferPerNs
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType {single} }
{ description {limits transfers-per ns entry from named.boot} }
}
}
{
XferDatasize
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType {single} }
{ description {limits transfers-datasize entry from named.boot} }
}
}
{
dNSResolvers
{
{ validOperations {get add remove replace} }
{ validFilters {} }
{ dataType {set} }
{ description {nameserver entries from resolv.conf} }
}
}
{
domain
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType single }
{ description {local domain name
from resolv.conf} }
}
}
{
hostresorder
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType single }
{ description {hostresorder from
resolv.conf} }
}
}
{
search
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType single }
{ description {search list for hostname lookup from resolv.conf} }
}
}
{
resSortlist
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType single }
{ description {sortlist from resolv.conf} }
}
}
}
set sco_dNSystem_CDT(groups) {}
set sco_dNSystem_CDT(operations) {
{
get
{
{ function {dNSystem_get} }
{ granularity {perAttribute} }
}
}
{
replace
{
{ function {dNSystem_replace} }
{ granularity {perAttribute} }
}
}
{
add
{
{ function {dNSystem_add} }
{ granularity {perAttribute} }
}
}
{
remove
{
{ function {dNSystem_remove} }
{ granularity {perAttribute} }
}
}
{
action
{
{ function dNSystem_action }
{ granularity perObject }
}
}
}
set sco_dNSystem_CDT(class) {sco dNSystem}
set sco_dNSystem_CDT(superior) {}
set sco_dNSystem_CDT(subordinates) {{sco dNSPrimary} {sco dNSSecondary} {sco dNSStub} {sco dNSHint}}
set sco_hostTabs_CDT(attributes) {
{
name
{
{ validOperations {get} }
{ validFilters {} }
{ dataType {single} }
}
}
}
set sco_hostTabs_CDT(groups) {}
set sco_hostTabs_CDT(operations) {
{
get
{
{ function {hostTabs_get} }
{ granularity {perAttribute} }
}
}
}
set sco_hostTabs_CDT(class) {sco hostTabs}
set sco_hostTabs_CDT(superior) {}
set sco_hostTabs_CDT(subordinates) {{sco hostTab}}
set sco_dNSStub_CDT(attributes) {
{
name
{
{ validOperations {get} }
{ validFilters {} }
{ dataType {single} }
}
}
{
serverList
{
{ validOperations {get add remove replace} }
{ validFilters {} }
{ dataType {set} }
}
}
{
file
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType {single} }
}
}
}
set sco_dNSStub_CDT(groups) {}
set sco_dNSStub_CDT(operations) {
{
get
{
{ function {dNSStub_get} }
{ granularity {perAttribute} }
}
}
{
add
{
{ function {dNSStub_add} }
{ granularity {perAttribute} }
}
}
{
replace
{
{ function {dNSStub_replace} }
{ granularity {perAttribute} }
}
}
{
remove
{
{ function {dNSStub_remove} }
{ granularity {perAttribute} }
}
}
{
create
{
{ function {dNSStub_create} }
{ granularity {perObject} }
}
}
{
delete
{
{ function {dNSStub_delete} }
{ granularity {perObject} }
}
}
{
list
{
{ function {dNSStub_list} }
{ granularity {perObject} }
}
}
}
set sco_dNSStub_CDT(class) {sco dNSStub}
set sco_dNSStub_CDT(superior) {sco dNSystem}
set sco_dNSStub_CDT(subordinates) {}
set sco_hostTab_CDT(attributes) {
{
name
{
{ validOperations {get} }
{ validFilters {} }
{ dataType {single} }
}
}
}
set sco_hostTab_CDT(groups) {}
set sco_hostTab_CDT(operations) {
{
get
{
{ function {hostTab_get} }
{ granularity {perAttribute} }
}
}
{
list
{
{ function {hostTab_list} }
{ granularity {perObject} }
}
}
}
set sco_hostTab_CDT(class) {sco hostTab}
set sco_hostTab_CDT(superior) {sco hostTabs}
set sco_hostTab_CDT(subordinates) {{sco hostTabEntry}}
set sco_dNSSecondary_CDT(attributes) {
{
name
{
{ validOperations {get} }
{ validFilters {} }
{ dataType {single} }
}
}
{
serverList
{
{ validOperations {get add remove replace} }
{ validFilters {} }
{ dataType {set} }
}
}
{
file
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType {single} }
}
}
}
set sco_dNSSecondary_CDT(groups) {}
set sco_dNSSecondary_CDT(operations) {
{
get
{
{ function {dNSSecondary_get} }
{ granularity {perAttribute} }
}
}
{
add
{
{ function {dNSSecondary_add} }
{ granularity {perAttribute} }
}
}
{
replace
{
{ function {dNSSecondary_replace} }
{ granularity {perAttribute} }
}
}
{
remove
{
{ function {dNSSecondary_remove} }
{ granularity {perAttribute} }
}
}
{
create
{
{ function {dNSSecondary_create} }
{ granularity {perObject} }
}
}
{
delete
{
{ function {dNSSecondary_delete} }
{ granularity {perObject} }
}
}
{
list
{
{ function {dNSSecondary_list} }
{ granularity {perObject} }
}
}
}
set sco_dNSSecondary_CDT(class) {sco dNSSecondary}
set sco_dNSSecondary_CDT(superior) {sco dNSystem}
set sco_dNSSecondary_CDT(subordinates) {}
set sco_dNSHint_CDT(attributes) {
{
name
{
{ validOperations {get} }
{ validFilters {} }
{ dataType {single} }
}
}
{
addrList
{
{ validOperations {get add remove replace} }
{ validFilters {} }
{ dataType {set} }
}
}
{
comment
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType {single} }
}
}
}
set sco_dNSHint_CDT(groups) {}
set sco_dNSHint_CDT(operations) {
{
get
{
{ function {dNSHint_get} }
{ granularity {perAttribute} }
}
}
{
replace
{
{ function {dNSHint_replace} }
{ granularity {perAttribute} }
}
}
{
create
{
{ function {dNSHint_create} }
{ granularity {perObject} }
}
}
{
delete
{
{ function {dNSHint_delete} }
{ granularity {perObject} }
}
}
{
add
{
{ function {dNHint_add} }
{ granularity {perAttribute} }
}
}
{
remove
{
{ function {dNHint_remove} }
{ granularity {perAttribute} }
}
}
{
list
{
{ function {dNSHint_list} }
{ granularity {perObject} }
}
}
}
set sco_dNSHint_CDT(class) {sco dNSHint}
set sco_dNSHint_CDT(superior) {sco dNSystem}
set sco_dNSHint_CDT(subordinates) {}
set sco_dNSPrimary_CDT(attributes) {
{
name
{
{ validOperations {get} }
{ validFilters {} }
{ dataType {single} }
}
}
{
file
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType {single} }
}
}
{
mailbox
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType {single} }
}
}
{
serial
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType single }
{ description {Serial number for zone} }
}
}
{
refresh
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType {single} }
}
}
{
retry
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType {single} }
}
}
{
expire
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType {single} }
}
}
{
minimum
{
{ validOperations {get replace} }
{ validFilters {} }
{ dataType {single} }
}
}
{
serverList
{
{ validOperations {get replace add remove} }
{ validFilters {} }
{ dataType set }
}
}
}
set sco_dNSPrimary_CDT(groups) {}
set sco_dNSPrimary_CDT(operations) {
{
get
{
{ function {dNSPrimary_get} }
{ granularity {perAttribute} }
}
}
{
replace
{
{ function {dNSPrimary_replace} }
{ granularity {perAttribute} }
}
}
{
create
{
{ function {dNSPrimary_create} }
{ granularity {perObject} }
}
}
{
delete
{
{ function {dNSPrimary_delete} }
{ granularity {perObject} }
}
}
{
list
{
{ function {dNSPrimary_list} }
{ granularity {perObject} }
}
}
{
add
{
{ granularity perObject }
{ function dNSPrimary_add }
}
}
{
remove
{
{ granularity perObject }
{ function dNSPrimary_remove }
}
}
}
set sco_dNSPrimary_CDT(class) {sco dNSPrimary}
set sco_dNSPrimary_CDT(superior) {sco dNSystem}
set sco_dNSPrimary_CDT(subordinates) {}
proc Resolv:CreateScancontext {} {
global resolv_scontext
set resolv_scontext [scancontext create]
scanmatch $resolv_scontext {^} {
global resolv_lines resolv_lineindexes
set lineindex $matchInfo(handle).$matchInfo(linenum)
lappend resolv_lineindexes $lineindex
set resolv_lines($lineindex) $matchInfo(line)
}
scanmatch $resolv_scontext {(^[ ]*;)|(^[ ]*$)} {
continue
}
scanmatch -nocase $resolv_scontext {^[ ]*nameserver[ ]} {
global resolv_servers
if { ! [regsub {;.*$} $matchInfo(line) {} line]} {
set line $matchInfo(line)
}
if {[llength $line] != 2} {
ErrorPush {} 1 SCO_DNSOSA_ERR_FMT_BAD_LINE \
[list $filename $line]
} else {
set resolv_servers($lineindex) [lindex $line 1]
}
continue
}
scanmatch -nocase $resolv_scontext {^[ ]*domain[ ]} {
global resolv_domain
if { ! [regsub {;.*$} $matchInfo(line) {} line]} {
set line $matchInfo(line)
}
if {[llength $line] != 2} {
ErrorPush {} 1 SCO_DNSOSA_ERR_FMT_BAD_LINE \
[list $filename $line]
} else {
set resolv_domain($lineindex) [lindex $line 1]
}
continue
}
scanmatch -nocase $resolv_scontext {^[ ]*hostresorder[ ]} {
global resolv_hostresorder
if { ! [regsub {;.*$} $matchInfo(line) {} line]} {
set line $matchInfo(line)
}
if {[llength $line] < 2} {
ErrorPush {} 1 SCO_DNSOSA_ERR_FMT_BAD_LINE \
[list $filename $line]
} else {
set resolv_hostresorder($lineindex) [lrange $line 1 end]
}
continue
}
scanmatch -nocase $resolv_scontext {^[ ]*search[ ]} {
global resolv_search
if { ! [regsub {;.*$} $matchInfo(line) {} line]} {
set line $matchInfo(line)
}
if {[llength $line] < 2} {
ErrorPush {} 1 SCO_DNSOSA_ERR_FMT_BAD_LINE \
[list $filename $line]
} else {
set resolv_search($lineindex) [lrange $line 1 end]
}
continue
}
scanmatch -nocase $resolv_scontext {^[ ]*sortlist[ ]} {
global resolv_sortlist
if { ! [regsub {;.*$} $matchInfo(line) {} line]} {
set line $matchInfo(line)
}
if {[llength $line] < 2} {
ErrorPush {} 1 SCO_DNSOSA_ERR_FMT_BAD_LINE \
[list $filename $line]
} else {
set resolv_sortlist($lineindex) [lrange $line 1 end]
}
continue
}
}
proc resolv_addline {before line} {
global resolv_lines resolv_lineindexes resolv_newindex resolv_modified
if {$before == "end"} {
set index [llength $resolv_lineindexes]
} else {
if {[set index [lsearch $resolv_lineindexes $before]] == -1} {
ErrorPush {} 1 SCO_DNSOSA_ERR_ILLEGAL \
[list "resolv_addline" $before]
}
}
set newindex new.$resolv_newindex
set resolv_lineindexes [linsert $resolv_lineindexes $index $newindex]
set resolv_lines($newindex) $line
incr resolv_newindex
set resolv_modified 1
return $newindex
}
proc resolv_rmline {line} {
global resolv_lineindexes resolv_modified
if {[set index [lsearch -exact $resolv_lineindexes $line]] == -1} {
ErrorPush {} 1 SCO_DNSOSA_ERR_ILLEGAL [list "resolv_rmline" $line]
}
lvarpop resolv_lineindexes $index
set resolv_modified 1
}
proc list_resolvers {} {
global resolv_servers
if [catch {array names resolv_servers} linelist] {
return {}
}
set result {}
foreach line [lsort -command SortByLineNum $linelist] {
lappend result $resolv_servers($line)
}
return $result
}
proc rm_resolver {addr} {
global resolv_servers
if [catch {array names resolv_servers} linelist] {
return {}
}
foreach line $linelist {
if [addrmatch $addr $resolv_servers($line)] {
unset resolv_servers($line)
resolv_rmline $line
}
}
}
proc add_resolver {addr} {
global resolv_servers
set index [resolv_addline end "nameserver $addr"]
set resolv_servers($index) $addr
}
proc get_domain {} {
global resolv_domain
if [catch {array names resolv_domain} linelist] {
return {}
}
set result {}
foreach line $linelist {
lappend result $resolv_domain($line)
}
return $result
}
proc rm_domain {} {
global resolv_domain
if [catch {array names resolv_domain} linelist] {
return {}
}
foreach line $linelist {
unset resolv_domain($line)
resolv_rmline $line
}
}
proc set_domain {domain} {
global resolv_domain
set index [resolv_addline end "domain $domain"]
set resolv_domain($index) $domain
}
proc get_hostresorder {} {
global resolv_hostresorder
if [catch {array names resolv_hostresorder} linelist] {
return {}
}
set result {}
foreach line $linelist {
lappend result $resolv_hostresorder($line)
}
return $result
}
proc rm_hostresorder {} {
global resolv_hostresorder
if [catch {array names resolv_hostresorder} linelist] {
return {}
}
foreach line $linelist {
unset resolv_hostresorder($line)
resolv_rmline $line
}
}
proc set_hostresorder {hostresorder} {
global resolv_hostresorder
set index [resolv_addline end "hostresorder $hostresorder"]
set resolv_hostresorder($index) $hostresorder
}
proc get_searchorder {} {
global resolv_search
if [catch {array names resolv_search} linelist] {
return {}
}
set result {}
foreach line $linelist {
lappend result $resolv_search($line)
}
return $result
}
proc rm_searchorder {} {
global resolv_search
if [catch {array names resolv_search} linelist] {
return {}
}
foreach line $linelist {
unset resolv_search($line)
resolv_rmline $line
}
}
proc set_searchorder {searchorder} {
global resolv_search
set index [resolv_addline end "search $searchorder"]
set resolv_search($index) $searchorder
}
proc get_resSortlist {} {
global resolv_sortlist
if [catch {array names resolv_sortlist} linelist] {
return {}
}
set result {}
foreach line $linelist {
lappend result $resolv_sortlist($line)
}
return $result
}
proc rm_resSortlist {} {
global resolv_sortlist
if [catch {array names resolv_sortlist} linelist] {
return {}
}
foreach line $linelist {
unset resolv_sortlist($line)
resolv_rmline $line
}
}
proc set_resSortlist {sortlist} {
global resolv_sortlist
set index [resolv_addline end "sortlist $sortlist"]
set resolv_sortlist($index) $sortlist
}
proc ResolverActive {} {
global resolv_file
if {[owner file isfile $resolv_file]} {
return 1
} else {
return 0
}
}
proc resolv_writemode {} {
global dns_selectedmode
global resolv_file resolv_save resolv_modified
case $dns_selectedmode {
remote {
if $resolv_modified {
resolv_writefile $resolv_file
backup_file $resolv_save
} else {
if { ! [owner file isfile $resolv_file]} {
if [owner file isfile $resolv_save] {
move_file $resolv_save $resolv_file
} else {
user_error "no resolver file"
}
}
}
}
delresolv {
owner unlink -nocomplain $resolv_file
}
{off master caching} {
if $resolv_modified {
resolv_writefile $resolv_save
} else {
}
}
}
}
proc resolv_readfile {filename} {
global resolv_scontext resolv_modified resolv_newindex
global resolv_lines resolv_lineindexes
set infile [ownerOpen readfile $filename]
if {$infile != -1} {
scanfile $resolv_scontext $infile
close $infile
}
set resolv_modified 0
if [catch {set resolv_lineindexes}] {
lappend resolv_lineindexes new.0
set resolv_lines(new.0) ""
set resolv_newindex 1
} else {
set resolv_newindex 0
}
}
proc resolv_writefile {file} {
global resolv_modified resolv_lines resolv_lineindexes
if { ! $resolv_modified} {
return
}
backup_file $file
set outfile [ownerOpen writefile $file]
if {$outfile == -1} {
ErrorPush {} 1 SCO_DNSOSA_ERR_OPEN_WR $file
}
foreach line $resolv_lineindexes {
puts $outfile $resolv_lines($line)
}
close $outfile
}
proc resolv_init {} {
global IPAddrMap_ConfigDir
global resolv_file resolv_save
set resolv_file /etc/resolv.conf
set resolv_save /etc/resolv.save
Resolv:CreateScancontext
if {[owner file isfile $resolv_file]} {
resolv_readfile $resolv_file
} else {
resolv_readfile $resolv_save
}
}
proc setup_boot_scancontexts {} {
global boot_scontext
set boot_scontext [scancontext create]
scanmatch $boot_scontext {^} {
global boot_lines boot_lineindexes
set lineindex $matchInfo(handle).$matchInfo(linenum)
lappend boot_lineindexes $lineindex
set boot_lines($lineindex) $matchInfo(line)
}
scanmatch $boot_scontext {(^[ ]*;)|(^[ ]*$)} {
continue
}
scanmatch -nocase $boot_scontext {^[ ]*directory[ ]} {
global boot_directory
if {[llength $matchInfo(line)] < 2} {
ErrorPush {} 1 SCO_DNSOSA_ERR_FMT_BAD_DIR $matchInfo(line)
} else {
set boot_directory [lindex $matchInfo(line) 1]
}
continue
}
scanmatch -nocase $boot_scontext {^[ ]*cache[ ]} {
global boot_caches
if {([llength $matchInfo(line)] < 3)
|| (([lindex $matchInfo(line) 1] != ".")
&& ([lindex $matchInfo(line) 1] != ".."))} {
ErrorPush {} 1 SCO_DNSOSA_ERR_FMT_BAD_CACHE \
$matchInfo(line)
}
set boot_caches($lineindex) [lindex $matchInfo(line) 2]
continue
}
scanmatch -nocase $boot_scontext {^[ ]*primary[ ]} {
global boot_primaries boot_localhost
if { ! [regsub {;.*$} $matchInfo(line) {} line]} {
set line $matchInfo(line)
}
if {[llength $line] < 3} {
ErrorPush {} 1 SCO_DNSOSA_ERR_BAD_LINE $matchInfo(line)
}
if [cequal [lindex $line 1] "0.0.127.in-addr.arpa"] {
set boot_localhost $lineindex
} else {
set boot_primaries($lineindex) [lrange $line 1 2]
}
continue
}
scanmatch -nocase $boot_scontext {^[ ]*secondary[ ]} {
global boot_secondaries
if { ! [regsub {;.*$} $matchInfo(line) {} line]} {
set line $matchInfo(line)
}
if {[llength $line] < 4} {
ErrorPush {} 1 SCO_DNSOSA_ERR_BAD_LINE $line
}
set addrs {}
set file {}
foreach j [lrange $line 2 end] {
if [string match {[0-9]*} $j] {
lappend addrs $j
} else {
set file $j
}
}
if { $addrs == {} } {
ErrorPush {} 1 SCO_DNSOSA_ERR_BAD_LINE $matchInfo(line)
}
set boot_secondaries($lineindex) [list [lindex $line 1] $addrs $file]
continue
}
scanmatch -nocase $boot_scontext {^[ ]*forwarders[ ]} {
global boot_forwarders
if [regsub {;.*$} $matchInfo(line) {} line] {
set boot_forwarders($lineindex) [lrange $line 1 end]
} else {
set boot_forwarders($lineindex) [lrange $matchInfo(line) 1 end]
}
continue
}
scanmatch -nocase $boot_scontext {^[ ]*slave[ ]} {
global boot_slave
set boot_slave $lineindex
}
scanmatch -nocase $boot_scontext {^[ ]*sortlist[ ]} {
global boot_sortlist
if [regsub {;.*$} $matchInfo(line) {} line] {
set boot_sortlist($lineindex) [lrange $line 1 end]
} else {
set boot_sortlist($lineindex) [lrange $matchInfo(line) 1 end]
}
continue
}
scanmatch -nocase $boot_scontext {^[ ]*xfrnets[ ]} {
global boot_xfrnets
if [regsub {;.*$} $matchInfo(line) {} line] {
set boot_xfrnets($lineindex) [lrange $line 1 end]
} else {
set boot_xfrnets($lineindex) [lrange $matchInfo(line) 1 end]
}
continue
}
scanmatch -nocase $boot_scontext {^[ ]*bogusns[ ]} {
global boot_bogusns
if [regsub {;.*$} $matchInfo(line) {} line] {
set boot_bogusns($lineindex) [lrange $line 1 end]
} else {
set boot_bogusns($lineindex) [lrange $matchInfo(line) 1 end]
}
continue
}
scanmatch -nocase $boot_scontext {^[ ]*options[ ]} {
if [regsub -nocase {no-recursion} $matchInfo(line) {} line] {
global boot_optsnorecursion
set boot_optsnorecursion $lineindex
} elseif [regsub -nocase {query-log} $matchInfo(line) {} line] {
global boot_optsquerylog
set boot_optsquerylog $lineindex
} elseif [regsub -nocase {forward-only} $matchInfo(line) {} line] {
global boot_slave
set boot_slave $lineindex
} elseif [regsub -nocase {no-fetch-glue} $matchInfo(line) {} line] {
global boot_optsfetchglue
set boot_optsfetchglue $lineindex
}
}
scanmatch -nocase $boot_scontext {^[ ]*limits[ ]} {
if [cequal [lindex $matchInfo(line) 1] transfers-in] {
global boot_xferin
set boot_xferin($lineindex) [lindex $matchInfo(line) end]
} elseif [cequal [lindex $matchInfo(line) 1] transfers-per-ns] {
global boot_xferperns
set boot_xferperns($lineindex) [lindex $matchInfo(line) end]
} elseif [cequal [lindex $matchInfo(line) 1] transfers-datasize] {
global boot_xferdatasize
set res [lindex $matchInfo(line) end]
set boot_xferdatasize($lineindex) [string trimright $res mk]
}
}
scanmatch -nocase $boot_scontext {^[ ]*stub[ ]} {
global boot_stubs
if { ! [regsub {;.*$} $matchInfo(line) {} line]} {
set line $matchInfo(line)
}
if {[llength $line] < 3} {
ErrorPush {} 1 SCO_DNSOSA_ERR_BAD_LINE $matchInfo(line)
}
set addrs {}
set file {}
foreach j [lrange $line 2 end] {
if [string match {[0-9]*} $j] {
lappend addrs $j
} else {
set file $j
}
}
if { $addrs == {} } {
ErrorPush {} 1 SCO_DNSOSA_ERR_BAD_LINE $matchInfo(line)
}
set boot_stubs($lineindex) [list [lindex $line 1] $addrs $file]
continue
}
}
proc boot_addline {before line} {
global boot_lines boot_lineindexes boot_newindex boot_modified
if {$before == "end"} {
set index [llength $boot_lineindexes]
} else {
if {[set index [lsearch $boot_lineindexes $before]] == -1} {
ErrorPush {} 1 SCO_DNSOSA_ERR_ILLEGAL \
[list "boot_addline" $before]
}
}
set newindex new.$boot_newindex
set boot_lineindexes [linsert $boot_lineindexes $index $newindex]
set boot_lines($newindex) $line
incr boot_newindex
set boot_modified 1
return $newindex
}
proc boot_rmline {line} {
global boot_lineindexes boot_modified
if {[set index [lsearch -exact $boot_lineindexes $line]] == -1} {
ErrorPush {} 1 SCO_DNSOSA_ERR_ILLEGAL \
[list "boot_rmline" $line]
}
lvarpop boot_lineindexes $index
set boot_modified 1
}
proc list_primaries {} {
global boot_primaries
set result {}
if [catch {array names boot_primaries} linelist] {
return {}
}
foreach line [lsort -command SortByLineNum $linelist] {
lappend result [lindex $boot_primaries($line) 0]
}
return $result
}
proc find_primary {name} {
global boot_primaries
if [catch {array names boot_primaries} linelist] {
return {}
}
foreach line $linelist {
if {[lindex $boot_primaries($line) 0] == $name} {
return $line
}
}
return {}
}
proc get_rrfile {domname} {
global boot_primaries
if {[set line [find_primary $domname]] == {} } {
return {}
}
return [dns_locate [lindex $boot_primaries($line) 1]]
}
proc rm_primary {name} {
global boot_primaries
if {[set line [find_primary $name]] == {} } {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
set fpath [get_rrfile $name]
unset boot_primaries($line)
boot_rmline $line
if {[owner file exists $fpath]} {
owner unlink -nocomplain $fpath
}
}
proc add_primary {name filename serverList mailbox serial refresh retry expire minimum} {
global boot_primaries
if {([find_primary $name] != {}) || ([find_secondary $name] != {})\
|| ([find_stub $name] != {}) } {
ErrorPush {} 1 SCO_OSA_ERR_DUPLICATE_MANAGED_OBJECT_INSTANCE "$name"
}
set line "primary $name $filename"
set index [boot_addline end $line]
set boot_primaries($index) [lrange $line 1 2]
dns_makefile $filename $mailbox $serial $refresh $retry $expire $minimum
dns_readfile $name $filename
foreach server $serverList {
dns_addserver $name [lindex $server 0] [lindex $server 1] {}
}
dns_writefile
}
proc change_rrfile {domname newname} {
global boot_primaries boot_lines boot_modified
if {[set line [find_primary $domname]] == {} } {
return {}
}
set boot_primaries($line) [lreplace $boot_primaries($line) 1 1 $newname]
set boot_lines($line) [lreplace $boot_lines($line) 2 2 $newname]
set boot_modified 1
}
proc list_secondaries {} {
global boot_secondaries
set result {}
if [catch {array names boot_secondaries} linelist] {
return {}
}
foreach line [lsort -command SortByLineNum $linelist] {
lappend result [lindex $boot_secondaries($line) 0]
}
return $result
}
proc find_secondary {name} {
global boot_secondaries
if [catch {array names boot_secondaries} linelist] {
return {}
}
foreach line $linelist {
if {[lindex $boot_secondaries($line) 0] == $name} {
return $line
}
}
return {}
}
proc get_secondary {name} {
global boot_secondaries
if {[set line [find_secondary $name]] == {} } {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
return [lrange $boot_secondaries($line) 1 end]
}
proc add_secondary {name servers backup} {
global boot_secondaries
if {([find_primary $name] != {}) || ([find_secondary $name] != {})\
|| ([find_stub $name] != {}) } {
ErrorPush {} 1 SCO_OSA_ERR_DUPLICATE_MANAGED_OBJECT_INSTANCE "$name"
}
if {$backup != {}} {
set index [boot_addline end "secondary $name $servers $backup"]
} else {
set index [boot_addline end "secondary $name $servers"]
}
set boot_secondaries($index) [list $name $servers $backup]
}
proc rm_secondary {name} {
global boot_secondaries
if {[set line [find_secondary $name]] == {} } {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
dns_del_file [lindex $boot_secondaries($line) end]
boot_rmline $line
unset boot_secondaries($line)
}
proc dns_del_file {file} {
global boot_directory
set fpath [format "%s/%s" $boot_directory $file]
if {[owner file exists $fpath]} {
owner unlink -nocomplain $fpath
}
}
proc sec_addserver {name addr} {
global boot_secondaries boot_modified boot_lines
if {[set line [find_secondary $name]] == {} } {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
set addrlist [lindex $boot_secondaries($line) 1]
foreach j $addrlist {
if [addrmatch $j $addr] {
return
}
}
set addrlist [concat $addr $addrlist]
set boot_secondaries($line) [lreplace $boot_secondaries($line) 1 1 $addrlist]
set boot_lines($line) [linsert $boot_lines($line) 2 $addr]
set boot_modified 1
}
proc sec_rmserver {name addr} {
global boot_secondaries boot_modified boot_lines
if {[set line [find_secondary $name]] == {} } {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
set addrlist [lindex $boot_secondaries($line) 1]
loop index 0 [llength $addrlist] {
if [addrmatch [lindex $addrlist $index] $addr] {
break
}
}
if { $index == [llength $addrlist] } {
return
}
lvarpop addrlist $index
set boot_secondaries($line) [lreplace $boot_secondaries($line) 1 1 $addrlist]
incr index 2
lvarpop boot_lines($line) $index
set boot_modified 1
}
proc sec_setbackup {name file} {
global boot_secondaries boot_modified boot_lines
if {[set line [find_secondary $name]] == {} } {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
set numaddrs [llength [lindex $boot_secondaries($line) 1]]
incr numaddrs 2
if {[lindex $boot_secondaries($line) 2] == {} } {
set boot_lines($line) [linsert $boot_lines($line) $numaddrs $file]
} else {
set boot_lines($line) [lreplace $boot_lines($line) $numaddrs $numaddrs $file]
}
set boot_secondaries($line) [lreplace $boot_secondaries($line) 2 2 $file]
set boot_modified 1
}
proc list_stubs {} {
global boot_stubs
set result {}
if [catch {array names boot_stubs} linelist] {
return {}
}
foreach line [lsort -command SortByLineNum $linelist] {
lappend result [lindex $boot_stubs($line) 0]
}
return $result
}
proc find_stub {name} {
global boot_stubs
if [catch {array names boot_stubs} linelist] {
return {}
}
foreach line $linelist {
if {[lindex $boot_stubs($line) 0] == $name} {
return $line
}
}
return {}
}
proc get_stub {name} {
global boot_stubs
if {[set line [find_stub $name]] == {} } {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
return [lrange $boot_stubs($line) 1 end]
}
proc add_stub {name servers backup} {
global boot_stubs
if {([find_primary $name] != {}) || ([find_secondary $name] != {})\
|| ([find_stub $name] != {}) } {
ErrorPush {} 1 SCO_OSA_ERR_DUPLICATE_MANAGED_OBJECT_INSTANCE "$name"
}
if {$backup != {}} {
set index [boot_addline end "stub $name $servers $backup"]
} else {
set index [boot_addline end "stub $name $servers"]
}
set boot_stubs($index) [list $name $servers $backup]
}
proc rm_stub {name} {
global boot_stubs
if {[set line [find_stub $name]] == {} } {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
boot_rmline $line
unset boot_stubs($line)
}
proc stub_addserver {name addr} {
global boot_stubs boot_modified boot_lines
if {[set line [find_stub $name]] == {} } {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
set addrlist [lindex $boot_stubs($line) 1]
foreach j $addrlist {
if [addrmatch $j $addr] {
return
}
}
set addrlist [concat $addr $addrlist]
set boot_stubs($line) [lreplace $boot_stubs($line) 1 1 $addrlist]
set boot_lines($line) [linsert $boot_lines($line) 2 $addr]
set boot_modified 1
}
proc stub_rmserver {name addr} {
global boot_stubs boot_modified boot_lines
if {[set line [find_stub $name]] == {} } {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
set addrlist [lindex $boot_stubs($line) 1]
loop index 0 [llength $addrlist] {
if [addrmatch [lindex $addrlist $index] $addr] {
break
}
}
if { $index == [llength $addrlist] } {
return
}
lvarpop addrlist $index
set boot_stubs($line) [lreplace $stubs($line) 1 1 $addrlist]
incr index 2
lvarpop boot_lines($line) $index
set boot_modified 1
}
proc stub_setbackup {name file} {
global boot_stubs boot_modified boot_lines
if {[set line [find_stub $name]] == {} } {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
set numaddrs [llength [lindex $boot_stubs($line) 1]]
incr numaddrs 2
if {[lindex $boot_stubs($line) 2] == {} } {
set boot_lines($line) [linsert $boot_lines($line) $numaddrs $file]
} else {
set boot_lines($line) [lreplace $boot_lines($line) $numaddrs $numaddrs $file]
}
set boot_stubs($line) [lreplace $boot_stubs($line) 2 2 $file]
set boot_modified 1
}
proc list_forwarders {} {
global boot_forwarders
if [catch {array names boot_forwarders} linelist] {
return {}
}
set result {}
foreach line [lsort -command SortByLineNum $linelist] {
set result [concat $result $boot_forwarders($line)]
}
return $result
}
proc rm_forwarder {addr} {
global boot_forwarders boot_lines boot_modified
if [catch {array names boot_forwarders} linelist] {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$addr"
}
foreach line $linelist {
set addrlist $boot_forwarders($line)
loop index 0 [llength $addrlist] {
if [addrmatch [lindex $addrlist $index] $addr] {
break
}
}
if { ! [addrmatch [lindex $addrlist $index] $addr]} {
continue
}
if {[llength $addrlist] == 1} {
unset boot_forwarders($line)
boot_rmline $line
} else {
lvarpop boot_forwarders($line) $index
incr index
lvarpop boot_lines($line) $index
set boot_modified 1
}
}
}
proc add_forwarder {addr} {
global boot_forwarders
set index [boot_addline end "forwarders $addr"]
set boot_forwarders($index) $addr
}
proc list_sortlist {} {
global boot_sortlist
if [catch {array names boot_sortlist} linelist] {
return {}
}
set result {}
foreach line [lsort -command SortByLineNum $linelist] {
set result [concat $result $boot_sortlist($line)]
}
return $result
}
proc rm_sortlist {addr} {
global boot_sortlist boot_lines boot_modified
if [catch {array names boot_sortlist} linelist] {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$addr"
}
foreach line $linelist {
set addrlist $boot_sortlist($line)
loop index 0 [llength $addrlist] {
if [addrmatch [lindex $addrlist $index] $addr] {
break
}
}
if { ! [addrmatch [lindex $addrlist $index] $addr]} {
continue
}
if {[llength $addrlist] == 1} {
unset boot_sortlist($line)
boot_rmline $line
} else {
lvarpop boot_sortlist($line) $index
incr index
lvarpop boot_lines($line) $index
set boot_modified 1
}
}
}
proc add_sortlist {addr} {
global boot_sortlist
set index [boot_addline end "sortlist $addr"]
set boot_sortlist($index) $addr
}
proc list_xfrnets {} {
global boot_xfrnets
if [catch {array names boot_xfrnets} linelist] {
return {}
}
set result {}
foreach line [lsort -command SortByLineNum $linelist] {
set result [concat $result $boot_xfrnets($line)]
}
return $result
}
proc rm_xfrnets {addr} {
global boot_xfrnets boot_lines boot_modified
if [catch {array names boot_xfrnets} linelist] {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$addr"
}
foreach line $linelist {
set addrlist $boot_xfrnets($line)
loop index 0 [llength $addrlist] {
if [addrmatch [lindex $addrlist $index] $addr] {
break
}
}
if { ! [addrmatch [lindex $addrlist $index] $addr]} {
continue
}
if {[llength $addrlist] == 1} {
unset boot_xfrnets($line)
boot_rmline $line
} else {
lvarpop boot_xfrnets($line) $index
incr index
lvarpop boot_lines($line) $index
set boot_modified 1
}
}
}
proc add_xfrnets {addr} {
global boot_xfrnets
set index [boot_addline end "xfrnets $addr"]
set boot_xfrnets($index) $addr
}
proc list_bogusns {} {
global boot_bogusns
if [catch {array names boot_bogusns} linelist] {
return {}
}
set result {}
foreach line [lsort -command SortByLineNum $linelist] {
set result [concat $result $boot_bogusns($line)]
}
return $result
}
proc rm_bogusns {addr} {
global boot_bogusns boot_lines boot_modified
if [catch {array names boot_bogusns} linelist] {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$addr"
}
foreach line $linelist {
set addrlist $boot_bogusns($line)
loop index 0 [llength $addrlist] {
if [addrmatch [lindex $addrlist $index] $addr] {
break
}
}
if { ! [addrmatch [lindex $addrlist $index] $addr]} {
continue
}
if {[llength $addrlist] == 1} {
unset boot_bogusns($line)
boot_rmline $line
} else {
lvarpop boot_bogusns($line) $index
incr index
lvarpop boot_lines($line) $index
set boot_modified 1
}
}
}
proc add_bogusns {addr} {
global boot_bogusns
set index [boot_addline end "bogusns $addr"]
set boot_bogusns($index) $addr
}
proc get_slaveflag {} {
global boot_slave
return [expr {$boot_slave != ""}]
}
proc set_slaveflag {value} {
global boot_slave
if {($boot_slave == "") && ($value == 1)} {
set index [boot_addline end "options forward-only"]
set boot_slave $index
} elseif {($boot_slave != "") && ($value == 0)} {
boot_rmline $boot_slave
set boot_slave ""
}
return 1
}
proc get_norecursionflag {} {
global boot_optsnorecursion
return [expr {$boot_optsnorecursion != ""}]
}
proc set_norecursionflag {value} {
global boot_optsnorecursion
if {($boot_optsnorecursion == "") && ($value == 1)} {
set index [boot_addline end "options no-recursion"]
set boot_optsnorecursion $index
} elseif {($boot_optsnorecursion != "") && ($value == 0)} {
boot_rmline $boot_optsnorecursion
set boot_optsnorecursion ""
}
return 1
}
proc get_querylogflag {} {
global boot_optsquerylog
return [expr {$boot_optsquerylog != ""}]
}
proc set_querylogflag {value} {
global boot_optsquerylog
if {($boot_optsquerylog == "") && ($value == 1)} {
set index [boot_addline end "options query-log"]
set boot_optsquerylog $index
} elseif {($boot_optsquerylog != "") && ($value == 0)} {
boot_rmline $boot_optsquerylog
set boot_optsquerylog ""
}
return 1
}
proc get_fetchglueflag {} {
global boot_optsfetchglue
return [expr {$boot_optsfetchglue != ""}]
}
proc set_fetchglueflag {value} {
global boot_optsfetchglue
if {($boot_optsfetchglue == "") && ($value == 1)} {
set index [boot_addline end "options no-fetch-glue"]
set boot_optsfetchglue $index
} elseif {($boot_optsfetchglue != "") && ($value == 0)} {
boot_rmline $boot_optsfetchglue
set boot_optsfetchglue ""
}
return 1
}
proc get_xferinlimit {} {
global boot_xferin
if ![info exists boot_xferin] {
return {}
}
set result {}
for_array_keys ind boot_xferin {
lappend result $boot_xferin($ind)
}
return $result
}
proc set_xferinlimit {{value {}}} {
global boot_xferin
set exists [info exists boot_xferin]
if {$exists} {
for_array_keys ind boot_xferin {
boot_rmline $ind
}
unset boot_xferin
}
if ![lempty $value] {
set replace [format "limits transfers-in %d" $value]
set index [boot_addline end $replace]
set boot_xferin($index) $value
}
return 1
}
proc get_xferpernslimit {} {
global boot_xferperns
if ![info exists boot_xferperns] {
return {}
}
set result {}
for_array_keys ind boot_xferperns {
lappend result $boot_xferperns($ind)
}
return $result
}
proc set_xferpernslimit {{value {}}} {
global boot_xferperns
set exists [info exists boot_xferperns]
if {$exists} {
for_array_keys ind boot_xferperns {
boot_rmline $ind
}
unset boot_xferperns
}
if ![lempty $value] {
set replace [format "limits transfers-per-ns %d" $value]
set index [boot_addline end $replace]
set boot_xferperns($index) $value
}
return 1
}
proc get_xferdatasize {} {
global boot_xferdatasize
if ![info exists boot_xferdatasize] {
return {}
}
set result {}
for_array_keys ind boot_xferdatasize {
lappend result $boot_xferdatasize($ind)
}
return $result
}
proc set_xferdatasize {{value {}}} {
global boot_xferdatasize
set exists [info exists boot_xferdatasize]
if {$exists} {
for_array_keys ind boot_xferdatasize {
boot_rmline $ind
}
unset boot_xferdatasize
}
if ![lempty $value] {
set replace [format "limits transfers-datasize %dm" $value]
set index [boot_addline end $replace]
set boot_xferdatasize($index) $value
}
return 1
}
proc dns_readhints {} {
global boot_caches dns_domain
if {$dns_domain == "."} {
return
}
dns_writefile
if [catch {array names boot_caches} linelist] {
return
}
foreach line $linelist {
dns_readfile . $boot_caches($line)
}
}
proc dns_gethintnames {} {
dns_readhints
if [catch {dns_getdatabyname . ns} result] {
if [catch {dns_getdatabyname .. ns} result] {
set result {}
}
}
return $result
}
proc dns_addhint {name addrs comment} {
dns_readhints
dns_addserver . $name $addrs $comment
}
proc dns_rmhint {name} {
dns_readhints
if [catch {dns_rmserver . $name}] {
if [catch {dns_rmserver .. $name}] {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
}
}
proc dns_findptr {addr} {
set addr [split $addr .]
if {[llength $addr] != 4} {
ErrorPush {} 1 SCO_DNSOSA_ERR_BAD_ADDR $addr]
}
foreach prim [list_primaries] {
set prim [string tolower $prim]
if [regsub -nocase {^([0-9.]*)(\.in-addr\.arpa)$} $prim {\1} dom] {
set dom [lreverse [split $dom .]]
if {[lmatch $dom $addr] == [llength $dom]} {
return $prim
}
}
}
return {}
}
proc dns_getmode {} {
global boot_file boot_primaries boot_secondaries
if [ResolverActive] {
return "remote"
}
if { ! [owner file isfile $boot_file]} {
return "off"
}
if { ! [catch {array size boot_secondaries}]} {
return "master"
}
if [catch {array names boot_primaries} linelist] {
return "caching"
}
foreach line $linelist {
if {[string tolower [lindex $boot_primaries($line) 0]] != "0.0.127.in-addr.arpa"} {
return "master"
}
}
return "caching"
}
proc boot_writemode {} {
global dns_selectedmode dns_currentmode boot_file boot_modified
global boot_file boot_save boot_master
case $dns_selectedmode {
off {
if $boot_modified {
boot_writefile all $boot_save
backup_file $boot_file
backup_file $boot_master
} else {
move_file $boot_file $boot_save
backup_file $boot_master
}
}
caching {
if {$boot_modified || ($dns_currentmode != "caching")} {
boot_writefile all $boot_file
}
}
master {
if {$boot_modified || ($dns_currentmode != "master")} {
boot_writefile all $boot_file
backup_file $boot_master
}
}
}
}
proc dns_locate {file} {
global boot_directory
if [string match {/*} $file] {
return $file
}
return "$boot_directory/$file"
}
proc boot_readfile {filename} {
global boot_scontext boot_modified boot_newindex
if {! [owner file exists $filename] || \
[owner file size $filename] == 0} {
set fp [ownerOpen writefile $filename]
if {$fp != -1} {
puts $fp "; [owner file tail $filename]"
close $fp
}
}
set infile [ownerOpen readfile $filename]
if {$infile != -1} {
scanfile $boot_scontext $infile
close $infile
}
set boot_modified 0
set boot_newindex 0
}
proc boot_writefile {mode file} {
global boot_modified boot_lines boot_lineindexes
global boot_primaries boot_secondaries
global restart_server
if {! $boot_modified} {
return
}
backup_file $file
set outfile [ownerOpen writefile $file]
if {$outfile == -1} {
ErrorPush {} 1 SCO_DNSOSA_ERR_OPEN_WR $file
}
foreach line $boot_lineindexes {
set linetype nomaster
if { ! [catch {set pline $boot_primaries($line)}]} {
if {[string tolower [lindex $pline 0]]
!= "0.0.127.in-addr.arpa"} {
set linetype master
}
}
if { ! [catch {set pline $boot_secondaries($line)}]} {
set linetype master
}
if {($mode == "all") || ($mode == $linetype)} {
puts $outfile $boot_lines($line)
}
}
close $outfile
set restart_server 1
set boot_modified 0
}
proc boot_minimal_config {} {
global boot_directory boot_caches
global boot_localhost
global IPAddrMap_ConfigDir
if ![info exists boot_directory] {
set boot_directory [format "%s/named.d" $IPAddrMap_ConfigDir]
if ![owner file isdirectory $boot_directory] {
owner mkdir -path $boot_directory
}
set addline [format "directory\t%s" $boot_directory]
set index [boot_addline end $addline]
}
if ![info exists boot_caches] {
set addline [format "cache\t.\t\t\t%s" "db.cache"]
set index [boot_addline end $addline]
set boot_caches($index) "db.cache"
set fpath [format "%s/db.cache" $boot_directory]
if {![owner file exists $fpath]} {
set outfile [ownerOpen writefile $fpath]
if {$outfile == -1} {
ErrorPush {} 1 SCO_DNSOSA_ERR_OPEN_WR $fpath
} else {
close $outfile
}
}
}
if ![info exists boot_localhost] {
set boot_localhost "db.local"
set addline [format "primary\t0.0.127.in-addr.arpa\t%s" $boot_localhost]
set index [boot_addline end $addline]
set fpath [format "%s/%s" $boot_directory $boot_localhost]
set fp [ownerOpen writefile $fpath]
if {$fp == -1} {
ErrorPush {} 1 SCO_DNSOSA_ERR_OPEN_WR $fpath
} else {
puts $fp [makeSOA "@ IN SOA" [exec /usr/ucb/hostname]. \
root.localhost [SetSerial 1 noincr] \
[list 10800 1800 14000000 86400]]
puts $fp [format "\tIN\tNS\t%s." [exec /usr/ucb/hostname]]
puts $fp "1\tIN\tPTR\tlocalhost."
close $fp
}
}
}
proc boot_init {} {
global IPAddrMap_ConfigDir
global boot_file boot_master boot_save boot_slave
global named_pid_file
global boot_optsnorecursion boot_optsquerylog boot_optsfetchglue
global boot_xferin boot_xferperns boot_xferdatasize
global dns_currentmode dns_selectedmode
setup_boot_scancontexts
set boot_file $IPAddrMap_ConfigDir/named.boot
set boot_master $IPAddrMap_ConfigDir/named.master
set boot_save $IPAddrMap_ConfigDir/named.save
set named_pid_file /etc/named.pid
set boot_slave ""
set boot_optsnorecursion {}
set boot_optsquerylog {}
set boot_optsfetchglue {}
boot_readfile $boot_file
set dns_currentmode [dns_getmode]
set dns_selectedmode $dns_currentmode
boot_minimal_config
}
proc SortByLineNum {el1 el2} {
set e1 [lindex [split $el1 .] end]
set e2 [lindex [split $el2 .] end]
if [cequal $e1 $e2] { return 0 }
return [expr {($e1 < $e2) ? -1 : 1}]
}
proc dns_fixname {name} {
global dns_origin
set name [string tolower $name]
if [string match {*.} $name] {
if {$name != "."} {
set name [string trimright $name .]
}
} else {
if {$name == "@"} {
set name $dns_origin
}
}
return $name
}
proc storeRR {lineindex name ttl typeoff} {
global dns_namelines dns_cnames dns_records dns_lastname
global dns_lines dns_origin dns_soa dns_filename
global dns_hinfo dns_rp dns_mx dns_txt
set dns_lastname $name
set name [dns_fixname $name]
set line $dns_lines($lineindex)
set type [string toupper [lindex $line $typeoff]]
set dataoff [expr $typeoff+1]
case $type in {
SOA {
if [lempty $dns_soa] {
parseSOA $line $dataoff $lineindex
} else {
ErrorPush {} 1 SCO_DNSOSA_ERR_MULT_SOA $dns_filename
}
append dns_mx($name) ""
append dns_rp($name) ""
append dns_hinfo($name) ""
append dns_txt($name) ""
append dns_ns($name) ""
lappend dns_namelines($name) $lineindex
}
NS {
lappend dns_ns($name) [lrange $line $dataoff end]
lappend dns_namelines($name) $lineindex
}
HINFO {
lappend dns_hinfo($name) [lrange $line $dataoff end]
lappend dns_namelines($name) $lineindex
}
MX {
lappend dns_mx($name) [lrange $line $dataoff end]
lappend dns_namelines($name) $lineindex
}
TXT {
lappend dns_txt($name) [lrange $line $dataoff end]
lappend dns_namelines($name) $lineindex
}
RP {
lappend dns_rp($name) [lrange $line $dataoff end]
lappend dns_namelines($name) $lineindex
}
CNAME {
set official [dns_fixname [lindex $line $dataoff]]
lappend dns_cnames($official) $name
lappend dns_namelines($name) $lineindex
}
default {
append dns_cnames($name) ""
append dns_mx($name) ""
append dns_rp($name) ""
append dns_hinfo($name) ""
append dns_txt($name) ""
lappend dns_namelines($name) $lineindex
}
}
set dns_records($lineindex) "$dataoff $name $ttl $type $dns_origin"
}
proc parseSOA {line dataoff lineindex} {
global dns_soa dns_filename
if { ! [regsub -all "(;\[^\n\]*($|\n))|\\\(|\\\)" $line "" dns_soa]} {
set dns_soa $line
}
set dns_soa [lrange $dns_soa $dataoff end]
lappend dns_soa $lineindex $dataoff
if {[llength $dns_soa] != 9} {
set dns_soa ""
ErrorPush {} 1 SCO_DNSOSA_ERR_BAD_SOA $dns_filename
}
if [string match {*.*} [lindex $dns_soa 2]] {
set foo [split [lindex $dns_soa 2] "."]
set dns_soa [lreplace $dns_soa 2 2 [lindex $foo 0]000[lindex $foo 1]]
}
}
proc balanceparens {init string} {
set opens [llength [split $string "("]]
set closes [llength [split $string ")"]]
return [expr "$init + ($opens - $closes)"]
}
proc setup_RR_scancontexts {} {
global dns_innercontext dns_outercontext
set nullstart {^[ ]+}
set rrstart {^[ ]*[^ ]+[ ]+}
set ttl {[0-9]+[ ]+}
set proto {in[ ]+}
set type {(a|cname|hinfo|mb|md|mf|minfo|mr|mx|ns|null|ptr|soa|txt|wks|afsdb|isdn|rp|rt|x25)[ ]+}
set dns_innercontext [scancontext create]
scanmatch $dns_innercontext {\)} {
append longline \n$matchInfo(line)
if {[set parens [balanceparens $parens $matchInfo(line)]]==0} {
return
}
}
scanmatch $dns_innercontext {
append longline \n$matchInfo(line)
set parens [balanceparens $parens $matchInfo(line)]
}
set dns_outercontext [scancontext create]
scanmatch $dns_outercontext {^} {
global dns_lines dns_lineindexes
set lineindex $matchInfo(handle).$matchInfo(linenum)
lappend dns_lineindexes $lineindex
set dns_lines($lineindex) $matchInfo(line)
}
scanmatch $dns_outercontext {(^[ ]*;)|(^[ ]*$)} {
continue
}
scanmatch -nocase $dns_outercontext {^\$origin} {
global dns_origin
set tmporg [string tolower [lindex $matchInfo(line) 1]]
if [string match {*.} $tmporg] {
set dns_origin [string trimright $tmporg .]
} else {
set dns_origin $tmporg.$dns_origin
}
continue
}
scanmatch -nocase $dns_outercontext {^\$include} {
global dns_outercontext dns_openfiles dns_origin dns_filename
set oldfilename $dns_filename
set oldorigin $dns_origin
set dns_filename [dns_locate [lindex $matchInfo(line) 1]]
if { ! [string match {;*} [lindex $matchInfo(line) 2]]} {
set dns_origin [lindex $matchInfo(line) 2]
}
set infile [ownerOpen readfile $dns_filename]
if {$infile == -1} {
ErrorPush {} 1 SCO_DNSOSA_ERR_NO_FILE $dns_filename
}
keylset dns_openfiles($infile) name $dns_filename modified 0
scanfile $dns_outercontext $infile
set dns_filename $oldfilename
set dns_origin $oldorigin
continue
}
scanmatch -nocase $dns_outercontext "$rrstart$ttl$proto$type.*\\\(" {
global dns_innercontext dns_lines
set longline $matchInfo(line)
set parens [balanceparens 0 $matchInfo(line)]
scanfile $dns_innercontext $matchInfo(handle)
set dns_lines($lineindex) $longline
storeRR $lineindex [lindex $longline 0] [lindex $longline 1] 3
continue
}
scanmatch -nocase $dns_outercontext "$rrstart$proto$ttl$type.*\\\(" {
global dns_innercontext dns_lines
set longline $matchInfo(line)
set parens [balanceparens 0 $matchInfo(line)]
scanfile $dns_innercontext $matchInfo(handle)
set dns_lines($lineindex) $longline
storeRR $lineindex [lindex $longline 0] [lindex $longline 2] 3
continue
}
scanmatch -nocase $dns_outercontext "$rrstart$ttl$type.*\\\(" {
global dns_innercontext dns_lines
set longline $matchInfo(line)
set parens [balanceparens 0 $matchInfo(line)]
scanfile $dns_innercontext $matchInfo(handle)
set dns_lines($lineindex) $longline
storeRR $lineindex [lindex $longline 0] [lindex $longline 1] 2
continue
}
scanmatch -nocase $dns_outercontext "$rrstart$proto$type.*\\\(" {
global dns_innercontext dns_lines
set longline $matchInfo(line)
set parens [balanceparens 0 $matchInfo(line)]
scanfile $dns_innercontext $matchInfo(handle)
set dns_lines($lineindex) $longline
storeRR $lineindex [lindex $longline 0] 0 2
continue
}
scanmatch -nocase $dns_outercontext "$rrstart$type.*\\\(" {
global dns_innercontext dns_lines
set longline $matchInfo(line)
set parens [balanceparens 0 $matchInfo(line)]
scanfile $dns_innercontext $matchInfo(handle)
set dns_lines($lineindex) $longline
storeRR $lineindex [lindex $longline 0] 0 1
continue
}
scanmatch -nocase $dns_outercontext "$nullstart$ttl$proto$type" {
global dns_lastname
storeRR $lineindex $dns_lastname [lindex $matchInfo(line) 0] 2
continue
}
scanmatch -nocase $dns_outercontext "$nullstart$proto$ttl$type" {
global dns_lastname
storeRR $lineindex $dns_lastname [lindex $matchInfo(line) 1] 2
continue
}
scanmatch -nocase $dns_outercontext "$nullstart$ttl$type" {
global dns_lastname
storeRR $lineindex $dns_lastname [lindex $matchInfo(line) 0] 1
continue
}
scanmatch -nocase $dns_outercontext "$nullstart$proto$type" {
global dns_lastname
storeRR $lineindex $dns_lastname 0 1
continue
}
scanmatch -nocase $dns_outercontext "$nullstart$type" {
global dns_lastname
storeRR $lineindex $dns_lastname 0 0
continue
}
scanmatch -nocase $dns_outercontext "$rrstart$ttl$proto$type" {
storeRR $lineindex [lindex $matchInfo(line) 0] [lindex $matchInfo(line) 1] 3
continue
}
scanmatch -nocase $dns_outercontext "$rrstart$proto$ttl$type" {
storeRR $lineindex [lindex $matchInfo(line) 0] [lindex $matchInfo(line) 2] 3
continue
}
scanmatch -nocase $dns_outercontext "$rrstart$ttl$type" {
storeRR $lineindex [lindex $matchInfo(line) 0] [lindex $matchInfo(line) 1] 2
continue
}
scanmatch -nocase $dns_outercontext "$rrstart$proto$type" {
storeRR $lineindex [lindex $matchInfo(line) 0] 0 2
continue
}
scanmatch -nocase $dns_outercontext "$rrstart$type" {
storeRR $lineindex [lindex $matchInfo(line) 0] 0 1
continue
}
scanmatch $dns_outercontext "^" {
global dns_filename
ErrorPush {} 1 SCO_DNSOSA_ERR_BAD_LINE $matchInfo(line)
}
}
proc makeSOA {start host mailbox serial rest} {
set result "$start\t$host\t$mailbox\t(\n"
append result "\t\t\t$serial ; serial number \[[fmtclock [getclock] "%D %T"]\]\n"
append result "\t\t\t[lindex $rest 0] ; refresh[cvtsecs [lindex $rest 0]]\n"
append result "\t\t\t[lindex $rest 1] ; retry[cvtsecs [lindex $rest 1]]\n"
append result "\t\t\t[lindex $rest 2] ; expire[cvtsecs [lindex $rest 2]]\n"
append result "\t\t\t[lindex $rest 3] ) ; minimum ttl[cvtsecs [lindex $rest 3]]"
return $result
}
proc storeSOA {} {
global dns_soa dns_lines dns_domain
if {($dns_domain == ".") || ($dns_domain == "..")} {
return
}
set serial [SetSerial [lindex $dns_soa 2]]
set lineindex [lindex $dns_soa 7]
set dataoff [lindex $dns_soa 8]
set start [lrange $dns_lines($lineindex) 0 [expr $dataoff-1]]
set host [lindex $dns_soa 0]
set mailbox [lindex $dns_soa 1]
set dns_lines($lineindex) [makeSOA $start $host $mailbox $serial [lrange $dns_soa 3 6]]
dns_markmodified $lineindex
}
proc SetSerial {serial {noincr {}}} {
set today [fmtclock [getclock] \%Y\%m\%d]
if {[clength $serial] > 8} {
scan $serial "%8d%d" date index
if [cequal $today $date] {
if [lempty $noincr] {
incr index
}
} else {
set index 1
}
} else {
set index 1
}
if {$index < 10} {
return [format "%s0%s" $today $index]
} else {
return [format "%s%s" $today $index]
}
}
proc dns_makefile {filename mailbox serial refresh retry expire minimum} {
global boot_directory
set fpath [format "%s/%s" $boot_directory $filename]
set outfile [ownerOpen writefile $fpath w+]
if {$outfile == -1} {
ErrorPush {} 1 SCO_DNSOSA_ERR_OPEN_WR $fpath
}
puts $outfile [makeSOA "@ IN SOA" [exec /usr/ucb/hostname]. $mailbox $serial [list $refresh $retry $expire $minimum]]
close $outfile
}
proc dns_addline {before name ttl type data comment} {
global dns_lines dns_lineindexes dns_newindex dns_addhandle
if {$before == "end"} {
set index [llength $dns_lineindexes]
} else {
if {[set index [lsearch $dns_lineindexes $before]] == -1} {
ErrorPush {} 1 SCO_DNSOSA_ERR_ILLEGAL \
[list "dns_addline" $before]
}
}
set oldname ""
set previndex [expr {$index - 1}]
while {($oldname == "") && ($previndex >= 0)} {
set oldindex [lindex $dns_lineindexes $previndex]
set oldline $dns_lines($oldindex)
if [string match {[ ]*} $oldline] {
set oldname ""
} else {
set oldname [lindex $oldline 0]
}
incr previndex -1
}
if {$oldname == $name} {
set line " "
set typeoff 0
} else {
set line "$name "
set typeoff 1
}
if {$ttl} {
append line "$ttl IN $type $data"
incr typeoff 2
} else {
append line "IN $type $data"
incr typeoff
}
if {$comment != {}} {
append line "\t; $comment"
}
set newindex $dns_addhandle.new$dns_newindex
incr dns_newindex
dns_markmodified $newindex
set dns_lineindexes [linsert $dns_lineindexes $index $newindex]
set dns_lines($newindex) $line
storeRR $newindex $name $ttl $typeoff
return $newindex
}
proc dns_rmline {line} {
global dns_lineindexes dns_records dns_namelines dns_lines
if {[set index [lsearch -exact $dns_lineindexes $line]] == -1} {
ErrorPush {} 1 SCO_DNSOSA_ERR_ILLEGAL \
[list "dns_rmline" $line]
}
lvarpop dns_lineindexes $index
dns_markmodified $line
if [catch {lindex $dns_records($line) 1} name] {
return
}
unset dns_records($line)
if {[set i [lsearch $dns_namelines($name) $line]] != -1} {
lvarpop dns_namelines($name) $i
}
if [string match {[ ]*} $dns_lines($line)] {
unset dns_lines($line)
return
}
set name [lindex $dns_lines($line) 0]
unset dns_lines($line)
foreach line [lrange $dns_lineindexes $index end] {
if { ! [catch {set record $dns_records($line)}]} {
if [string match {[ ]*} $dns_lines($line)] {
set dns_lines($line) "$name$dns_lines($line)"
set record $dns_records($line)
set dataoff [lindex $record 0]
incr dataoff
set record [lreplace $record 0 0 $dataoff]
set dns_records($line) $record
}
break
}
}
return
}
proc dns_getlinesbyname {name type} {
global dns_namelines dns_records
set type [string toupper $type]
set name [string tolower $name]
set result {}
if [catch {set linelist $dns_namelines($name)}] {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
set result {}
foreach line $linelist {
if {[lindex $dns_records($line) 3] == $type} {
lappend result $line
}
}
return $result
}
proc dns_getlinebydata {name type test} {
global dns_lines dns_records
set result {}
set test [string tolower $test]
foreach line [dns_getlinesbyname $name $type] {
set record $dns_records($line)
set dataoff [lindex $record 0]
set data [lrange $dns_lines($line) $dataoff end]
set data [string tolower $data]
case $type {
{NS CNAME PTR} {
if [string match {*.} $data] {
set data [string trimright $data .]
} else {
set data $data.[lindex $record 4]
}
if {$data == $test} {
return $line
}
}
{A} {
if [addrmatch $data $test] {
return $line
}
}
{MX RP HINFO} {
regsub -all "\"" $data "" data
regsub -all "\"" $test "" test
if {([lindex $data 0] == [lindex $test 0]) && \
([lindex $data 1] == [lindex $test 1])} {
return $line
}
}
{TXT} {
regsub -all "\"" $data "" data
regsub -all "\"" $test "" test
if {$data == $test} {
return $line
}
}
default {
if {$data == $test} {
return $line
}
}
}
}
return {}
}
proc dns_getdatabyname {name type} {
global dns_lines dns_records
set type [string toupper $type]
set result {}
foreach line [dns_getlinesbyname $name $type] {
set record $dns_records($line)
set dataoff [lindex $record 0]
set data [lindex $dns_lines($line) $dataoff]
case $type {
{NS CNAME PTR} {
if [string match {*.} $data] {
set data [string trimright $data .]
}
}
}
lappend result $data
}
return $result
}
proc dns_getnamesbytype {type} {
global dns_namelines dns_records
set type [string toupper $type]
set result {}
foreach name [array names dns_namelines] {
foreach line $dns_namelines($name) {
set record $dns_records($line)
if {[lindex $record 3] == $type} {
lappend result $name
break
}
}
}
return [lsort $result]
}
proc dns_getservers {name} {
set serverList {}
set servers [dns_getdatabyname $name ns]
foreach server $servers {
set addrs [dns_getaddrs $server]
lappend serverList [list $server $addrs]
}
return $serverList
}
proc MakeFQDN {host} {
if ![cequal [cindex $host end ] "."] {
return [format "%s." $host]
} else {
return $host
}
}
proc dns_addserver {dname hname addrs comment} {
dns_addline end [MakeFQDN $dname] 0 NS $hname $comment
foreach addr $addrs {
dns_addline end $hname 0 A $addr {}
}
}
proc dns_rmserver {dname {hname {}}} {
global dns_namelines dns_records dns_lines dns_lineindexes
set dname [string tolower $dname]
set hname [string tolower $hname]
if [catch {set linelist $dns_namelines($dname)}] {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$dname"
}
foreach line $linelist {
set record $dns_records($line)
if {[lindex $record 3] == "NS"} {
set dataoff [lindex $record 0]
set data [string tolower [lindex $dns_lines($line) $dataoff]]
if [string match {*.} $data] {
set data [string trimright $data .]
}
if {$hname != {}} {
if {$data == $hname} {
dns_rmline $line
dns_rmhost $data
return
}
} else {
dns_rmline $line
dns_rmhost $data
}
}
}
}
proc dns_addhost {name addrs aliases mxs rps txts hinfos comment} {
global dns_namelines
if {($name == {}) || ($addrs == {})} {
ErrorPush {} 1 SCO_DNSOSA_ERR_NO_HOST
}
if { ! [catch {set linelist $dns_namelines($name)}]} {
ErrorPush {} 1 SCO_OSA_ERR_DUPLICATE_MANAGED_OBJECT_INSTANCE "host"
}
foreach addr $addrs {
dns_addaddr $name $addr $comment
set comment {}
}
foreach txt $txts {
dns_addtxt $name $txt
}
foreach rp $rps {
dns_addrp $name $rp
}
foreach mx $mxs {
dns_addmx $name $mx
}
foreach hinfo $hinfos {
dns_addhinfo $name $hinfo
}
foreach alias $aliases {
dns_addalias $name $alias
}
}
proc dns_rmhost {name} {
global dns_namelines dns_cnames dns_mx dns_rp dns_hinfo dns_txt
if [catch {set linelist $dns_namelines($name)}] {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
foreach line $linelist {
dns_rmline $line
}
unset dns_namelines($name)
foreach alias $dns_cnames($name) {
foreach line $dns_namelines($alias) {
dns_rmline $line
}
unset dns_namelines($alias)
}
unset dns_cnames($name)
unset dns_mx($name)
unset dns_rp($name)
unset dns_hinfo($name)
unset dns_txt($name)
}
proc dns_getaddrs {name} {
return [dns_getdatabyname $name a]
}
proc dns_setaddrs {name addrList} {
set curaddrs [dns_getaddrs $name]
set newaddrs [lsubtract $addrList $curaddrs addrmatch]
set rmaddrs [lsubtract $curaddrs $addrList addrmatch]
set comment [dns_getcomment $name]
foreach addr $newaddrs {
dns_addaddr $name $addr $comment
set comment {}
}
foreach addr $rmaddrs {
dns_rmaddr $name $addr
}
}
proc dns_addaddrs {name addrList comment} {
set curaddrs [dns_getaddrs $name]
set newaddrs [lsubtract $addrList $curaddrs addrmatch]
foreach addr $newaddrs {
dns_addaddr $name $addr $comment
set comment {}
}
}
proc dns_rmaddrs {name addrList} {
set curaddrs [dns_getaddrs $name]
set rmaddrs [lsubtract $curaddrs $addrList addrmatch]
if [lempty $rmaddrs] {
ErrorPush {} 1 SCO_DNSOSA_ERR_RM_LAST_ADDR $name
}
foreach addr $addrList {
dns_rmaddr $name $addr
}
}
proc dns_addaddr {name addr comment} {
dns_addline end $name 0 A $addr $comment
}
proc dns_rmaddr {name addr} {
if {[set line [dns_getlinebydata $name A $addr]] == {} } {
ErrorPush {} 1 SCO_DNSOSA_ERR_NO_ADDR [list $addr $name]
}
dns_rmline $line
}
proc dns_getaliases {name} {
global dns_cnames
if [catch {set result $dns_cnames($name)}] {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
return $result
}
proc dns_setaliases {name aliases} {
global dns_cnames
set curaliases [dns_getaliases $name]
set newaliases [lsubtract $aliases $curaliases]
set rmaliases [lsubtract $curaliases $aliases]
foreach alias $rmaliases {
dns_rmalias $name $alias
}
foreach alias $newaliases {
dns_addalias $name $alias
}
set dns_cnames($name) $aliases
}
proc dns_addaliases {name aliases} {
set curaliases [dns_getaliases $name]
set newaliases [lsubtract $aliases $curaliases]
foreach alias $newaliases {
dns_addalias $name $alias
}
}
proc dns_addalias {name alias} {
dns_addline end $alias 0 CNAME $name {}
}
proc dns_rmaliases {name aliases} {
global dns_cnames
set curaliases [dns_getaliases $name]
set rmaliases [lsubtract $curaliases $aliases]
foreach alias $aliases {
dns_rmalias $name $alias
}
set dns_cnames($name) $rmaliases
}
proc dns_rmalias {name alias} {
if {[set line [dns_getlinebydata $alias CNAME $name]] == {} } {
ErrorPush {} 1 SCO_DNSOSA_ERR_NO_ALIAS [list $alias $name]
}
dns_rmline $line
}
proc dns_getmxs {name} {
global dns_mx
if [catch {set result $dns_mx($name)}] {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
return $result
}
proc dns_setmxs {name mxs} {
global dns_mx
set curmxs [dns_getmxs $name]
set newmxs [lsubtract $mxs $curmxs]
set rmmxs [lsubtract $curmxs $mxs]
foreach mx $rmmxs {
dns_rmmx $name $mx
}
foreach mx $newmxs {
dns_addmx $name $mx
}
set dns_mx($name) $mxs
}
proc dns_addmxs {name mxs} {
set curmxs [dns_getmxs $name]
set newmxs [lsubtract $mxs $curmxs]
foreach mx $newmxs {
dns_addmx $name $mx
}
}
proc dns_addmx {name mx} {
dns_addline end $name 0 MX $mx {}
}
proc dns_rmmxs {name mxs} {
global dns_mx
set curmxs [dns_getmxs $name]
set rmmxs [lsubtract $curmxs $mxs]
foreach mx $mxs {
dns_rmmx $name "$mx"
}
set dns_mx($name) $rmmxs
}
proc dns_rmmx {name mx} {
if {[set line [dns_getlinebydata $name MX $mx]] == {} } {
ErrorPush {} 1 SCO_DNSOSA_ERR_NO_MX [list $mx $name]
}
dns_rmline $line
}
proc dns_getrps {name} {
global dns_rp
if [catch {set result $dns_rp($name)}] {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
return $result
}
proc dns_setrps {name rps} {
global dns_rp
set currps [dns_getrps $name]
set newrps [lsubtract $rps $currps]
set rmrps [lsubtract $currps $rps]
foreach rp $rmrps {
dns_rmrp $name $rp
}
foreach rp $newrps {
dns_addrp $name $rp
}
set dns_rp($name) $rps
}
proc dns_addrps {name rps} {
set currps [dns_getrps $name]
set newrps [lsubtract $rps $currps]
foreach rp $newrps {
dns_addrp $name $rp
}
}
proc dns_addrp {name rp} {
dns_addline end $name 0 RP $rp {}
}
proc dns_rmrps {name rps} {
global dns_rp
set currps [dns_getrps $name]
set rmrps [lsubtract $currps $rps]
foreach rp $rps {
dns_rmrp $name $rp
}
set dns_rp($name) $rmrps
}
proc dns_rmrp {name rp} {
if {[set line [dns_getlinebydata $name RP $rp]] == {} } {
ErrorPush {} 1 SCO_DNSOSA_ERR_NO_RP [list $rp $name]
}
dns_rmline $line
}
proc dns_gettxts {name} {
global dns_txt
if [catch {set result $dns_txt($name)}] {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
regsub -all "\"" $result "" result
return $result
}
proc dns_settxts {name txts} {
global dns_txt
set curtxts [dns_gettxts $name]
set newtxts [lsubtract $txts $curtxts]
set rmtxts [lsubtract $curtxts $txts]
foreach txt $rmtxts {
dns_rmtxt $name $txt
}
foreach txt $newtxts {
dns_addtxt $name $txt
}
set dns_txt($name) $txts
}
proc dns_addtxts {name txts} {
set curtxts [dns_gettxts $name]
set newtxts [lsubtract $txts $curtxts]
foreach txt $newtxts {
dns_addtxt $name $txt
}
}
proc dns_addtxt {name txt} {
dns_addline end $name 0 TXT "\"$txt\"" {}
}
proc dns_rmtxts {name txts} {
global dns_txt
set curtxts [dns_gettxts $name]
set rmtxts [lsubtract $curtxts $txts]
foreach txt $txts {
dns_rmtxt $name $txt
}
set dns_txt($name) $rmtxts
}
proc dns_rmtxt {name txt} {
if {[set line [dns_getlinebydata $name TXT $txt]] == {} } {
ErrorPush {} 1 SCO_DNSOSA_ERR_NO_TXT [list $txt $name]
}
dns_rmline $line
}
proc dns_gethinfos {name} {
global dns_hinfo
if [catch {set result $dns_hinfo($name)}] {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
return $result
}
proc dns_sethinfos {name hinfos} {
global dns_hinfo
set curhinfos [dns_gethinfos $name]
set newhinfos [lsubtract $hinfos $curhinfos]
set rmhinfos [lsubtract $curhinfos $hinfos]
foreach hinfo $rmhinfos {
dns_rmhinfo $name $hinfo
}
foreach hinfo $newhinfos {
dns_addhinfo $name $hinfo
}
set hinfos [lindex $hinfos 0]
keylget hinfos hw hw
keylget hinfos os os
set dns_hinfo($name) [list [format "%s %s" $hw $os]]
}
proc dns_addhinfos {name hinfos} {
set curhinfos [dns_gethinfos $name]
set newhinfos [lsubtract $hinfos $curhinfos]
foreach hinfo $newhinfos {
dns_addhinfo $name $hinfo
}
}
proc dns_addhinfo {name hinfo} {
set hw {}
set os {}
keylget hinfo hw hw
keylget hinfo os os
if {[llength $hw] > 1} {
set hw "\"$hw\""
}
if {[llength $os] > 1} {
set os "\"$os\""
}
if {[lempty $hw] || [lempty $os]} {
return
}
dns_addline end $name 0 HINFO "$hw $os" {}
}
proc dns_rmhinfos {name hinfos} {
global dns_hinfo
set curhinfos [dns_gethinfos $name]
set rmhinfos [lsubtract $curhinfos $hinfos]
foreach hinfo $hinfos {
dns_rmhinfo $name $hinfo
}
set dns_hinfo($name) $rmhinfos
}
proc dns_rmhinfo {name hinfo} {
if {[set line [dns_getlinebydata $name HINFO $hinfo]] == {} } {
ErrorPush {} 1 SCO_DNSOSA_ERR_NO_HINFO [list $hinfo $name]
}
dns_rmline $line
}
proc dns_getcomment {name} {
global dns_namelines dns_lines
if [catch {set linelist $dns_namelines($name)}] {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
foreach line $linelist {
if [regsub {([^;]*);(.*$)} $dns_lines($line) {\2} foo] {
return $foo
}
}
return {}
}
proc dns_setcomment {name comment} {
global dns_namelines dns_lines
if [catch {set linelist $dns_namelines($name)}] {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
if {$comment == {}} {
return
}
foreach line $linelist {
if [regsub {([^;]*);(.*$)} $dns_lines($line) {\1} foo] {
set $dns_lines($line) "$foo ; $comment"
dns_markmodified $line
return
}
}
append dns_lines([lindex $linelist 0]) " ; $comment"
dns_markmodified [lindex $linelist 0]
return
}
proc dns_markmodified {index} {
global dns_openfiles dns_modified
set handle [lindex [split $index .] 0]
keylset dns_openfiles($handle) modified 1
set dns_modified 1
return
}
proc dns_readdomain {domain} {
global dns_domain
if {$dns_domain == $domain} {
return
}
if {[set file [get_rrfile $domain]] == ""} {
ErrorPush {} 1 SCO_DNSOSA_ERR_DOMAIN $domain
}
dns_readfile $domain $file
}
proc dns_readfile {domain file} {
global dns_outercontext
global dns_openfiles dns_filename dns_addhandle
global dns_origin dns_lastname dns_soa dns_domain dns_newindex
global dns_lineindexes dns_lines dns_records dns_cnames dns_namelines
global dns_hinfo dns_rp dns_mx dns_txt
if {$dns_domain == $domain} {
return
}
dns_writefile
catch {unset dns_lines}
catch {unset dns_lineindexes}
catch {unset dns_records}
catch {unset dns_cnames}
catch {unset dns_hinfo}
catch {unset dns_rp}
catch {unset dns_mx}
catch {unset dns_txt}
catch {unset dns_namelines}
catch {unset dns_openfiles}
set dns_origin $domain
set dns_domain $domain
set dns_lastname {??}
set dns_soa ""
set dns_filename [dns_locate $file]
set infile [ownerOpen readfile $dns_filename]
if {$infile == -1} {
ErrorPush {} 1 SCO_DNSOSA_ERR_OPEN_RD $dns_filename
}
keylset dns_openfiles($infile) name $dns_filename modified 0
scanfile $dns_outercontext $infile
foreach handle [array names dns_openfiles] {
close $handle
}
set dns_addhandle $infile
set dns_newindex 0
}
proc dns_writefile {} {
global dns_modified dns_lineindexes dns_lines dns_openfiles
global restart_server
if {$dns_modified} {
storeSOA
foreach handle [array names dns_openfiles] {
set fdata $dns_openfiles($handle)
if {[keylget fdata modified]} {
set fname [keylget fdata name]
backup_file $fname
set outhandle [ownerOpen writefile $fname]
if {$outhandle == -1} {
ErrorPush {} 1 SCO_DNSOSA_ERR_NO_FILE $fname
}
keylset dns_openfiles($handle) outhandle $outhandle
}
}
foreach line $dns_lineindexes {
set inhandle [lindex [split $line .] 0]
if [keylget dns_openfiles($inhandle) outhandle outhandle] {
puts $outhandle $dns_lines($line)
}
}
foreach handle [array names dns_openfiles] {
if [keylget dns_openfiles($handle) outhandle outhandle] {
close $outhandle
}
}
set restart_server 1
}
set dns_modified 0
}
proc dns_init {} {
global dns_domain dns_modified
setup_RR_scancontexts
set dns_domain ""
set dns_modified 0
}
proc ht_getaddr line {
return [lindex $line 0]
}
proc ht_getaliases line {
return [lrange [lindex [split $line #] 0] 1 end]
}
proc ht_getcomment line {
set foo [split $line #]
if {[llength $foo] == 1} {
return {}
}
return [string trim [lindex $foo 1]]
}
proc setup_host_scancontext {} {
global host_scontext
set host_scontext [scancontext create]
scanmatch $host_scontext {^} {
global host_lines host_lineindexes
set lineindex $matchInfo(linenum)
set host_lines($lineindex) $matchInfo(line)
lappend host_lineindexes $lineindex
}
scanmatch $host_scontext {(^[ ]*#)|(^[ ]*$)} {
continue
}
scanmatch $host_scontext {^[ ]*[0-9.]+[ ]+[^ #]+} {
global host_byaddr host_byname
set host_byaddr($lineindex) [ht_getaddr $matchInfo(line)]
set host_byname($lineindex) [ht_getaliases $matchInfo(line)]
continue
}
scanmatch $host_scontext "^" {
ErrorPush {} 1 SCO_DNSOSA_ERR_BAD_LINE $matchInfo(line)
}
}
proc host_list {} {
global host_byname
if [catch {array names host_byname} result] {
set result {}
}
return [lrmdups $result]
}
proc host_addhost {name addr aliases comment} {
global host_lines host_lineindexes host_newindex host_modified
global host_byaddr host_byname
if {($aliases == {}) || ($addr == {})} {
ErrorPush {} 1 SCO_DNSOSA_ERR_NO_HOST
}
if {[lempty $comment]} {
set line "$addr $aliases"
} else {
set line "$addr $aliases # $comment"
}
set lineindex [format "new_%s" $host_newindex]
incr host_newindex
set host_lines($lineindex) $line
lappend host_lineindexes $lineindex
set host_byaddr($lineindex) $addr
set host_byname($lineindex) $aliases
set host_modified 1
return $lineindex
}
proc host_rmhost {lineindex} {
global host_lineindexes host_byname host_byaddr
global host_modified host_lines
if {![info exists host_byname($lineindex)]} {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$lineindex"
}
set line $host_lines($lineindex)
if {[set index [lsearch $host_lineindexes $lineindex]] == -1} {
ErrorPush {} 1 SCO_DNSOSA_ERR_ILLEGAL \
[list "host_rmline" $lineindex]
}
lvarpop host_lineindexes $index
unset host_lines($lineindex)
unset host_byaddr($lineindex)
unset host_byname($lineindex)
set host_modified 1
}
proc host_getindex {lineindex} {
global host_byname
if {! [info exists host_byname($lineindex)]} {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$lineindex"
}
return $lineindex
}
proc host_getname {lineindex} {
global host_byname
return $host_byname([host_getindex $lineindex])
}
proc host_getaddr {lineindex} {
global host_byname host_lines
if {! [info exists host_byname($lineindex)]} {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$lineindex"
}
return [ht_getaddr $host_lines($lineindex)]
}
proc host_setaddrs {lineindex addr} {
global host_byname host_lines host_byaddr host_modified
if {[llength $addr] != 1} {
ErrorPush {} 1 SCO_DNSOSA_ERR_HOSTS
}
if {! [info exists host_byname($lineindex)]} {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$lineindex"
}
set oldaddr [ht_getaddr $host_lines($lineindex)]
unset host_byaddr($lineindex)
set host_byaddr($lineindex) $addr
set host_lines($lineindex) [lreplace $host_lines($lineindex) 0 0 $addr]
set host_modified 1
}
proc host_addaddr {name addr} {
ErrorPush {} 1 SCO_DNSOSA_ERR_HOSTS
}
proc host_rmaddr {name addr} {
ErrorPush {} 1 SCO_DNSOSA_ERR_HOSTS
}
proc host_getaliases {lineindex} {
global host_byname host_lines
if {! [info exists host_byname($lineindex)]} {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$lineindex"
}
return [ht_getaliases $host_lines($lineindex)]
}
proc host_setaliases {lineindex aliases} {
global host_byname host_lines host_modified
if {! [info exists host_byname($lineindex)]} {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$lineindex"
}
set line $host_lines($lineindex)
set addr [ht_getaddr $line]
set comment [ht_getcomment $line]
if {[lempty $comment]} {
set host_lines($lineindex) "$addr $aliases"
} else {
set host_lines($lineindex) "$addr $aliases # $comment"
}
set host_modified 1
}
proc host_addalias {name alias} {
global host_byname host_lines
if [catch {set lineindex $host_byname($name)}] {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
set aliases [ht_getaliases $host_lines($lineindex)]
lappend aliases $alias
host_setaliases $name $aliases
}
proc host_rmalias {name alias} {
global host_byname host_lines
if [catch {set lineindex $host_byname($name)}] {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$name"
}
set aliases [ht_getaliases $host_lines($lineindex)]
if {[set index [lsearch $aliases $alias]] == -1} {
ErrorPush {} 1 SCO_DNSOSA_ERR_NOT_ALIAS [list $alias {}]
}
lvarpop aliases $index
host_setaliases $name $aliases
}
proc host_getcomment {lineindex} {
global host_byname host_lines
if {! [info exists host_byname($lineindex)]} {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$lineindex"
}
return [ht_getcomment $host_lines($lineindex)]
}
proc host_setcomment {lineindex comment} {
global host_byname host_lines host_modified
if {! [info exists host_byname($lineindex)]} {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$lineindex"
}
set line $host_lines($lineindex)
if {[lempty $comment]} {
set host_lines($lineindex) "[lindex [split $line #] 0]"
} else {
set host_lines($lineindex) "[lindex [split $line #] 0] # $comment"
}
set host_modified 1
}
proc host_readfile {} {
global host_scontext host_file host_read host_newindex
if {$host_read} {
return
}
set host_read 1
set infile [ownerOpen readfile $host_file]
if {$infile == -1} {
ErrorPush {} 1 SCO_DNSOSA_ERR_OPEN_RD $host_file
}
scanfile $host_scontext $infile
close $infile
set host_newindex 0
}
proc host_writefile {} {
global host_file host_modified host_lineindexes host_lines
global host_read restart_server
if {$host_read && $host_modified} {
set outfile [ownerOpen writefile $host_file]
if {$outfile == -1} {
ErrorPush {} 1 SCO_DNSOSA_ERR_OPEN_WR $host_file
}
foreach line $host_lineindexes {
if {![lempty $host_lines($line)]} {
puts $outfile $host_lines($line)
}
}
close $outfile
set restart_server 1
}
set host_modified 0
}
proc host_init {} {
global IPAddrMap_ConfigDir
global host_file host_read host_modified
setup_host_scancontext
set host_file /etc/hosts
set host_read 0
set host_modified 0
}
proc GetObjectId {instance attrName depth} {
if {[llength $instance] < [expr "$depth + 1"]} {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$instance"
}
set objectString [lindex $instance $depth]
if {[llength $objectString] == 1} {
return $objectString
}
if {[llength $objectString] != 2} {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_OBJECT_INSTANCE "$objectString"
}
if {[lindex $objectString 0] != $attrName} {
ErrorPush {} 1 SCO_DNSOSA_ERR_INVALID_ATTR \
[lindex $objectString 0]
}
return [lindex $objectString 1]
}
proc CheckEnums {pList eList} {
upvar $pList paramList
upvar $eList enumList
foreach enum $enumList {
set arg [lindex $enum 0]
if { ! [keylget paramList $arg value]} {
continue
}
set allowed [lindex $enum 1]
if {[lsearch $allowed $value] == -1} {
ErrorPush {} 1 SCO_DNSOSA_ERR_BAD_VAL [list $value $arg]
}
}
}
proc GetValueList {pList nameList} {
upvar $pList paramList
set result {}
foreach name $nameList {
if {! [keylget paramList [lindex $name 0] value]} {
if {[llength $name] == 2} {
lappend result [lindex $name 1]
} else {
ErrorPush {} 1 SCO_DNSOSA_ERR_NO_PARAM $name
}
} else {
lappend result $value
}
}
return $result
}
proc GetRequiredValue {pList name} {
upvar $pList paramList
if {! [keylget paramList $name value]} {
ErrorPush {} 1 SCO_DNSOSA_ERR_NO_PARAM $name
}
return $value
}
proc GetFilterClass {filter} {
if {([llength $filter] != 3)
|| ([lindex $filter 0] != "objectClass")
|| ([lindex $filter 1] != "eq")} {
error "only class filters supported: $filter"
}
return [lindex $filter 2]
}
proc MakeResponseList {invokeId class instance nameList} {
set result {}
foreach name $nameList {
if {$instance != {}} {
set iname [list [concat $instance $name]]
} else {
set iname $name
}
lappend result [list {operation get} \
"invokeId $invokeId" {linkedId 1} \
"objectClass {$class}" "objectInstance $iname" \
"attributeList {{name $name}}" \
{actionType {}} {actionInfo {}} {errorParameter {}}]
}
return $result
}
proc HandleScopedRequest {scope osaData sessionId bmipRequest} {
global contained
if {$scope != "firstLevelOnly"} {
ErrorPush {} 1 SCO_DNSOSA_ERR_SCOPE $scope
}
set class [keylget bmipRequest objectClass]
set invokeId [keylget bmipRequest invokeId]
set objectList [keylget bmipRequest objectInstance]
if {$objectList == {}} {set objectList {{}}}
set filter [keylget bmipRequest filter]
if {$filter != {}} {
set filterClass [GetFilterClass $filter]
} else {
set filterClass {}
}
if [catch {set classList $contained($class)}] {
error "class $class not a container"
}
set heldResp {}
foreach classData $classList {
set containedClass [lindex $classData 0]
if {$filterClass != {} && $filterClass != $containedClass} {
continue
}
set listCommand [lindex $classData 1]
foreach object $objectList {
set sublist [eval $listCommand $object]
foreach resp [MakeResponseList $invokeId $containedClass \
$object $sublist] {
if {$heldResp != {}} {
OFReturnBmipResponse $sessionId heldResp TRUE
}
set heldResp $resp
}
}
}
if {$heldResp != {}} {
OFReturnBmipResponse $sessionId heldResp FALSE
}
}
proc ValidationRoutine {osaData sessionId bmipRequest} {
set scope [keylget bmipRequest scope]
if {$scope != {}} {
HandleScopedRequest $scope $osaData $sessionId $bmipRequest
return
}
set class [keylget bmipRequest objectClass]
set objectList [keylget bmipRequest objectInstance]
if {$objectList == {}} { set objectList {{}}}
set listLength [llength $objectList]
foreach object $objectList {
set bmipResponse [OFEvaluateOperation $sessionId $object]
incr listLength -1
if "($listLength < 1)" {
set continue FALSE
} {
set continue TRUE
}
OFReturnBmipResponse $sessionId bmipResponse $continue
}
}
proc _keylget {var match} {
upvar $var klist
foreach i $klist {
lassign $i key val
if {[cequal $match $key]} {
return $val
}
}
return {}
}
proc named_boot_path {} {
global IPAddrMap_ConfigDir
return [format "%s/named.boot" $IPAddrMap_ConfigDir]
}
proc get_named_boot {} {
set fpath [named_boot_path]
if {[owner file exists $fpath]} {
set res {}
net:for_file line $fpath {
if {[regexp {^[ | ]*;} $line] || \
[regexp {^[ | ]*$} $line]} {
continue
}
append res $line "\n"
}
return $res
} else {
return {}
}
}
proc deconfig_named_boot {} {
set fpath [named_boot_path]
if {[owner file exists $fpath]} {
owner unlink -nocomplain $fpath
}
}
proc get_pid {} {
global named_pid_file
set ret [catch {exec /bin/ps -e | grep in.named | grep -v grep} res]
if {(! $ret) && (! [lempty $res])} {
return [lindex $res 0]
}
return {}
}
proc restart_named {} {
set pid [get_pid]
if {![lempty $pid]} {
catch {owner kill SIGHUP $pid}
}
return $pid
}
proc get_status {} {
if {[lempty [get_pid]]} {
return 0
} else {
return 1
}
}
proc enable_named {} {
if {[lempty [restart_named]]} {
if {[id userid] == 0} {
catch {exec /usr/sbin/in.named}
} else {
catch {exec /sbin/tfadmin swUser root /usr/sbin/in.named}
}
}
}
proc disable_named {} {
global named_pid_file
set pid [get_pid]
if ![lempty $pid] {
;# try and kill named gracefully
catch {owner kill SIGTERM $pid}
catch {owner kill SIGKILL $pid}
owner unlink -nocomplain $named_pid_file
}
}
proc isdotteddec {string} {
return [regexp {[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} $string]
}
proc addrmatch {addr1 addr2} {
if { ! ( [isdotteddec $addr1] && [isdotteddec $addr2] )} {
return 0
}
set list1 [split $addr1 "."]
set list2 [split $addr2 "."]
loop i 0 4 {
if {[lindex $list1 $i] != [lindex $list2 $i]} {
return 0
}
}
return 1
}
proc cvtsecs secs {
set nums "31557600 604800 86400 3600 60 1"
set names [IntlLocalizeMsg SCO_DNSOSA_MSG_TIME]
set plural [IntlLocalizeMsg SCO_DNSOSA_MSG_TIMES]
set result ""
loop i 0 [llength $nums] {
if {[set num [expr $secs/[lindex $nums $i]]] != 0} {
if {$num == 1} {
append result " $num [lindex $names $i]"
} else {
append result " $num [lindex $plural $i]"
}
set secs [expr "$secs % [lindex $nums $i]"]
}
}
return $result
}
proc move_file {oldname newname} {
if { ! [owner file isfile $oldname]} {
return 0
}
if [catch {
owner unlink -nocomplain $newname
owner link $oldname $newname
owner unlink $oldname
}] {
ErrorPush {} 1 SCO_DNSOSA_ERR_MV [list $oldname $newname]
}
return 0
}
proc backup_file {name} {
move_file $name $name-
}
proc compare_files {f1 f2} {
if {[id userid] == 0} {
return [catch {exec /bin/cmp $f1 $f2}]
} else {
return [catch {exec /sbin/tfadmin swUser root /bin/cmp $f1 $f2}]
}
}
proc copy_file {f1 f2} {
if { ! [owner file isfile $f1]} {
return 0
}
if {[id userid] == 0} {
set ret [catch {exec /bin/cp -f $f1 $f2}]
} else {
set ret [catch {exec /sbin/tfadmin cpfile $f1 $f2}]
}
if {$ret} {
ErrorPush {} 1 SCO_DNSOSA_ERR_CP [list $f1 $f2]
}
}
proc lsubtract {list1 list2 {matcher {}}} {
set list1 [lrmdups $list1]
set list2 [lrmdups $list2]
set result {}
while {! ([lempty $list1] || [lempty $list2])} {
set element1 [lindex $list1 0]
set element2 [lindex $list2 0]
if {$matcher != {}} {
if [$matcher $element1 $element2] {
lvarpop list1
lvarpop list2
continue
}
}
if {$element1 < $element2} {
lappend result [lvarpop list1]
continue
}
if {$element2 < $element1} {
lvarpop list2
continue
}
lvarpop list1
lvarpop list2
}
if { ! [lempty $list1]} {
set result [concat $result $list1]
}
return $result
}
proc lmatch {list1 list2} {
set count 0
while { ( ! [lempty $list1]) && ( ! [lempty $list2])} {
if {[lvarpop list1] != [lvarpop list2]} {
return $count
}
incr count
}
return $count
}
proc lreverse {list} {
set len [llength $list]
set result {}
while {$len} {
incr len -1
lappend result [lindex $list $len]
}
return $result
}
proc BuildCacheFile {} {
global boot_caches boot_directory
set output [CallNonStdCmd /usr/sbin/dig ". ns" \
SCO_DNS_ERR_UNIX errStack]
if [catch {array names boot_caches} linelist] {
ErrorPush {} 1 SCO_DNSOSA_ERR_NO_CACHE
} else {
set cache $boot_caches([lindex $linelist 0])
}
if {[lempty $output] || ! [lempty $errStack]} {
return
}
set fpath [format "%s/%s" $boot_directory $cache]
set fd [ownerOpen writefile $fpath]
if {$fd == -1} {
ErrorPush {} 1 SCO_DNSOSA_ERR_OPEN_WR $fpath
}
puts $fd $output
close $fd
}
proc BuildReverseFile {zone networks} {
global dns_soa dns_origin boot_directory
dns_readdomain $zone
lassign $dns_soa ign mailbox serial refresh retry expire minimum
set serial [SetSerial $serial noincr]
set fpath [format "%s/db.local" $boot_directory]
set fp [ownerOpen writefile $fpath]
if {$fp == -1} {
ErrorPush {} 1 SCO_DNSOSA_ERR_OPEN_WR $fpath
}
foreach network $networks {
set file [lindex $network 1]
set fd($file) [ownerOpen writefile $file w+]
if {$fd($file) == -1} {
catch {unset fd($file)}
ErrorPush {} 1 SCO_DNSOSA_ERR_OPEN_WR $file
}
puts $fd($file) [makeSOA "@ IN SOA" [exec /usr/ucb/hostname]. $mailbox $serial [list $refresh $retry $expire $minimum]]
puts $fd($file) [format "\tIN\tNS\t%s." [exec /usr/ucb/hostname]]
}
puts $fp [makeSOA "@ IN SOA" [exec /usr/ucb/hostname]. $mailbox $serial [list $refresh $retry $expire $minimum]]
puts $fp [format "\tIN\tNS\t%s." [exec /usr/ucb/hostname]]
set hosts [lrmdups [dns_getnamesbytype A]]
foreach host $hosts {
set addrs [dns_getdatabyname $host a]
foreach addr $addrs {
foreach network $networks {
set netaddr [lindex $network 0]
if {[string first $netaddr $addr] > -1} {
set file [lindex $network 1]
set ptr [split $addr "."]
set ptr [lreverse $ptr]
set ptr [join $ptr "."]
set ptr "${ptr}.in-addr.arpa."
set host [string tolower $host]
if {! [string match {*.} $host]} {
set host "${host}.${dns_origin}."
}
puts $fd($file) "$ptr IN PTR $host"
break
}
}
}
}
foreach file [array names fd] {
close $fd($file)
}
puts $fp "1\tIN\tPTR\tlocalhost." ;# add localhost entry
close $fp ;# close db.local
}
proc hostTab_open {
class object objectRef operation subOperation filterData attribute attrValueList
handle} {
set table [GetObjectId $object hostTabName 0]
if {$table == "/etc/hosts"} {
host_readfile
} else {
dns_readdomain $table
}
}
proc dNSystem_get {class object refObject op subOp data attr attrValueList osaData} {
global dns_currentmode
case $attr {
dNSMode {
set result $dns_currentmode
return [list [list $attr $result]]
}
dNSForwarders {
set result [list_forwarders]
return [list [list $attr $result]]
}
dNSBogusns {
set result [list_bogusns]
return [list [list $attr $result]]
}
dNSXfrnets {
set result [list_xfrnets]
return [list [list $attr $result]]
}
dNSSortlist {
set result [list_sortlist]
return [list [list $attr $result]]
}
dNSResolvers {
set result [list_resolvers]
return [list [list $attr $result]]
}
slave {
set result [get_slaveflag]
return [list [list $attr $result]]
}
OptsNoRecursion {
set result [get_norecursionflag]
return [list [list $attr $result]]
}
OptsQueryLog {
set result [get_querylogflag]
return [list [list $attr $result]]
}
OptsFetchGlue {
set result [get_fetchglueflag]
return [list [list $attr $result]]
}
XferIn {
set result [get_xferinlimit]
return [list [list $attr $result]]
}
XferPerNs {
set result [get_xferpernslimit]
return [list [list $attr $result]]
}
XferDatasize {
set result [get_xferdatasize]
return [list [list $attr $result]]
}
domain {
set result [get_domain]
return [list [list $attr $result]]
}
hostresorder {
set result [get_hostresorder]
return [list [list $attr $result]]
}
search {
set result [get_searchorder]
return [list [list $attr $result]]
}
resSortlist {
set result [get_resSortlist]
return [list [list $attr $result]]
}
name {
return [list [list $attr dummy]]
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr $class"
}
}
}
proc dNSystem_replace {class object refObject op subOp data attr attrValueList osaData} {
global dns_selectedmode
set value [keylget attrValueList $attr]
case $attr {
dNSMode {
set dns_selectedmode $value
dns_done
return 1
}
dNSForwarders {
foreach forw [list_forwarders] {
rm_forwarder $forw
}
foreach forw $value {
add_forwarder $forw
}
return 1
}
dNSBogusns {
foreach bogusns [list_bogusns] {
rm_bogusns $bogusns
}
foreach bogusns $value {
add_bogusns $bogusns
}
return 1
}
dNSXfrnets {
foreach xfrnet [list_xfrnets] {
rm_xfrnets $xfrnet
}
foreach xfrnet $value {
add_xfrnets $xfrnet
}
return 1
}
dNSSortlist {
foreach network [list_sortlist] {
rm_sortlist $network
}
foreach network $value {
add_sortlist $network
}
return 1
}
dNSResolvers {
foreach res [list_resolvers] {
rm_resolver $res
}
foreach res $value {
add_resolver $res
}
return 1
}
domain {
rm_domain
if ![lempty $value] {
set_domain $value
}
return 1
}
hostresorder {
rm_hostresorder
set_hostresorder $value
return 1
}
search {
rm_searchorder
if ![lempty $value] {
set_searchorder $value
}
return 1
}
resSortlist {
rm_resSortlist
set_resSortlist $value
return 1
}
slave {
return [set_slaveflag $value]
}
OptsNoRecursion {
return [set_norecursionflag $value]
}
OptsQueryLog {
return [set_querylogflag $value]
}
OptsFetchGlue {
return [set_fetchglueflag $value]
}
XferIn {
return [set_xferinlimit $value]
}
XferPerNs {
return [set_xferpernslimit $value]
}
XferDatasize {
return [set_xferdatasize $value]
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr $class"
}
}
}
proc dNSystem_add {class object refObject op subOp data attr attrValueList osaData} {
set value [keylget attrValueList $attr]
case $attr {
dNSForwarders {
foreach forw $value {
add_forwarder $forw
}
}
dNSBogusns {
foreach bogusns $value {
add_bogusns $bogusns
}
}
dNSXfrnets {
foreach xfrnet $value {
add_xfrnets $xfrnet
}
}
dNSSortlist {
foreach network $value {
add_sortlist $network
}
}
dNSResolvers {
foreach res $value {
add_resolver $res
}
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr $class"
}
}
}
proc dNSystem_remove {class object refObject op subOp data attr attrValueList osaData} {
set value [keylget attrValueList $attr]
case $attr {
dNSForwarders {
foreach forw $value {
rm_forwarder $forw
}
}
dNSBogusns {
foreach bogusns $value {
rm_bogusns $bogusns
}
}
dNSXfrnets {
foreach xfrnet $value {
rm_xfrnets $xfrnet
}
}
dNSSortlist {
foreach network $value {
rm_sortlist $network
}
}
dNSResolvers {
foreach res $value {
rm_resolver $res
}
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr $class"
}
}
}
proc dNSystem_action {class object refObject op subOp data attr attrValueList osaData} {
global dns_soa
switch $subOp {
deconfig { return [deconfig_named_boot]
}
configured { return [get_named_boot]
}
enable { return [enable_named]
}
disable { return [disable_named]
}
status { return [get_status]
}
restart { return [restart_named]
}
ip { set output [CallNonStdCmd /usr/sbin/host "$data" \
SCO_DNS_ERR_UNIX errStack]
if {[string length $errStack]!=0} then {
set output [ErrorText errStack]
}
return [lindex $output end]
}
test { set output [CallNonStdCmd /usr/sbin/host "-v $data" \
SCO_DNS_ERR_UNIX errStack]
if {[string length $errStack]!=0} then {
set output [ErrorText errStack]
}
return $output
}
create_root { BuildCacheFile
return
}
create_ptr {
lassign $data zone networks
BuildReverseFile $zone $networks
return
}
default { ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ACTION "$subOp"
}
}
}
proc hostTabEntry_get {class object refObject op subOp data attr attrValueList osaData} {
set table [GetObjectId $object name 0]
set entry [GetObjectId $object name 1]
if {$table == "/etc/hosts"} {
host_readfile
case $attr {
name {
set result [host_getindex $entry]
return [list [list $attr $result]]
}
aliasList {
set result [host_getaliases $entry]
return [list [list $attr $result]]
}
addrList {
set result [host_getaddr $entry]
return [list [list $attr $result]]
}
comment {
set result [host_getcomment $entry]
return [list [list $attr $result]]
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr $class"
}
}
} else {
dns_readdomain $table
case $attr {
name {
set result $entry
return [list [list $attr $result]]
}
aliasList {
set result [dns_getaliases $entry]
return [list [list $attr $result]]
}
addrList {
set result [dns_getaddrs $entry]
return [list [list $attr $result]]
}
mxList {
set result [dns_getmxs $entry]
return [list [list $attr $result]]
}
rpList {
set result [dns_getrps $entry]
return [list [list $attr $result]]
}
txtList {
set result [dns_gettxts $entry]
return [list [list $attr $result]]
}
hinfoList {
set result [dns_gethinfos $entry]
lassign [lindex $result 0] hw os
keylset hinfo hw $hw
keylset hinfo os $os
return [list [list $attr $hinfo]]
}
comment {
set result [dns_getcomment $entry]
return [list [list $attr $result]]
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr $class"
}
}
}
}
proc hostTabEntry_replace {class object refObject op subOp data attr attrValueList osaData} {
global dns_modified
set table [GetObjectId $object name 0]
set entry [GetObjectId $object name 1]
set value [keylget attrValueList $attr]
if {$table == "/etc/hosts"} {
host_readfile
case $attr {
aliasList {
set result [host_setaliases $entry $value]
}
addrList {
set result [host_setaddrs $entry $value]
}
comment {
set result [host_setcomment $entry $value]
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr $class"
}
}
host_writefile
} else {
dns_readdomain $table
case $attr {
aliasList {
set result [dns_setaliases $entry $value]
}
addrList {
set result [dns_setaddrs $entry $value]
}
mxList {
set result [dns_setmxs $entry $value]
}
rpList {
set result [dns_setrps $entry $value]
}
txtList {
set result [dns_settxts $entry $value]
}
hinfoList {
set result [dns_sethinfos $entry $value]
}
comment {
set result [dns_setcomment $entry $value]
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr"
}
}
set dns_modified 1
dns_writefile
}
return $result
}
proc hostTabEntry_add {class object refObject op subOp data attr attrValueList osaData} {
set table [GetObjectId $object name 0]
set entry [GetObjectId $object name 1]
set value [keylget attrValueList $attr]
if {$table == "/etc/hosts"} {
host_readfile
case $attr {
aliasList {
foreach alias $value {
host_addalias $entry $alias
}
return 1
}
addrList {
return [host_addaddr $entry $value]
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr"
}
}
host_writefile
} else {
dns_readdomain $table
case $attr {
addrList {
return [dns_addaddrs $entry $value {}]
}
aliasList {
return [dns_addaliases $entry $value]
}
mxList {
return [dns_addmxs $entry $value]
}
rpList {
return [dns_addrps $entry $value]
}
txtList {
return [dns_addtxts $entry $value]
}
hinfoList {
return [dns_addhinfos $entry $value]
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr"
}
}
}
}
proc hostTabEntry_remove {class object refObject op subOp data attr attrValueList osaData} {
global dns_modified
set table [GetObjectId $object name 0]
set entry [GetObjectId $object name 1]
set value [keylget attrValueList $attr]
if {$table == "/etc/hosts"} {
host_readfile
case $attr {
aliasList {
set result [host_rmalias $entry $value]
}
addrList {
set result [host_rmaddr $entry $value]
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr"
}
}
host_writefile
} else {
dns_readdomain $table
case $attr {
aliasList {
set result [dns_rmaliases $entry $value]
}
addrList {
set result [dns_rmaddrs $entry $value]
}
mxList {
set result [dns_rmmxs $entry $value]
}
rpList {
set result [dns_rmrps $entry $value]
}
txtList {
set result [dns_rmtxts $entry $value]
}
hinfoList {
set result [dns_rmhinfos $entry $value]
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr"
}
}
set dns_modified 1
dns_writefile
}
return $result
}
proc hostTabEntry_create {class object refObject op subOp data attr attrValueList osaData} {
global dns_modified
set ret 0
set table [GetObjectId $object name 0]
set entry [GetObjectId $object name 1]
if {$table == "/etc/hosts"} {
host_readfile
set vlist [GetValueList attrValueList {addrList {aliasList {}} {comment {}}}]
set ret [eval host_addhost $entry $vlist]
host_writefile
} else {
dns_readdomain $table
set vlist [GetValueList attrValueList {addrList {aliasList {}} {mxList {}} {rpList {}} {txtList {}} {hinfoList {}} {comment {}}}]
eval dns_addhost $entry $vlist
set dns_modified 1
dns_writefile
}
return $ret
}
proc hostTabEntry_delete {class object refObject op subOp data attr attrValueList osaData} {
set table [GetObjectId $object name 0]
set entry [GetObjectId $object name 1]
if {$table == "/etc/hosts"} {
host_readfile
host_rmhost $entry
host_writefile
} else {
dns_readdomain $table
dns_rmhost $entry
}
}
proc hostTabEntry_list {class object refObject op subOp data attr attrValueList osaData} {
set table [GetObjectId $object name 0]
if {$table == "/etc/hosts"} {
host_readfile
set objects [host_list]
} else {
dns_readdomain $table
set objects [lrmdups [dns_getnamesbytype A]]
}
set results {}
foreach object $objects {
lappend results [list $table $object]
}
return $results
}
proc hostTabs_get {class object refObject op subOp data attr attrValueList osaData} {
case $attr {
name {
return [list [list $attr dummy]]
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr"
}
}
}
proc dNSSecondary_get {class object refObject op subOp data attr attrValueList osaData} {
set domain [GetObjectId $object name 0]
case $attr {
name {
set result $domain
return [list [list $attr $result]]
}
serverList {
set result [lindex [get_secondary $domain] 0]
return [list [list $attr $result]]
}
file {
set result [lindex [get_secondary $domain] 1]
return [list [list $attr $result]]
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr"
}
}
}
proc dNSSecondary_add {class object refObject op subOp data attr attrValueList osaData} {
set domain [GetObjectId $object name 0]
set value [keylget attrValueList $attr]
case $attr {
serverList {
foreach serv $value {
sec_addserver $domain $serv
}
return
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr"
}
}
}
proc dNSSecondary_replace {class object refObject op subOp data attr attrValueList osaData} {
set domain [GetObjectId $object name 0]
set value [keylget attrValueList $attr]
case $attr {
serverList {
set curlist [lindex [get_secondary $domain] 0]
set newlist [lsubtract $value $curlist]
set rmlist [lsubtract $curlist $value]
foreach serv $rmlist {
sec_rmserver $domain $serv
}
foreach serv $newlist {
sec_addserver $domain $serv
}
}
file {
return [sec_setbackup $domain $value]
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr"
}
}
}
proc dNSSecondary_remove {class object refObject op subOp data attr attrValueList osaData} {
set domain [GetObjectId $object name 0]
set value [keylget attrValueList $attr]
case $attr {
serverList {
foreach serv $value {
sec_rmserver $domain $serv
}
return
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr"
}
}
}
proc dNSSecondary_create {class object refObject op subOp data attr attrValueList osaData} {
set domain [GetObjectId $object name 0]
set vlist [GetValueList attrValueList {serverList {file {}}}]
return [eval add_secondary $domain $vlist]
}
proc dNSSecondary_delete {class object refObject op subOp data attr attrValueList osaData} {
set domain [GetObjectId $object name 0]
return [rm_secondary $domain]
}
proc dNSSecondary_list {class object refObject op subOp data attr attrValueList osaData} {
return [list_secondaries]
}
proc hostTab_get {class object refObject op subOp data attr attrValueList osaData} {
set table [GetObjectId $object name 0]
case $attr {
name {
set result $table
return [list [list $attr $result]]
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr"
}
}
}
proc hostTab_list {class object refObject op subOp data attr attrValueList osaData} {
return [concat /etc/hosts [list_primaries] [list_secondaries] [list_stubs]]
}
proc dNSHint_get {class object refObject op subOp data attr attrValueList osaData} {
set name [GetObjectId $object name 0]
dns_readhints
case $attr {
name {
set result $name
return [list [list $attr $result]]
}
addrList {
set result [dns_getaddrs $name]
return [list [list $attr $result]]
}
comment {
set result [dns_getcomment $name]
return [list [list $attr $result]]
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr"
}
}
}
proc dNSHint_replace {class object refObject op subOp data attr attrValueList osaData} {
set name [GetObjectId $object name 0]
set value [keylget attrValueList $attr]
dns_readhints
case $attr {
addrList {
return [dns_setaddrs $name $value]
}
comment {
return [dns_setcomment $name $value]
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr"
}
}
}
proc dNSHint_create {class object refObject op subOp data attr attrValueList osaData} {
set name [GetObjectId $object name 0]
set vlist [GetValueList attrValueList {addrList {comment {}}}]
return [eval dns_addhint $name $vlist]
}
proc dNSHint_delete {class object refObject op subOp data attr attrValueList osaData} {
set name [GetObjectId $object name 0]
return [dns_rmhint $name]
}
proc dNSHint_add {class object refObject op subOp data attr attrValueList osaData} {
set name [GetObjectId $object name 0]
set value [keylget attrValueList $attr]
case $attr {
addrList {
dns_readhints
return [dns_addaddrs $name $value {}]
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr"
}
}
}
proc dNSHint_remove {class object refObject op subOp data attr attrValueList osaData} {
set name [GetObjectId $object name 0]
set value [keylget attrValueList $attr]
case $attr {
addrList {
dns_readhints
return [dns_rmaddrs $name $value]
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr"
}
}
}
proc dNSHint_list {class object refObject op subOp data attr attrValueList osaData} {
return [dns_gethintnames]
}
proc dNSPrimary_get {class object refObject op subOp data attr attrValueList osaData} {
global dns_soa
set domain [GetObjectId $object name 0]
dns_readdomain $domain
case $attr {
name {
set result $domain
return [list [list $attr $result]]
}
serverList {
set result [dns_getservers $domain]
return [list [list $attr $result]]
}
file {
set result [get_rrfile $object]
return [list [list $attr $result]]
}
mailbox {
return [list [list $attr [lindex $dns_soa 1]]]
}
serial {
return [list [list $attr [lindex $dns_soa 2]]]
}
refresh {
return [list [list $attr [lindex $dns_soa 3]]]
}
retry {
return [list [list $attr [lindex $dns_soa 4]]]
}
expire {
return [list [list $attr [lindex $dns_soa 5]]]
}
minimum {
return [list [list $attr [lindex $dns_soa 6]]]
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr"
}
}
}
proc dNSPrimary_replace {class object refObject op subOp data attr attrValueList osaData} {
global dns_soa dns_modified
set value [keylget attrValueList $attr]
set domain [GetObjectId $object name 0]
dns_readdomain $domain
case $attr {
file {
return [change_rrfile $object $value]
}
serverList {
set curlist [dns_getservers $domain]
if [lempty $value] {
set newlist ""
set rmlist $curlist
set addlist ""
} else {
set newlist [keylkeys value]
set rmlist [lsubtract $curlist $newlist]
set addlist [lsubtract $newlist $curlist]
}
foreach serv [keylkeys rmlist] {
dns_rmserver $domain $serv
}
foreach serv [keylkeys addlist] {
dns_addserver $domain $serv \
[_keylget value $serv] {}
}
}
mailbox {
set dns_soa [lreplace $dns_soa 1 1 $value]
storeSOA
}
serial {
set dns_soa [lreplace $dns_soa 2 2 $value]
storeSOA
}
refresh {
set dns_soa [lreplace $dns_soa 3 3 $value]
storeSOA
}
retry {
set dns_soa [lreplace $dns_soa 4 4 $value]
storeSOA
}
expire {
set dns_soa [lreplace $dns_soa 5 5 $value]
storeSOA
}
minimum {
set dns_soa [lreplace $dns_soa 6 6 $value]
storeSOA
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr"
}
}
set dns_modified 1
dns_writefile
return 1
}
proc dNSPrimary_create {class object refObject op subOp data attr attrValueList osaData} {
set name [GetObjectId $object name 0]
set vlist [GetValueList attrValueList \
{file serverList mailbox \
{serial 1} {refresh 21600} {retry 900} \
{expire 604800} {minimum 3600}}]
return [eval add_primary $name $vlist]
}
proc dNSPrimary_delete {class object refObject op subOp data attr attrValueList osaData} {
set name [GetObjectId $object name 0]
return [rm_primary $name]
}
proc dNSPrimary_list {class object refObject op subOp data attr attrValueList osaData} {
return [list_primaries]
}
proc dNSStub_get {class object refObject op subOp data attr attrValueList osaData} {
set domain [GetObjectId $object name 0]
case $attr {
name {
set result $domain
return [list [list $attr $result]]
}
serverList {
set result [lindex [get_stub $domain] 0]
return [list [list $attr $result]]
}
file {
set result [lindex [get_stub $domain] 1]
return [list [list $attr $result]]
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr"
}
}
}
proc dNSStub_add {class object refObject op subOp data attr attrValueList osaData} {
set domain [GetObjectId $object name 0]
set value [keylget attrValueList $attr]
case $attr {
serverList {
foreach serv $value {
stub_addserver $domain $serv
}
return
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr"
}
}
}
proc dNSStub_replace {class object refObject op subOp data attr attrValueList osaData} {
set domain [GetObjectId $object name 0]
set value [keylget attrValueList $attr]
case $attr {
serverList {
set curlist [lindex [get_stub $domain] 0]
set newlist [lsubtract $value $curlist]
set rmlist [lsubtract $curlist $value]
foreach serv $rmlist {
stub_rmserver $domain $serv
}
foreach serv $newlist {
stub_addserver $domain $serv
}
}
file {
return [stub_setbackup $domain $value]
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr"
}
}
}
proc dNSStub_remove {class object refObject op subOp data attr attrValueList osaData} {
set domain [GetObjectId $object name 0]
set value [keylget attrValueList $attr]
case $attr {
serverList {
foreach serv $value {
stub_rmserver $domain $serv
}
return
}
default {
ErrorPush {} 1 SCO_OSA_ERR_NO_SUCH_ATTRIBUTE "$attr"
}
}
}
proc dNSStub_create {class object refObject op subOp data attr attrValueList osaData} {
set domain [GetObjectId $object name 0]
set vlist [GetValueList attrValueList {serverList {file {}}}]
return [eval add_stub $domain $vlist]
}
proc dNSStub_delete {class object refObject op subOp data attr attrValueList osaData} {
set domain [GetObjectId $object name 0]
return [rm_stub $domain]
}
proc dNSStub_list {class object refObject op subOp data attr attrValueList osaData} {
return [list_stubs]
}
proc dns_done {} {
global restart_server
dns_writefile
resolv_writemode
boot_writemode
if {$restart_server} {
enable_named
}
}
set restart_server 0
set IPAddrMap_ConfigDir /etc/inet
resolv_init
boot_init
host_init
dns_init
OFBinding sco_dNSystem_CDT
OFBinding sco_hostTabEntry_CDT
OFBinding sco_hostTabs_CDT
OFBinding sco_hostTab_CDT
OFBinding sco_dNSHint_CDT
OFBinding sco_dNSPrimary_CDT
OFBinding sco_dNSSecondary_CDT
OFBinding sco_dNSStub_CDT