[Fedora-directory-commits] adminserver/admserv/newinst/src ASDialogs.pm.in, NONE, 1.1 setup-ds-admin.pl.in, NONE, 1.1 setup-ds-admin.res.in, NONE, 1.1

Richard Allen Megginson (rmeggins) fedora-directory-commits at redhat.com
Fri Jun 8 22:49:20 UTC 2007


Author: rmeggins

Update of /cvs/dirsec/adminserver/admserv/newinst/src
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv20908/adminserver/admserv/newinst/src

Added Files:
	ASDialogs.pm.in setup-ds-admin.pl.in setup-ds-admin.res.in 
Log Message:
Resolves: bug 237356
Bug Description: Move DS Admin Code into Admin Server
Reviewed by: nkinder (Thanks!)
Fix Description: This adds the admin server specific setup "ui" and main script driver.  Some of the values are currently missing because they don't yet have ui support.  These are commented out in setup-ds-admin.pl.  But at least this gives us the framework to add support for config DS creation, server registration, and other post config stuff.
Platforms tested: RHEL4
Flag Day: no
Doc impact: Yes, along with the rest of the new setup stuff.



--- NEW FILE ASDialogs.pm.in ---
# BEGIN COPYRIGHT BLOCK
# This Program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; version 2 of the License.
# 
# This Program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License along with
# this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA.
# 
# In addition, as a special exception, Red Hat, Inc. gives You the additional
# right to link the code of this Program with code not covered under the GNU
# General Public License ("Non-GPL Code") and to distribute linked combinations
# including the two, subject to the limitations in this paragraph. Non-GPL Code
# permitted under this exception must only link to the code of this Program
# through those well defined interfaces identified in the file named EXCEPTION
# found in the source code files (the "Approved Interfaces"). The files of
# Non-GPL Code may instantiate templates or use macros or inline functions from
# the Approved Interfaces without causing the resulting work to be covered by
# the GNU General Public License. Only Red Hat, Inc. may make changes or
# additions to the list of Approved Interfaces. You must obey the GNU General
# Public License in all respects for all of the Program code and other code used
# in conjunction with the Program except the Non-GPL Code covered by this
# exception. If you modify this file, you may extend this exception to your
# version of the file, but you are not obligated to do so. If you do not wish to
# provide this exception without modification, you must delete this exception
# statement from your version and license this file solely under the GPL without
# exception. 
# 
# 
# Copyright (C) 2007 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK
#

package ASDialogs;

use strict;

use DialogManager;
use Setup;
use Dialog;
use Util;

my $asport = new Dialog (
    $TYPICAL,
    'dialog_asport_text',
    sub {
        my $self = shift;
        my $port = $self->{manager}->{inf}->{admin}->{Port};
        if (!defined($port)) {
            $port = @admservport@;
        }
        if (!portAvailable($port)) {
            $port = getAvailablePort();
        }
        return $port;
    },
    sub {
        my $self = shift;
        my $ans = shift;
        my $res = $DialogManager::SAME;
        if ($ans !~ /\d+/) {
            $self->{manager}->alert("dialog_asport_error", $ans);
        } elsif (!portAvailable($ans)) {
            $self->{manager}->alert("dialog_asport_error", $ans);
        } else {
            $res = $DialogManager::NEXT;
            $self->{manager}->{inf}->{admin}->{Port} = $ans;
        }
        return $res;
    },
    ['dialog_asport_prompt']
);

my $ashostip = new Dialog (
    $CUSTOM,
    'dialog_ashostip_text',
    sub {
        my $self = shift;
        return $self->{manager}->{inf}->{admin}->{ServerIpAddress};
    },
    sub {
        my $self = shift;
        my $ans = shift;
        $self->{manager}->{inf}->{admin}->{ServerIpAddress} = shift;
        return $DialogManager::NEXT;
    },
    ['dialog_ashostip_prompt']
);

# must verify that the user or uid specified by the user to run the server as
# is a valid uid
sub verifyUserChoice {
    my $self = shift;
    my $ans = shift;
    my $res = $DialogManager::NEXT;
    # convert numeric uid to string
    my $strans = $ans;
    if ($ans =~ /^\d/) { # numeric - convert to string
        $strans = getpwuid $ans;
        if (!$strans) {
            $self->{manager}->alert("dialog_assysuser_error", $ans);
            return $DialogManager::SAME;
        }
    }
    if ($> != 0) { # if not root, the user must be our uid
        my $username = getlogin;
        if ($strans ne $username) {
            $self->{manager}->alert("dialog_assysuser_must_be_same", $username);
            return $DialogManager::SAME;
        }
    } else { # user is root - verify id
        my $nuid = getpwnam $strans;
        if (!defined($nuid)) {
            $self->{manager}->alert("dialog_assysuser_error", $ans);
            return $DialogManager::SAME;
        }
        if (!$nuid) {
            $self->{manager}->alert("dialog_assysuser_root_warning");
        }
    }
    $self->{manager}->{inf}->{admin}->{SysUser} = $ans;
    return $res;
}

my $assysuser = new Dialog (
    $CUSTOM,
    'dialog_assysuser_text',
    sub {
        my $self = shift;
        my $user = $self->{manager}->{inf}->{admin}->{SysUser};
        if (!defined($user)) {
            $user = $self->{manager}->{inf}->{General}->{SuiteSpotUserID};
        }
        if (!defined($user)) {
            if ($> == 0) { # if root, use the default user
                $user = "@httpduser@";
            } else { # if not root, use the user's uid
                $user = getlogin;
            }
        }
        return $user;
    },
    sub {
        my $self = shift;
        my $ans = shift;
        return verifyUserChoice($self, $ans);
    },
    ['dialog_assysuser_prompt']
);

sub getDialogs {
    return ($asport, $ashostip, $assysuser);
}

1;


--- NEW FILE setup-ds-admin.pl.in ---
#!/usr/bin/env perl
# BEGIN COPYRIGHT BLOCK
# This Program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; version 2 of the License.
# 
# This Program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License along with
# this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA.
# 
# In addition, as a special exception, Red Hat, Inc. gives You the additional
# right to link the code of this Program with code not covered under the GNU
# General Public License ("Non-GPL Code") and to distribute linked combinations
# including the two, subject to the limitations in this paragraph. Non-GPL Code
# permitted under this exception must only link to the code of this Program
# through those well defined interfaces identified in the file named EXCEPTION
# found in the source code files (the "Approved Interfaces"). The files of
# Non-GPL Code may instantiate templates or use macros or inline functions from
# the Approved Interfaces without causing the resulting work to be covered by
# the GNU General Public License. Only Red Hat, Inc. may make changes or
# additions to the list of Approved Interfaces. You must obey the GNU General
# Public License in all respects for all of the Program code and other code used
# in conjunction with the Program except the Non-GPL Code covered by this
# exception. If you modify this file, you may extend this exception to your
# version of the file, but you are not obligated to do so. If you do not wish to
# provide this exception without modification, you must delete this exception
# statement from your version and license this file solely under the GPL without
# exception. 
# 
# 
# Copyright (C) 2007 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK
#

use lib '@perldir@';

use strict;

use Setup;
use SetupLog;
use Inf;
use Resource;
use DialogManager;

my $setup = new Setup;

if (!$setup->{silent}) {
    my $res = new Resource("@propertydir@/setup-ds.res",
                           "@propertydir@/setup-ds-admin.res");
    my $dialogmgr = new DialogManager($setup, $res, $TYPICAL);

    require SetupDialogs;
    require DSDialogs;
    require ASDialogs;

    my @dialogs = SetupDialogs->getDialogs();
    push @dialogs, DSDialogs->getDialogs();
    push @dialogs, ASDialogs->getDialogs();

    $dialogmgr->addDialog(@dialogs);

    my $rc = $dialogmgr->run();
    if ($rc) {
        $setup->doExit();
    }

# these values are currently missing - have no UI support - ServerAdminID and Pwd
# are supposed to be derived from ConfigDirectoryAdminID and Pwd
#     $setup->{inf}->{admin}->{ServerAdminID} = "admin";
#     $setup->{inf}->{admin}->{ServerAdminPwd} = "admin";
#     $setup->{inf}->{General}->{ConfigDirectoryLdapURL} = "ldap://localhost.localdomain:1100/o=NetscapeRoot";
#     $setup->{inf}->{General}->{ConfigDirectoryAdminID} = "admin";
#     $setup->{inf}->{General}->{ConfigDirectoryAdminPwd} = "admin";
#     $setup->{inf}->{General}->{AdminDomain} = "localdomain";

    $setup->{inf}->write();
}

# create a directory server instance
if (system("@bindir@/ds_newinst.pl $setup->{inffile}")) {
    print STDERR "Failed to create directory server instance\n";
    $setup->{log}->logMessage($FATAL, "Setup", "Failed to create directory server instance");
}

# configure the admin server instance
if (system("@cmdbindir@/ds-admin-update -f $setup->{inffile}")) {
    print STDERR "Failed to configure administration server\n";
    $setup->{log}->logMessage($FATAL, "Setup", "Failed to configure administration server");
}

END {
    if (!$setup->{keep}) {
        unlink $setup->{inffile};
    }

    $setup->doExit();
}


--- NEW FILE setup-ds-admin.res.in ---
# this overrides the default
# ------------ Welcome Dialog Resource ------------
dialog_welcome_text = This program will setup the %s Directory and Administration Servers.\n\nIt is recommended that you have "root" privilege to setup the software.\nTips for using this  program:\n  - Press "Enter" to choose the default and go to the next screen\n  - Type "Control-B" then "Enter" to go back to the previous screen\n  - Type "Control-C" to cancel the setup program\n  - You can enter multiple items using commas to separate them.\n    For example: 1, 2, 3 \n\n
# %s -> brand

# this overrides the default
# ----------- SSUser Dialog Resource  ----------------
dialog_ssuser_text = The servers must run as a specific user in a specific group.\nIt is strongly recommended that this user should have no privileges\non the computer (i.e. a non-root user).  The setup procedure\nwill give this user/group some permissions in specific paths/files\nto perform server-specific operations.\n\nIf you have not yet created a user and group for the servers,\ncreate this user and group using your native operating\nsystem utilities.\n\n

# ----------- AS port Dialog Resource  ----------------
dialog_asport_text = The Administration Server is separate from any of your web or application\nservers since it listens to a different port and access to it is\nrestricted.\n\nPick a port number between 1024 and 65535 to run your Administration\nServer on. You should NOT use a port number which you plan to\nrun a web or application server on, rather, select a number which you\nwill remember and which will not be used for anything else.\n\nThe default in brackets was randomly selected from the available\nports on your system.\n\n
dialog_asport_prompt = Administration port
dialog_asport_error = The port %s is in use or not available.  Please choose another port.\n\n

# ----------- AS host IP Dialog Resource  ----------------
dialog_ashostip_text = If you want to configure the Administration Server to bind\nto a specific IP address, enter the address below.\n\n
dialog_ashostip_prompt = IP address

# ----------- AS sys user Dialog Resource  ----------------
dialog_assysuser_text = The Administration Server program runs as a certain user on your\nsystem. This user must have permission to modify files and directories\nfor your Directory server as well as the Administration server.  You\nare strongly encouraged to use a non-privileged (i.e. non-root) user.\n\n
dialog_assysuser_prompt = Run Administration Server as
dialog_assysuser_error = The user '%s' is invalid.\n\n
dialog_assysuser_must_be_same = Since you are not running setup as root, the user must be the same as your userid '%s'.\n\n
dialog_assysuser_root_warning = You are strongly encouraged to use a non-root user for\nthe server uid.  If you feel you have made a mistake,\nplease go back to this dialog and enter another user.\n\n




More information about the Fedora-directory-commits mailing list