User Tools

Site Tools


info:devel:architecture

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
info:devel:architecture [2015/07/25 08:57]
[Tasks]
info:devel:architecture [2015/07/26 12:35] (current)
[Additional Resources]
Line 15: Line 15:
 ===== Additional Resources ===== ===== Additional Resources =====
 **Additional resources** ‐ The following reference provides additional details on the topics discussed in this module: **Additional resources** ‐ The following reference provides additional details on the topics discussed in this module:
-  * The Sun Cobalt Qube 3 Developer’s Guide, which is available at http://​developer.cobalt.com/​sausalito/​index.php+  * [[info:​devel:​devguide|The Blueonyx ​Developer’s Guide]] 
 +  * [[info:​devel:building|How to setup a Blueonyx development environment]]
   * For more information on PHP the widely-used,​ general-purpose scripting language that is especially suited for Web development and can be embedded into HTML see: http://​www.php.net/​PHP   * For more information on PHP the widely-used,​ general-purpose scripting language that is especially suited for Web development and can be embedded into HTML see: http://​www.php.net/​PHP
   * For more information on gettext'​ utilities which are a set of tools that provides a framework to help produce multi-lingual messages http://​www.gnu.org/​software/​getteXt/​gettext.html   * For more information on gettext'​ utilities which are a set of tools that provides a framework to help produce multi-lingual messages http://​www.gnu.org/​software/​getteXt/​gettext.html
- 
 ===== What Is Important in This Module? ===== ===== What Is Important in This Module? =====
 This module describes the Sausalito architecture and how to use it to extend the server appliance’s out‐of-the-box service features. The major topics in this module are: This module describes the Sausalito architecture and how to use it to extend the server appliance’s out‐of-the-box service features. The major topics in this module are:
Line 234: Line 234:
  
 1. Open the ftproot.schema file editing and switch to insert mode: 1. Open the ftproot.schema file editing and switch to insert mode:
-  # v i ftproot.schema ​+  # vi ftproot.schema ​
   i   i
 2. On the line that starts with <class name="​System”,​ change Ftp to FtpRootLogin.\\ ​ 2. On the line that starts with <class name="​System”,​ change Ftp to FtpRootLogin.\\ ​
Line 260: Line 260:
  
 If you do not receive a similar result as above, make sure the syntax in your ftproot.schema file is correct. If you do not receive a similar result as above, make sure the syntax in your ftproot.schema file is correct.
 +
 +===== Registering an Event Handler =====
 +To register an event handler with the system, create an event handler configuration file with a .conf extension. The .conf file must contain the information that defines the class, name space, and properties for the object to which you want the event handler to be registered. Then, if the object is modified, the event handler will be triggered and make the necessary changes to the operating system. The . conf file must also contain the path to the executable script that is the event handler itself.
 +
 +The .conf file can beplaced anywhere under the /​usr/​sausa1ito/​conf directory tree. This makes it possible for third-party software developers to create their own /​usr/​sausalito/​conf/​vendor‐name directories,​ in which they can store their .conf files.
 +
 +CCE finds all the .conf files in the /​usr/​sausalito/​conf directory and subdirectories;​ however, all file names that begin with a period are ignored.
 +
 +==== Event Handler File Format ====
 +The .conf file format is simple and can contain several lines with three fields per line. For example:
 +
 +  ClassEvent ​          ​Handler definition(File path)            Execution stage
 +
 +
 +=== ClassEvent ===
 +Class.Event is a string of text that defines:
 +  * An object
 +  * An optional n a m e space
 +  * A property or an object
 +  * An optional name space (optional)
 +  * An event based on the events listed in Table 17-4
 +
 +
 +=== Table 17-4 Valid class events ===
 +^Event^Definition^
 +|_CREATE|When an object of the specified class is created|
 +|_DESTROY|When an object of the specified class is destroyed|
 +|propertyname|When the specified property of the specified class is changed|
 +|*|Wildcard,​ which means when any property of the specified class or class .namespace is changed|
 +
 +=== Handler Definition ===
 +The handler definition is the path to the eventhandler’s executable script. This path is preceded by either perl: or exec:. The perl: text causes CCE to use a persistent Perl daemon, thereby expediting the execution request. The exec: text executes the script or binary.
 +
 +=== Execution Stage ===
 +The execution stage allows the handler writer to suggest a relative order for event handler execution. The following five defined, case-sensitive execution stages are listed in priority from highest to lowest:
 +
 +  * VALIDATE
 +  * CONFIGURE
 +  * EXECUTE
 +  * TEST
 +  * CLEANUP
 +
 +If the execution stage is not specified, the event handler is in the EXECUTE stage. Relative ordering between stages is guaranteed, but ordering within a given stage is not.
 +
 +==== Example: Event Handler Configuration File ====
 +The following /​usr/​sausalito/​conf/​ftp/​ftp.conf file is provided as an example. When any of the properties are modified on the System.Ftp.* or System.FileShare.* object and name space,the /​usr/​sausalito/​handlers/​base/​ftp/​system.pl script is executed to handle the request.
 +
 +
 +This file also controls the script for enabling anonymous FTP, and for enabling and disabling FTP service monitoring using the Active Monitor.
 +
 +<​code>​
 +# $Id: ftp.conf,v 1.10 2000/09/15 01:03:54 thockin Exp $
 +# handlers for ftp
 +#
 +System.FileShare.* ​       perl:/​usr/​sausalito/​handlers/​base/​ftp/​guest.pl
 +System.Ftp.* ​             perl:/​usr/​sausalito/​handlers/​base/​ftp/​system.pl
 +ActiveMonitor.FTP.enabled perl:​base/​am/​am_enabled.pl EXECUTE
 +ActiveMonitor.FTP.monitor perl:​base/​am/​am_enabled.pl EXECUTE
 +System.Ftp.enabled ​       perl:​base/​ftp/​enableAM.pl
 +</​code>​
 +
 +
 +===== Exercise: Creating and Registering an Event Handler =====
 +In this exercise you continue the process started in “Exercise:​ Extending an Object’s Schema"​ on page 17‐18. There, you extended the properties of the FTP server by adding the FTP root user access feature though the Server Desktop. Now complete the tasks of creating the event handler configuration file and writing the executable script for modifying the FTP server configuration file.
 +
 +==== Tasks ====
 +Complete the following steps to create the event handler configuration file:
 +
 +1. Open a telnet window and change to the /​usr/​sausalito/​conf directory, create new directory using your_first_name/​ftp and then change to that directory:
 +
 +  # cd /​usr/​sausalito/​conf
 +  # mkdir ‐p your_first_name/​ftp
 +  # cd your_first_name/​ftp
 +
 +2. Open for editing a ftpRootAccess.conf file and switch to insert mode:
 +  # vi ftpRootLogin.conf
 +  i
 +
 +3. Add the following text(use a tab for the space between enabled and perl):
 +  # handler for ftp root login
 +  #
 +  Systam.FtpRootLogin.enabled ​    ​perl:/​usr/​sausalito/​handlers/​your_first_name/​ftp/​rootLogin.pl
 +
 +Make sure you replaced the your_first_name,​ with your real first name!
 +
 +4. Switch to command mode by pressing the Escape key.
 +
 +5. Save and close the file:
 +  :wq
 +
 +Complete the following steps to write the executable event handler Perl script for adding the root access directive to the FTP server configuration file:
 +
 +1. Change to the /​usr/​sausalito/​handlers directory, create new directory using your_first_name/​ftp and then change to that directory:
 +
 +  # cd /​usr/​sausalito/​handlers
 +  # mkdir ‐p your_first_name/​ftp
 +  # cd your_first_name/​ftp
 +  ​
 +2. Open for editing a rootLogin.pl file and switch to insert mode:
 +  # vi rootLogin.pl
 +  i
 +
 +3. Insert the following text exactly as shown into the file. Use the Tab key to indent lines. It might take several attempts to get the text exactly right, so take your time.
 +
 +**Note** ‐ This script is written to be streamlined and it does not follow good programming syntax guidelines for providing comments about the script’s use.
 +
 +<code perl>
 +#​!/​usr/​bin/​perl -w -I/​usr/​sausalito/​perl -I.
 +# System.FtpRootLogin.enabled modify handler
 +use strict;
 +use Sauce::​Config;​
 +use Sauce::​Util;​
 +use CCE;
 +
 +my $cce = new CCE;
 +$cce->​connectfd();​
 +
 +my $oid = $cce‐>​event_oid() ;
 +my($ok, $obj) = $cce‐>​get($oid,​ '​FtpRootLogin'​);​
 +if (!$oid) {
 +        $cce‐>​bye('​FAIL'​);​
 +        exit(1);
 +}
 +
 +#
 +my $enabled = $obj‐>​{enabled} ? "​on"​ : "​off";​
 +
 +my $fun = sub {
 +        my ($fin, $fout) = (shift, shift);
 +        my $found = 0;
 +        my $conf = "​RootLogin\t\t\t$enabled\n";​
 +        while (defined($_ = <​$fin>​)) {
 +                if(/​^\s*RootLogin/​) {
 +                        print $fout $conf;
 +                        $found = 1;
 +                } else {
 +                        print $fout $_;
 +                }
 +        }
 +        print $fout $conf unless ($found);
 +        return 1;
 +};
 +my $ret = Sauce::​Util::​editfile("/​etc/​proftpd.conf",​ $fun);
 +if ($ret) {
 +        $cce->​bye('​SUCCESS'​);​
 +        exit(0); ​
 +} else {
 +        $cce‐>​bye('​FAIL'​);​
 +        exit(1);
 +}
 +</​code>​
 +
 +4. Switch to command mode by pressing the Escape key.
 +
 +5. Save and close the file:
 +  :wq
 +
 +6. Execute the file at the command line to test the syntax:
 +  # perl -cw rootLogin.pl
 +  rootAccess.pl syntax OK
 +
 +The ‐cw option tells Perl to compile, but not execute, the program and to display warnings about errors.
 +
 +If you receive warnings, check the contents of the rootAccess.pl file and make any necessary changes until you receive no more warnings.
 +
 +7. Restart CCE:
 +  # /​etc/​rc.d/​init.d/​cced.init restart
 +  Shutting down cced: done
 +  Starting cced: cced
 +  Running CCE constructors:​
 +  #
 +
 +===== CSCP Communication With CCE =====
 +Communication to CCE is done through CSCP and there are two modes of communication:​ client mode and handler mode. The handler mode has more commands than the client mode.
 +
 +==== CCE Communication Modes ====
 +CSCP is shown in Table 17-1 on page 17-13. CSCP is used in the handler mode for communication between CCE and the event handlers; it is also used for communication between CCE and the Server Desktop.
 +
 +CSCP is used in the client mode to establish a direct connection to CCE. To establish a direct connection to CCE, the cceclient utility is executed from the command line: /​usr/​sausalito/​bin/​cceclient. Table 17-5 lists the commands used for both client and handler CCSP communication modes.
 +
 +Table 17-5 The client and handler mode commands
 +
 +^Command^Description^
 +|auth|Authenticates asa user to get that user's access privileges (starts a new session)|
 +|authkey|Authenticates to an already existing session|
 +|endkey|Expires the current sessionid|
 +|whoami|Returns the oid (Object Identification) of the currently authenticated user|
 +|bye|Closes the connection|
 +|commit|Triggers any postponed handler activity|
 +|create|Creates a new object of a certain class|
 +|destroy|Destroys an object|
 +|find|Finds all objects that match a given criteria|
 +|get|Gets all properties for a certain object or object name space|
 +|names|Lists name spaces associated with a Class|
 +|classes|Lists all classes|
 +|set|Sets the properties of a certain object|
 +
 +Table 17-6 contains additional commands that are available in the handler mode when the CCE is communicating with an event handler:
 +
 +Table 17-6 Additional Handler Mode Commands
 +^Command^Description^
 +|baddata|Reports that an unrecognized attribute or value was passed|
 +|info|Reports a piece of information|
 +|warn|Reports a warning or error|
 +
 +==== CCE Response Codes ====
 +For every command given to CCE, a response code is returned. These response codes consist of a numeric code and a set of arguments. The value of the first digit of the numeric code defines whether the message is an informational message (1), a success message (2), a warning message (3), a failure message (4), or a system-issued message (9). Table 17‐7 describes the response types.
 +
 +Table 17-7 CCE Response Codes
 +^Numeric code range^Type of response^
 +|100-199|Informational|
 +|200-299|Success|
 +|300-399|Warning|
 +|400-499|Failure|
 +|900-999|System~issucd message (which can be sent at any time)|
 +
 +===== Exercise: Testing Systems Changes From cceclient =====
 +
 +In this exercise you test the new feature added to the FTP server for root login access. This test must be successful before you extend the Server Desktop with new menu items.
 +
 +==== Tasks ====
 +Complete the following steps to determine the object number for the System object and test the FTP server changes performed by the event handler:
 +
 +1. In telnet, communicate to CCE using the cceclient utility and find the number for the System object:
 +  # /​usr/​sausalito/​bin/​cceclient
 + ​ 100 CSCP/O.80
 +  200 READY
 +  find system
 +  104 OBJECT 1
 +  201 OK
 +
 +2. Open another telnet session and list the /​etc/​proftpd.conffile contents:
 +  # cat /​etc/​proftpd.conf
 +
 +Notice that no RootLogin directive is listed in the file.
 +
 +3. In the first telnet session that has cceclient running,for the System object (object 1), set the FtpRootLogin name space’s enabled property to 0. (Zero equals off.)
 +  set 1.FtpRootLogin enabled="​0"​
 +  201 OK
 +
 +4. In the other telnet session, list the /​etc/​proftpd.conf file:
 +  # cat /​etc/​proftpd.conf
 +
 +Notice the last line of the file reads RootLogin off
 +
 +5. Try to log in to the FTP server as root and exit:
 +  # ftp localhost
 +  Connected to localhost.
 +  220 ProFTPD 1.2.0 Server (ProFTPD)
 +  [www.server_appliance.com]
 +  Name (localhost:​admin):​ root
 +  331 Password required for root.
 +  Password: your_password
 +  530 Login incorrect.
 +  Login failed.
 +  ftp> exit
 +
 +Notice the Login Failed.
 +
 +In the telnet window that has cceclient running, set the System object’s FtpRootLogin name space’s enabled property to 1.(One equals on.)
 +
 +  set 1.FtpRootLogin enabled=”1"​
 +  201 OK
 +
 +7. In the other telnet session, list the /​etc/​proftpd.conf file:
 +  # cat /​etc/​proftpd.conf
 +Notice that the last line of the file reads RootLogin on
 +
 +8. Log in to the FTP server as root and exit:
 +  # ftp localhost
 +  Connected to localhost.
 +  220 ProFTPD 1.2.0 Server (ProFTPD)
 +  [www.server_appliance.com]
 +  Name (localhostzadmin):​ root
 +  331 Password required for root.
 +  Password: your_password
 +  230 User root logged in.
 +  Remote system type is UNIX.
 +  Using binary mode to transfer files.
 +  ftp> exit
 +
 +Notice the 230 User root logged in.
  
  
info/devel/architecture.1437778659.txt.gz · Last modified: 2015/07/25 08:57 by