set SCO_USER_MHOME_MSGS(@catalog@) {mhome.cat@mail 1}
set SCO_USER_MHOME_MSGS(MSG_HELPBOOK) {1 multihome}
set SCO_USER_MHOME_MSGS(ERR_OPEN_FAIL) {2 {Unable to open file: %1$s}}
set SCO_USER_MHOME_MSGS(ERR_NO_MAP) {3 {No map created for %1$s,\nfile contents may be invalid.}}
set SCO_USER_MHOME_MSGS(ERR_NOHOST) {4 {Host (%1$s) not found.}}
set SCO_USER_MHOME_MSGS(ERR_BADHOST) {5 {Host (%1$s) not responding.\nPlease check the following:\n * your network configuration\n * your network connection\n * rhost permissions on the remote site\n * that SCOadmin is installed at the remote site}}
set SCO_USER_MHOME_MSGS(ERR_COPY_OUT) {6 {Unable to fetch %1$s\nCreate new file?}}
set SCO_USER_MHOME_MSGS(ERR_COPY_BACK) {7 {Unable to copy back to %1$s.}}
set SCO_USER_MHOME_MSGS(ERR_PARSE) {8 {Parse errors are contained in %1$s\nContinue and remove bad lines?}}
set SCO_USER_MHOME_MSGS(ERR_WRITE) {9 {Unable to write %1$s.}}
set SCO_USER_MHOME_MSGS(ERR_NO_VDOMAINS) {10 {No virtual domains found.}}
set SCO_USER_MHOME_MSGS(ERR_BAD_SUSER) {11 {Bad system user.}}
set SCO_USER_MHOME_MSGS(ERR_BAD_VUSER) {12 {Bad virtual user.}}
set SCO_USER_MHOME_MSGS(ERR_DUP_VUSER) {13 {Duplicate virtual user.}}
set SCO_USER_MHOME_MSGS(ERR_EXEC) {14 {Unable to exec (%1$s).}}
set SCO_USER_MHOME_MSGS(ERR_RESOLV) {15 {Unable to resolve name (%1$s).}}
set SCO_USER_MHOME_MSGS(ERR_TFADMIN) {16 {Failure in tfadmin authorization check}}
set SCO_USER_MHOME_MSGS(MSG_DIRTY) {17 {Do you wish to save your changes?}}
set SCO_USER_MHOME_MSGS(MSG_DOMAIN_UPDATE) {18 {The virtual domain map file is out of date:\n(%1$s)\nDo you wish to rebuild it?}}
set SCO_USER_MHOME_MSGS(MSG_GO_BACK) {19 {Do you wish to return to host (%1$s)?}}
set SCO_USER_MHOME_MSGS(MSG_USERS_FOR) {20 {Users for %1$s}}
set SCO_USER_MHOME_MSGS(MSG_USER_ADD) {21 {Add User}}
set SCO_USER_MHOME_MSGS(MSG_APP_TITLE) {22 {Virtual Domain User Manager}}
set SCO_USER_MHOME_MSGS(MSG_TITLE) {23 {Virtual Domain User Manager on %1$s}}
set SCO_USER_MHOME_MSGS(MSG_STATUS) {24 {Virtual Domains on %1$s}}
set SCO_USER_MHOME_MSGS(MSG_MENU_HOST) {25 Host}
set SCO_USER_MHOME_MSGS(MSG_MENU_HOST_MN) {26 t}
set SCO_USER_MHOME_MSGS(MSG_MENU_OPEN) {27 {Open Host...}}
set SCO_USER_MHOME_MSGS(MSG_TITLE_OPEN) {28 {Open Host}}
set SCO_USER_MHOME_MSGS(MSG_MENU_OPEN_MN) {29 O}
set SCO_USER_MHOME_MSGS(MSG_MENU_EXIT) {30 Exit}
set SCO_USER_MHOME_MSGS(MSG_MENU_EXIT_MN) {31 x}
set SCO_USER_MHOME_MSGS(MSG_MENU_EDIT) {32 Edit}
set SCO_USER_MHOME_MSGS(MSG_MENU_EDIT_MN) {33 E}
set SCO_USER_MHOME_MSGS(MSG_MENU_USER) {34 Users...}
set SCO_USER_MHOME_MSGS(MSG_MENU_USER_MN) {35 U}
set SCO_USER_MHOME_MSGS(MSG_MENU_ALIAS) {36 {Mail Aliases...}}
set SCO_USER_MHOME_MSGS(MSG_MENU_ALIAS_MN) {37 A}
set SCO_USER_MHOME_MSGS(MSG_MENU_RETIRE) {38 {Retire User...}}
set SCO_USER_MHOME_MSGS(MSG_MENU_RETIRE_MN) {39 R}
set SCO_USER_MHOME_MSGS(MSG_SHORT_OPEN) {40 {Manage virtual domain users on another host}}
set SCO_USER_MHOME_MSGS(MSG_SHORT_EXIT) {41 {Exit Virtual Domain User Manager}}
set SCO_USER_MHOME_MSGS(MSG_SHORT_USER) {42 {Edit Users in a virtual domain}}
set SCO_USER_MHOME_MSGS(MSG_SHORT_ALIAS) {43 {Edit Mail Aliases in a virtual domain}}
set SCO_USER_MHOME_MSGS(MSG_SHORT_RETIRE) {44 {Retire a User from all virtual domains}}
set SCO_USER_MHOME_MSGS(MSG_LOADING) {45 Loading...}
set SCO_USER_MHOME_MSGS(MSG_SAVING) {46 {Saving configuration...}}
set SCO_USER_MHOME_MSGS(MSG_STR_OK) {47 OK}
set SCO_USER_MHOME_MSGS(MSG_STR_YES) {48 Yes}
set SCO_USER_MHOME_MSGS(MSG_STR_NO) {49 No}
set SCO_USER_MHOME_MSGS(MSG_STR_CANCEL) {50 Cancel}
set SCO_USER_MHOME_MSGS(MSG_STR_BROWSE) {51 Select...}
set SCO_USER_MHOME_MSGS(MSG_STR_ADD_USER) {52 {Add User...}}
set SCO_USER_MHOME_MSGS(MSG_STR_DEL_USER) {53 {Delete User}}
set SCO_USER_MHOME_MSGS(MSG_VIRTUAL) {54 {Virtual User}}
set SCO_USER_MHOME_MSGS(MSG_SYSTEM) {55 {System User}}
proc \
mhm_open_host {} \
{
global mhm_host_name mhm_host_label mhm_host_resolv mhm_vdomains_data
global outerMainForm
# first save any previous changes, but keep open for cancel.
set ret [mhm_all_put]
switch $ret {
"ok" {
}
"fail" {
return
}
"cancel" {
return
}
}
# put up open host dialog and get result
set newhost [mhm_open_host_dialog]
if {"$newhost" == ""} {
return
}
# get full name of remote machine
set newhost [mhm_host_resolv $newhost]
if {"$newhost" == ""} {
VtUnLock
mhm_error1 NOHOST $newhost
VtLock
return
}
# save old host name for backout
set oldhost $mhm_host_name
# check if new host there
set ret [mhm_host_check $newhost]
if {"$ret" != "ok"} {
VtUnLock
mhm_error1 BADHOST $newhost
VtLock
return
}
# set new host name
set mhm_host_name $newhost
# unset cached list of vdomains
unset mhm_vdomains_data
set ret [mhm_all_get]
if {"$ret" == "no"} {
mhm_host_backout $oldhost
return
}
if {"$ret" == "fail"} {
mhm_host_backout $oldhost
return
}
set mhm_short_name [lindex [split $mhm_host_name "."] 0]
VtSetValues $outerMainForm -title [mhm_msg1 TITLE $mhm_short_name]
VtSetValues $mhm_host_label -label [mhm_msg1 STATUS $mhm_host_name]
mhm_display_mainlist
}
proc \
mhm_host_backout { oldhost } \
{
global mhm_host_name mhm_host_label mhm_vdomains_data DIRTY
VtUnLock
set ret [mhm_query_qyn GO_BACK $oldhost]
VtLock
if {"$ret" != "yes"} {
quit
}
set mhm_host_name $oldhost
unset mhm_vdomains_data
set DIRTY 0
set ret [mhm_all_get]
if {"$ret" == "no"} {
quit
}
if {"$ret" == "fail"} {
quit
}
}
proc \
mhm_open_host_dialog {} \
{
global ME PID
# file is used to pass results to preserve stdout for child process.
set file "/tmp/mhm.$PID"
system "rm -f $file"
VtControl -suspend
system "$ME -mhm_stand_host $file"
VtControl -resume
if {[file exists $file] == 1} {
set result [exec cat $file]
system "rm -f $file"
} else {
set result ""
}
return $result
}
proc \
mhm_stand_host { file } \
{
global app
global mhm_stand_text mhm_stand_outfile mhm_stand_form
# globals for callbacks
set mhm_stand_outfile $file
# init widget server
set app [VtOpen mailchild "mailadmin"]
mhm_setcat SCO_USER_MHOME
# std dialog box.
set mhm_stand_form [ \
VtFormDialog $app.mailchild \
-title [mhm_msg TITLE_OPEN] \
-resizable FALSE \
-ok -okCallback mhm_stand_host_ok \
-cancel -cancelCallback mhm_stand_open_quit \
-wmCloseCallback mhm_stand_open_quit \
]
set mhm_stand_text [ \
VtText $mhm_stand_form.text \
-columns 40 \
-callback mhm_stand_host_jump \
]
VtPushButton $mhm_stand_form.browse \
-leftSide $mhm_stand_text \
-topSide FORM \
-callback mhm_stand_host_browse \
-label [mhm_msg STR_BROWSE]
VtShow $mhm_stand_form
VtSetFocus $mhm_stand_text
VtMainLoop
}
proc \
mhm_stand_host_jump { cbs } \
{
global mhm_stand_form
set ok [VtGetValues $mhm_stand_form -ok]
VtSetFocus $ok
}
proc \
mhm_stand_host_browse { cbs } \
{
global mhm_stand_form
keylset parms parent $mhm_stand_form
keylset parms instance abc
keylset parms labeltext [mhm_msg MENU_HOST]
keylset parms buttontext [mhm_msg STR_BROWSE]
keylset parms userproc mhm_stand_host_browse_done
SaSelectHostDialog $parms $cbs
}
proc \
mhm_stand_host_browse_done { cbs } \
{
global mhm_stand_text
set value[SaSelectHostGetSelection abc]
VtSetValues $mhm_stand_text -value $value
}
proc \
mhm_stand_host_ok { cbs } \
{
global mhm_stand_text mhm_stand_outfile
set value [VtGetValues $mhm_stand_text -value]
if {[catch {open $mhm_stand_outfile w} fd] == 0} {
puts $fd $value
close $fd
}
VtClose
exit 0
}
proc \
mhm_stand_open_quit { cbs } \
{
VtClose
exit 0
}
proc \
mhm_host_check { host } \
{
global mhm_host_name mhm_local_host
if {"$host" == "$mhm_local_host"} {
return ok
}
set class [ list sco remoteCommand ]
set instance [GetInstanceList NULL $host]
set command [list ObjectAction $class $instance uname "-n"]
set result [SaMakeObjectCall $command]
set result [lindex $result 0]
if { [BmipResponseErrorIsPresent result] } {
return fail
}
set retStr [BmipResponseActionInfo result]
return ok
}
proc \
mhm_remote_copyout { src dst } \
{
global mhm_host_name mhm_local_host
if {"$mhm_host_name" == "$mhm_local_host"} {
return [mhm_local_copy $src $dst]
}
set host $mhm_host_name
set instance [GetInstanceList NULL $host]
set uid [id effective userid]
if {$uid == 0} {
if {[catch {system "/bin/rcp $src $host:$dst"} ret] == 0} {
return ok
} else {
return fail
}
} else {
# first copy to a temp file on remote machine
set tmp "/tmp/[file tail $src].[pid]"
if {[catch {system "/bin/rcp $src $host:$tmp"} ret] != 0} {
return fail
}
# then on remote machine, copy the temp file to destination,
# using tfadmin cpfile
set class [list sco remoteCommand]
set command [list ObjectAction $class $instance /sbin/tfadmin "cpfile $tmp $dst"]
set result [SaMakeObjectCall $command]
set result [lindex $result 0]
if {[BmipResponseErrorIsPresent result]} {
return fail
}
# now remove the temp file on remote machine
set class [list sco remoteCommand]
set command [list ObjectAction $class $instance /bin/rm "-f $tmp"]
set result [SaMakeObjectCall $command]
return ok
}
}
proc \
mhm_remote_copyin { src dst } \
{
global mhm_host_name mhm_local_host
if {"$mhm_host_name" == "$mhm_local_host"} {
return [mhm_local_copy $src $dst]
}
set host $mhm_host_name
set instance [GetInstanceList NULL $host]
set uid [id effective userid]
if {$uid == 0} {
if {[catch {system "/bin/rcp $host:$src $dst"} ret] == 0} {
return ok
} else {
return fail
}
} else {
# copy to a temp file on remote machine, using tfadmin
set tmp "/tmp/[file tail $src].[pid]"
set class [list sco remoteCommand]
set command [list ObjectAction $class $instance /sbin/tfadmin "cpfile $src $tmp"]
set result [SaMakeObjectCall $command]
set result [lindex $result 0]
if {[BmipResponseErrorIsPresent result]} {
return fail
}
# copy the remote temp file in to local destination using rcp
if {[catch {system "/bin/rcp $host:$tmp $dst"} ret] != 0} {
return fail
}
# remove the temp file on remote machine
set class [list sco remoteCommand]
set command [list ObjectAction $class $instance /bin/rm "-f $tmp"]
set result [SaMakeObjectCall $command]
return ok
}
}
proc \
mhm_local_copy { src dst } \
{
set uid [id effective userid]
if {$uid == 0} {
catch {system "copy $src $dst > /dev/null 2>&1"} ret
} else {
catch {system "/sbin/tfadmin cpfile $src $dst > /dev/null 2>&1"} ret
}
if {"$ret" == 0} {
return ok
} else {
return fail
}
}
proc \
GetInstanceList { names host } \
{
set instanceList {}
if { $host == "localhost" } {
foreach name $names {
set instance [list $name]
lappend instanceList $instance
}
} else {
foreach name $names {
set instance [list [list systemId $host] [list $name]]
lappend instanceList $instance
}
}
return $instanceList
}
proc \
mhm_host_local {} \
{
set localhost [exec uname -n]
set fqdn [mhm_host_resolv $localhost]
return $fqdn
}
proc \
mhm_host_resolv { hostname } \
{
global RESOLVER
set ret [catch {exec $RESOLVER $hostname} hostlist]
if {"$ret" != "0"} {
return $hostname
}
set newhost [lindex $hostlist 0]
return $newhost
}
proc \
mhm_list_users {} \
{
global mhm_host_name mhm_local_host
if {"$mhm_host_name" == "$mhm_local_host"} {
set users [SaUsersGet]
} else {
set users [SaUsersGet $mhm_host_name]
}
set users [string tolower $users]
return $users
}
proc \
mhm_remote_file_exists { path } \
{
global mhm_host_name mhm_local_host
if {"$mhm_host_name" == "$mhm_local_host"} {
return [file exists $path]
}
set host $mhm_host_name
set class [list sco remoteCommand]
set instance [GetInstanceList NULL $host]
set command [list ObjectAction $class $instance file $path]
set result [SaMakeObjectCall $command]
set result [lindex $result 0]
if { [BmipResponseErrorIsPresent result] } {
return 0
}
return 1
}
proc \
mhm_remote_mkdir { path } \
{
global mhm_host_name mhm_local_host
set uid [id effective userid]
if {[mhm_remote_file_exists $path]} {
return 1
}
if {"$mhm_host_name" == "$mhm_local_host"} {
if {$uid == 0} {
catch {system "mkdir -p $path > /dev/null 2>&1"} ret
if {$ret == 0} {
return 1
} else {
return 0
}
} else {
# create the path in /tmp
set tmpdir "/tmp/tmpdir.[pid]"
set tmpvar $path
set basedir [ctoken tmpvar "/"]
catch {system "mkdir -p $tmpdir/$path > /dev/null 2>&1"} ret