Bug 542570

Summary: Directory Server port number is not validated in the beginning.
Product: [Retired] 389 Reporter: Sankar Ramalingam <sramling>
Component: Install/UninstallAssignee: Nathan Kinder <nkinder>
Status: CLOSED CURRENTRELEASE QA Contact: Viktor Ashirov <vashirov>
Severity: high Docs Contact:
Priority: low    
Version: 1.2.6CC: jgalipea, rmeggins
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-12-07 16:36:43 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 434914, 543590    
Attachments:
Description Flags
0001-Bug-542570-Directory-Server-port-number-is-not-valid.patch
none
0001-Bug-542570-Directory-Server-port-number-is-not-valid.patch rmeggins: review+

Description Sankar Ramalingam 2009-11-30 08:14:57 UTC
Description of problem: 
The "Directory server network port" field is accepting any values like Alhanumeric, Alphabets and special characters. It doesn't validate the port number at the prompt and hence the instance creation fails in the end.


Version-Release number of selected component (if applicable): DS9.0


How reproducible: Consistently


Steps to Reproduce:
1. Run setup-ds.pl script and pass all the valid entries except the port no.
2. Pass a alphanumeric value, say "12NEW" when it prompts for "Directory server network port": 
3. Port number is not validated at the prompt and setup program proceeds with the instance creation.
  
Actual results: Instance creation fails due to which the port is not valid.


Expected results: Port number should be validated at the right place to avoid unnecessary failures.


Additional info:  error message displayed in the command prompt...

Could not import LDIF file '/tmp/ldif7t5qmO.ldif'.  Error: 256.  Output: importing data ...
[30/Nov/2009:13:41:24 +051800] dse - The entry cn=config in file /etc/dirsrv/slapd-alphaNport/dse.ldif is invalid, error code 1 (Operations error) - nsslapd-port: "123asss" is invalid, ports must range from 0 to 65535
[30/Nov/2009:13:41:24 +051800] dse - Could not load config file [dse.ldif]
[30/Nov/2009:13:41:24 +051800] dse - Please edit the file to correct the reported problems and then restart the server.

Error: Could not create directory server instance 'alphaNport'.
Exiting . . .
Log file is '/tmp/setupKUmlra.log'

Comment 2 Endi Sukma Dewata 2010-04-16 19:21:11 UTC
Created attachment 407177 [details]
0001-Bug-542570-Directory-Server-port-number-is-not-valid.patch

The code has been modified to validate the port value from the beginning of the string to the end to ensure that it only contains digits, and to generate the appropriate error message.

Comment 3 Rich Megginson 2010-04-20 02:40:07 UTC
Comment on attachment 407177 [details]
0001-Bug-542570-Directory-Server-port-number-is-not-valid.patch

This works for the case where you run setup-ds.pl interactively, but does not catch the case where the user has provided the value via cmd line (slapd.ServerPort=bogus) or in a .inf file.

Comment 4 Endi Sukma Dewata 2010-04-26 17:17:52 UTC
Created attachment 409238 [details]
0001-Bug-542570-Directory-Server-port-number-is-not-valid.patch

The patch has been modified to validate the port provided via slapd.ServerPort parameter as well.

Comment 5 Rich Megginson 2010-04-26 23:31:28 UTC
*** Bug 574532 has been marked as a duplicate of this bug. ***

Comment 6 Rich Megginson 2010-04-26 23:46:52 UTC
To ssh://git.fedorahosted.org/git/389/ds.git
   78c5066..1d7f7f5  master -> master
commit 1d7f7f52485922e9fa992de0e74ede1d44b81097
Author: Endi S. Dewata <edewata>
Date:   Sat Apr 17 00:08:35 2010 -0500

To ssh://git.fedorahosted.org/git/389/ds.git
   7fd0ad8..6fa8766  Directory_Server_8_2_Branch -> Directory_Server_8_2_Branch
commit 6fa876657c99509d770876b7c7c25dbebc8ebe53
Author: Endi S. Dewata <edewata>
Date:   Fri Apr 16 11:26:32 2010 -0500

Comment 7 Jenny Severance 2010-06-07 15:17:38 UTC
verified RHEL 4

version:

redhat-ds-base-8.2.0-2010060704.el4dsrv

OUTPUT Running setup-ds.pl:

The standard directory server network port number is 389.  However, if
you are not logged as the superuser, or port 389 is in use, the
default value will be a random unused port number greater than 1024.
If you want to use port 389, make sure that you are logged in as the
superuser, that port 389 is not in use.

Directory server network port [18261]: 12NEW
The port 12NEW is not a valid port. Please choose a valid port.