Issue 4453 - ldapdelete prints error message to stdout
Summary: ldapdelete prints error message to stdout
Status: VERIFIED FIXED
Alias: None
Product: OpenLDAP
Classification: Unclassified
Component: slapd (show other issues)
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-25 20:22 UTC by openldap@flyn.org
Modified: 2014-08-01 21:06 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description openldap@flyn.org 2006-03-25 20:22:28 UTC
Full_Name: W. Michael Petullo
Version: 2.3.19
OS: Fedora Core 5
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (63.13.194.34)


The ldapdelete command prints its error message to standard out.  However, the
manpage states, "Exit status is 0 if no errors occur.  Errors result in a
non-zero exit status and a diagnostic message being written to standard error."

1.  Try to delete an LDAP object that does not exist; execute a command like:
ldapdelete -x -D cn=Manager,dc=flyn,dc=org -W  "cn=Domain
Users,ou=Group,dc=flyn,dc=org" 2> /dev/null

2.  Execute "echo $?" to confirm exit status is non-zero.

3.  Notice that ldapdelete printed error to standard out.  The following was
printed:
Delete Result: No such object (32)
Matched DN: ou=group,dc=flyn,dc=org

The exit status was non-zero.  According to the manpage the error message
should
go to standard error.

Comment 1 Quanah Gibson-Mount 2006-03-25 22:11:08 UTC

--On Saturday, March 25, 2006 8:22 PM +0000 openldap@flyn.org wrote:

> Full_Name: W. Michael Petullo
> Version: 2.3.19
> OS: Fedora Core 5
> URL: ftp://ftp.openldap.org/incoming/
> Submission from: (NULL) (63.13.194.34)
>
>
> The ldapdelete command prints its error message to standard out.
> However, the manpage states, "Exit status is 0 if no errors occur.
> Errors result in a non-zero exit status and a diagnostic message being
> written to standard error."
>
> 1.  Try to delete an LDAP object that does not exist; execute a command
> like: ldapdelete -x -D cn=Manager,dc=flyn,dc=org -W  "cn=Domain
> Users,ou=Group,dc=flyn,dc=org" 2> /dev/null
>
> 2.  Execute "echo $?" to confirm exit status is non-zero.
>
> 3.  Notice that ldapdelete printed error to standard out.  The following
> was printed:
> Delete Result: No such object (32)
> Matched DN: ou=group,dc=flyn,dc=org
>
> The exit status was non-zero.  According to the manpage the error message
> should
> go to standard error.

Or maybe the man page is wrong, and it should say it should go to standard 
out.

--Quanah

--
Quanah Gibson-Mount
Principal Software Developer
ITS/Shared Application Services
Stanford University
GnuPG Public Key: http://www.stanford.edu/~quanah/pgp.html

Comment 2 peter@adpm.de 2006-03-26 12:35:26 UTC
Hi,

the attached patch should fix the issue:

--- ldapdelete.c        2006-01-03 23:16:01.000000000 +0100
+++ ldapdelete.c        2006-03-26 13:58:12.000000000 +0200
@@ -263,12 +263,12 @@
                return rc;
        }

-       if( verbose || code != LDAP_SUCCESS ||
-               (matcheddn && *matcheddn) || (text && *text) || (refs && 
*refs) )
-       {
-               printf( _("Delete Result: %s (%d)\n"),
-                       ldap_err2string( code ), code );
+       if (code != LDAP_SUCCESS) {
+               fprintf( stderr, "%s: delete result: %s (%d)\n",
+                       prog, ldap_err2string( code ), code );
+       }

+       if( verbose ) {
                if( text && *text ) {
                        printf( _("Additional info: %s\n"), text );
                }


Hope it helps
Peter

-- 
Peter Marschall
eMail: peter@adpm.de

Comment 3 Howard Chu 2006-04-04 20:26:07 UTC
openldap@flyn.org wrote:
> Full_Name: W. Michael Petullo
> Version: 2.3.19
> OS: Fedora Core 5
> URL: ftp://ftp.openldap.org/incoming/
> Submission from: (NULL) (63.13.194.34)
>
>
> The ldapdelete command prints its error message to standard out.  However, the
> manpage states, "Exit status is 0 if no errors occur.  Errors result in a
> non-zero exit status and a diagnostic message being written to standard error."
>
> 1.  Try to delete an LDAP object that does not exist; execute a command like:
> ldapdelete -x -D cn=Manager,dc=flyn,dc=org -W  "cn=Domain
> Users,ou=Group,dc=flyn,dc=org" 2> /dev/null
>
> 2.  Execute "echo $?" to confirm exit status is non-zero.
>
> 3.  Notice that ldapdelete printed error to standard out.  The following was
> printed:
> Delete Result: No such object (32)
> Matched DN: ou=group,dc=flyn,dc=org
>
> The exit status was non-zero.  According to the manpage the error message
> should
> go to standard error.

It looks like there's more problems here; when the "verbose" option is 
used ldapmodify and ldapdelete print a message that the operation was 
completed after the request was successfully sent to the server, but 
before reading the server's reply. I would expect that the "completed" 
message should not be printed until after we know the server 
successfully processed the request.

-- 
  -- Howard Chu
  Chief Architect, Symas Corp.  http://www.symas.com
  Director, Highland Sun        http://highlandsun.com/hyc
  OpenLDAP Core Team            http://www.openldap.org/project/

Comment 4 peter@adpm.de 2006-04-24 18:44:54 UTC
Hi Howard,

plaese apply the patch as it fixes the issue in the bug report.
("prints error messages to stdout") and create another bug
report for the problem you found.

Unfortunately my knowledge about the LDAP C API is not 
good enough to solve this problem as well.

Thanks in advance for applying the patch
Peter

-- 
Peter Marschall     |   eMail: peter.marschall@adpm.de
Scheffelstraße 15   |   Tel:   +49 931 14721
D-97072 Würzburg    |
PGP: 0BB1 04A3 0FB0 E27F 8018 52BA A286 7B23 9C22 2C83

Comment 5 Howard Chu 2006-05-12 05:56:49 UTC
changed notes
changed state Open to Test
moved from Incoming to Software Bugs
Comment 6 Kurt Zeilenga 2006-05-12 23:46:36 UTC
changed notes
changed state Test to Release
Comment 7 Kurt Zeilenga 2006-05-17 03:40:04 UTC
changed state Release to Closed
Comment 8 Howard Chu 2009-02-17 05:18:46 UTC
moved from Software Bugs to Archive.Software Bugs
Comment 9 OpenLDAP project 2014-08-01 21:06:44 UTC
fixed in HEAD/re23