contents

7. The Dispatcher

The Dispatcher will be installed as a server-service on a host. During start-up the password-file of all installed users will be checked. Users not installed on that host will be ignored. Then it listens on a port for requests from clients.
The client identifies itself by username and password. The Dispatcher then starts a Data-Server-Process with that user ID. The client will be connected with that process and communicates with it directly.
And the Dispatcher waits for new requests..

7.1 Setup

The Dispatcher will be installed in the following path:
/usr/magicadm/servers
There are four files:
  • mgdispatch    - the Dispatcher
  • mgdatasrvr    - the Data-Server
  • mgdatasrvr.rc - the resources for the Data-Server
  • MGSERVER.INI  - the Ini-file for the Data-Server
Despite Magic is of other opinion:
You should remember this is a daemon which should NOT have "root" privileges. This can be prevented, if  "magicadm" owns the files and the "Set User ID" bit is set.
chmod 4500 mgdispatch
chown magicadm mgdispatch
In plain words: if the Dispatcher has no "root"-privileges, it can only start new processes with  "magicadm"-privileges.
Your system admin may decide.

7.1.1 mgpasswd

The Dispatcher uses different password files, dependeing on the user that has started it and checks various conditions on start-up
The mgpasswd file:
  • is located in "/usr/magicadm/etc/" and is owned by  "magicadm"
    or
    is located in "/etc/" and is owned by  "root"
  • is named "mgpasswd" and has privilege "600".
  • mustn't be a symbolic link.
  • can only contain existing users.
If one of these conditions isn't met, start-up terminates with an error message.
If that file does not exist, then "rlogin" and "remote shell" conditions are executed.
Further informations are: The mgpasswd file
  • will only be read at start-up of the dispatcher.
  • has passwords in plain text that are only valid for the Dispatcher, shouldn't be the users Linux password!
  • mustn't contain spaces at the end of a field or line.
Format: RealUserName:DispatcherPasswort:[FirstIP[,SecondIP]:]
# sample mgpasswd
# all three fields are terminated by a ":"
# UserName:Password:[Host1[,Host2]:]
magicadm:dmagciam:192.168.0.1:
# Host 192.168.0.1 can log in as User magicadm Password dmagciam
meier::192.168.0.22:
# Host 192.168.0.22 can log in as User meier without password
schulze:nix:
# anyone can log in as User schulze Password nix
cheffe::192.168.0.1,192.168.18.1:
# Hosts 192.168.0.1 und 192.168.18.1 can log in as User cheffe without password

7.2 Manual Start

Login as "magicadm" and change to the dispatcher default directory.
Starting the dispatcher:
cd /usr/magicadm/servers
./mgdispatch 2060
  • 2060  - The port that the Dispatcher registers to can be changed to any above 1000.
Check whether the Dispatcher was started:
ps -A -l| grep mgdispatch
  F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
040 S   501 99880     1  0  60   0 -   357 wait_f pts/0    00:00:00 mgdispatch
As user we see UID=501, that is e.g. "magicadm" and as process the PID=99880.
To stop enter:
kill 99880

7.3 Dispatcher and SuSE

The system scripts are located in
/sbin/init.d/
And they have their own start algorithm. The change of a run level is controlled by a script called:
/etc/rc.config
You have to insert a new section at the end of the file:
---------- cut ---------
#
# Start the magic dispatcher (yes,no).
#
START_MGDISPATCH="yes"
#
---------- cut ---------
This setting can be changed by "yast"
Administrating the System -> Changing Configuration File
Now copy the script "mgcss" from archive to "/sbin/init.d/" and change the properties:
chmod 4700 mgcss
chown magicadm mgcss
The run level in which the dispatcher should be started is controled by a symbolic link in a directory:
  • kill and start the dispatcher at run level 2
    ln -s /sbin/init.d/mgcss /sbin/init.d/rc2.d/K92mgcss
    ln -s /sbin/init.d/mgcss /sbin/init.d/rc2.d/S91mgcss
  • kill and start the dispatcher at run level 3
    ln -s /sbin/init.d/mgcss /sbin/init.d/rc3.d/K92mgcss
    ln -s /sbin/init.d/mgcss /sbin/init.d/rc3.d/S91mgcss
(The license manager should be started (S91mglms) before the dispatcher (S92mgcss). And vice versa:  first stop the dispatcher (K91mgbrs) and than the license manager (S92mgcss). If you want to know more= RtFM.)
If you modified the location or the user of the dispatcher, you have to modify the script:
---------- cut --------------
CS_PATH=/usr/magicadm/servers
CS_USER=magicadm
CS_PORT=2060
---------- cut --------------
You are now able to controll the Dispatcher:
/sbin/init.d/mgcss start
/sbin/init.d/mgcss stop
/sbin/init.d/mgcss status
/sbin/init.d/mgcss restart

7.4 Dispatcher und Red Hat

The system scripts are located in
/etc/rc.d/init.d/
Now copy the script "mgcsr"  from archive to "/etc/rc.d/init.d/" and change the properties:
chmod 4700 mgcsr
chown magicadm mgcsr
And it is controlled by "chkconfig". The "mgcsr" script has a section with three lines like this (the slash at the end of the second line concatenates the third line and must be):
---------- cut --------------
# chkconfig:   23 92 91
# description: start the daemon at run level 2 & 3 as S92mgcsr \
#              and stop it at the other level as K91mgcsr
---------- cut --------------
(First start the license manager (S91mglmr) than the dispatcher (S92mgcsr). And first stop the dispatcher (K91mgcsr) and than the license manager (S92mglmr).  If you want to know more "man chkconfig")
For to add the service:
chkconfig --add mgcsr
chkconfig --list mgcsr
result: "mgcsr 1:off 2:on 3:on 4:off 5:off 6:off"
To delete the Dispatcher as a service:
chkconfig --del mgcsr
chkconfig --list mgcsr
result: "mgcsr 1:off 2:off 3:off 4:off 5:off 6:off"
The script "/etc/rc.d/rc" control's the change of a run level. All symbolic links with a "K" ("K92mgcsr") in the beginning are taken to check  "/var/lock/subsys" for a lock file named "mgcsr". The script "mgcsr" has to create an empty file on start up in this directory and delete it on stop.  "magicadm"  doesn't have properties to write into this directory.
To solve this problem "root" has to change the properties of "/var/lock/subsys/" to "search/execute others" :
chmod o+x /var/lock/subsys/
If you modified the location or the user of the dispatcher, you have to modify the script:
---------- cut --------------
CS_PATH=/usr/magicadm/servers
CS_USER=magicadm
CS_PORT=2060
---------- cut --------------
You are now able to controll the dispatcher:
/etc/rc.d/init.d/mgcsr start
/etc/rc.d/init.d/mgcsr stop
/etc/rc.d/init.d/mgcsr status
/etc/rc.d/init.d/mgcsr restart

7.5 Dispatcher and Data-Server

The Data-Server first executes the script "mgdatasrvr.rc". Then "MGSERVER.INI" is read.

7.5.1 mgdatasrvr.rc

This script:
  • checks whether Magic was installed correctly.
  • sets the names for the log-files.
  • checks whether a user directory exists.
  • reads user specific settings.

7.5.2 MGSERVER.INI

Exemplarily only the necessary entries for access on local services are explained.
"ServerName" is up to your free decision. This same name must appaer at the Client in the section "[MAGIC_SERVERS]" in the "magic.ini". This means that if the Data-Server is running on the host "MGLINUX", it can be named "mgwebdaten" in the "[MAGIC_SERVERS]" section. There is no reason to give it the same name as the host. It may be even better NOT to give it the same name as the host, that the service must be run on a totally different server. And then it can be quite confusing if the Data-server has the same name as its former host.
 
[MAGIC_SERVERS]  
ServerName =  1,NONE, , ,  server name is the name of the Magic logical server:
Any Magic client or server that wants to communicate with a server must use the same name in all the MGSERVER.INI files;
communication type is a number with one of the following values:
1 is no communication (local),
2 is TCP/IP communications, and
3 is DECnet;
server address is set based upon the communication type setting:
for communication type 1, local, the address must be "NONE";
for communication type 2, TCP/IP, the address is as follows:
hostname/port number
where:
the host name is the name of the host in the TCP/IP hosts repository, and port number is the port number on which the communication dispatcher is listening, as used when loading the dispatcher. For details on the Magic dispatcher see the operating system-specific subsection in this chapter.
For communication type 3, DECnet, the address is as follows:
DECnet-node-name/object-name
where
DECnet host name can be a DECnet node name as defined in the NCP database, or it can be a DECnet address.
The Object name refers to a known Magic DECnet object name. This name is used to distinguish the server that will be invoked on the host machine. MG800GEN will activate the development server and MG800RNT will invoke the runtime server.
For more information on DECnet client/server communication see the section in this chapter on the DECnet Server.
username is the user account that is used for logging into the server:
The server process will be created in the context of this user account.
password is the password for the user account.
Syntax :server name = communication type,server address,username,password
     
[MAGIC_DATABASES]  
Default Database =  4, , , , , , , , MagicRecordLock, ChangeFileInToolkit, CheckDefinition, CheckKey, FileLocks, , , , NoCheckExist, 0,  
     
[MAGIC_LOGICAL_NAMES]  
MagicDir =  /usr/magicadm   

contents