X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fshell-backends%2Fshellutil.c;h=0321061bd4c62970b2d494bbe67d7e66a39a7bb8;hb=f96e6378d6cd06c744a47af5e5e551cbb494826a;hp=d05ec738959ea8f05eb941cf809f99f9fbb96e28;hpb=403f4479bc9f9a864122d4aeecf7284408918302;p=openldap diff --git a/servers/slapd/shell-backends/shellutil.c b/servers/slapd/shell-backends/shellutil.c index d05ec73895..0321061bd4 100644 --- a/servers/slapd/shell-backends/shellutil.c +++ b/servers/slapd/shell-backends/shellutil.c @@ -1,18 +1,32 @@ +/* shellutil.c - common routines useful when building shell-based backends */ /* $OpenLDAP$ */ -/* - shellutil.c - common routines useful when building shell-based backends - for the standalone ldap server - - Copyright (c) 1995 Regents of the University of Michigan. - All rights reserved. - - Redistribution and use in source and binary forms are permitted - provided that this notice is preserved and that due credit is given - to the University of Michigan at Ann Arbor. The name of the University - may not be used to endorse or promote products derived from this - software without specific prior written permission. This software - is provided ``as is'' without express or implied warranty. -*/ +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2006 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in the file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ +/* Portions Copyright (c) 1995 Regents of the University of Michigan. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of Michigan at Ann Arbor. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. This software + * is provided ``as is'' without express or implied warranty. + */ +/* ACKNOWLEDGEMENTS: + * This work was originally developed by the University of Michigan + * (as part of U-MICH LDAP). + */ #include "portable.h" @@ -89,7 +103,8 @@ write_entry( struct ldop *op, struct ldentry *entry, FILE *ofp ) int test_filter( struct ldop *op, struct ldentry *entry ) { - return (( random() & 0x07 ) == 0x07 ); /* XXX random for now */ + return ((random() & 0x07 ) == 0x07) /* XXX random for now */ + ? LDAP_COMPARE_TRUE : LDAP_COMPARE_FALSE; } @@ -140,7 +155,7 @@ parse_input( FILE *ifp, FILE *ofp, struct ldop *op ) struct inputparams *ip; if ( fgets( line, MAXLINELEN, ifp ) == NULL ) { - write_result( ofp, LDAP_OPERATIONS_ERROR, NULL, "Empty Input" ); + write_result( ofp, LDAP_OTHER, NULL, "Empty Input" ); } line[ strlen( line ) - 1 ] = '\0'; if ( strncasecmp( line, STR_OP_SEARCH, sizeof( STR_OP_SEARCH ) - 1 ) @@ -170,21 +185,32 @@ parse_input( FILE *ifp, FILE *ofp, struct ldop *op ) op->ldop_dn = estrdup( args ); break; case IP_TYPE_SCOPE: - if (( op->ldop_srch.ldsp_scope = atoi( args )) != LDAP_SCOPE_BASE && + if ( lutil_atoi( &op->ldop_srch.ldsp_scope, args ) != 0 || + ( op->ldop_srch.ldsp_scope != LDAP_SCOPE_BASE && op->ldop_srch.ldsp_scope != LDAP_SCOPE_ONELEVEL && - op->ldop_srch.ldsp_scope != LDAP_SCOPE_SUBTREE ) { - write_result( ofp, LDAP_OPERATIONS_ERROR, NULL, "Bad scope" ); + op->ldop_srch.ldsp_scope != LDAP_SCOPE_SUBTREE ) ) + { + write_result( ofp, LDAP_OTHER, NULL, "Bad scope" ); return( -1 ); } break; case IP_TYPE_ALIASDEREF: - op->ldop_srch.ldsp_aliasderef = atoi( args ); + if ( lutil_atoi( &op->ldop_srch.ldsp_aliasderef, args ) != 0 ) { + write_result( ofp, LDAP_OTHER, NULL, "Bad alias deref" ); + return( -1 ); + } break; case IP_TYPE_SIZELIMIT: - op->ldop_srch.ldsp_sizelimit = atoi( args ); + if ( lutil_atoi( &op->ldop_srch.ldsp_sizelimit, args ) != 0 ) { + write_result( ofp, LDAP_OTHER, NULL, "Bad size limit" ); + return( -1 ); + } break; case IP_TYPE_TIMELIMIT: - op->ldop_srch.ldsp_timelimit = atoi( args ); + if ( lutil_atoi( &op->ldop_srch.ldsp_timelimit, args ) != 0 ) { + write_result( ofp, LDAP_OTHER, NULL, "Bad time limit" ); + return( -1 ); + } break; case IP_TYPE_FILTER: op->ldop_srch.ldsp_filter = estrdup( args ); @@ -213,7 +239,7 @@ parse_input( FILE *ifp, FILE *ofp, struct ldop *op ) if ( op->ldop_suffixes == NULL || op->ldop_dn == NULL || op->ldop_srch.ldsp_filter == NULL ) { - write_result( ofp, LDAP_OPERATIONS_ERROR, NULL, + write_result( ofp, LDAP_OTHER, NULL, "Required suffix:, base:, or filter: missing" ); return( -1 ); }