From a97eed06f04f4b12051296a098815f81682dca1a Mon Sep 17 00:00:00 2001 From: Quanah Gibson-Mount Date: Wed, 15 Apr 2020 19:31:07 +0000 Subject: [PATCH] ITS#6937 - Remove unused proctitle bits --- clients/tools/common.c | 83 ++++++------------------------- clients/tools/ldapcompare.c | 2 +- clients/tools/ldapdelete.c | 2 +- clients/tools/ldapmodify.c | 5 +- clients/tools/ldapmodrdn.c | 4 +- clients/tools/ldappasswd.c | 4 +- clients/tools/ldapsearch.c | 16 ++---- clients/tools/ldapvc.c | 3 +- clients/tools/ldapwhoami.c | 2 +- configure.in | 22 -------- include/ac/setproctitle.h | 33 ------------ include/portable.hin | 3 -- libraries/libldap/test.c | 4 +- libraries/liblutil/setproctitle.c | 78 ----------------------------- servers/slapd/main.c | 23 +++------ servers/slapd/slapcommon.c | 27 ++-------- servers/slapd/slappasswd.c | 10 ++-- tests/progs/slapd-addel.c | 2 +- tests/progs/slapd-auth.c | 6 +-- tests/progs/slapd-common.c | 16 +++--- tests/progs/slapd-modify.c | 4 +- tests/progs/slapd-modrdn.c | 2 +- tests/progs/slapd-mtread.c | 4 +- tests/progs/slapd-read.c | 4 +- tests/progs/slapd-search.c | 6 +-- tests/progs/slapd-tester.c | 16 +++--- 26 files changed, 78 insertions(+), 303 deletions(-) delete mode 100644 include/ac/setproctitle.h delete mode 100644 libraries/liblutil/setproctitle.c diff --git a/clients/tools/common.c b/clients/tools/common.c index 518017ae6b..b29cff77f5 100644 --- a/clients/tools/common.c +++ b/clients/tools/common.c @@ -285,63 +285,17 @@ tool_destroy( void ) BER_BVZERO( &pr_cookie ); } - if ( binddn != NULL ) { - ber_memfree( binddn ); - binddn = NULL; - } - if ( passwd.bv_val != NULL ) { ber_memfree( passwd.bv_val ); BER_BVZERO( &passwd ); } -#ifdef HAVE_CYRUS_SASL - if ( sasl_mech != NULL ) { - ber_memfree( sasl_mech ); - sasl_mech = NULL; - } -#endif /* HAVE_CYRUS_SASL */ - - if ( infile != NULL ) { - ber_memfree( infile ); - infile = NULL; - } - - if ( assertion ) { - ber_memfree( assertion ); - assertion = NULL; - } - - if ( authzid ) { - ber_memfree( authzid ); - authzid = NULL; - } - - if ( proxydn ) { - ber_memfree( proxydn ); - proxydn = NULL; - } - - if ( preread_attrs ) { - ber_memfree( preread_attrs ); - preread_attrs = NULL; - } - - if ( postread_attrs ) { - ber_memfree( postread_attrs ); - postread_attrs = NULL; - } - #ifdef LDAP_CONTROL_X_SESSION_TRACKING if ( !BER_BVISNULL( &stValue ) ) { ber_memfree( stValue.bv_val ); BER_BVZERO( &stValue ); } - if ( sessionTrackingName ) { - ber_memfree( sessionTrackingName ); - sessionTrackingName = NULL; - } #endif /* LDAP_CONTROL_X_SESSION_TRACKING */ } @@ -473,7 +427,7 @@ tool_args( int argc, char **argv ) fprintf( stderr, "%s: -D previously specified\n", prog ); exit( EXIT_FAILURE ); } - binddn = ber_strdup( optarg ); + binddn = optarg; break; case 'e': /* general extensions (controls and such) */ /* should be extended to support comma separated list of @@ -487,7 +441,7 @@ tool_args( int argc, char **argv ) optarg++; } - control = ber_strdup( optarg ); + control = optarg; if ( (cvalue = strchr( control, '=' )) != NULL ) { *cvalue++ = '\0'; } @@ -505,7 +459,7 @@ tool_args( int argc, char **argv ) assertctl = 1 + crit; assert( assertion == NULL ); - assertion = ber_strdup( cvalue ); + assertion = cvalue; } else if ( strcasecmp( control, "authzid" ) == 0 ) { if( authzid != NULL ) { @@ -532,7 +486,7 @@ tool_args( int argc, char **argv ) } assert( authzid == NULL ); - authzid = ber_strdup( cvalue ); + authzid = cvalue; #ifdef LDAP_CONTROL_OBSOLETE_PROXY_AUTHZ } else if ( strcasecmp( control, "proxydn" ) == 0 ) { @@ -558,7 +512,7 @@ tool_args( int argc, char **argv ) } assert( proxydn == NULL ); - proxydn = ber_strdup( cvalue ); + proxydn = cvalue; #endif /* LDAP_CONTROL_OBSOLETE_PROXY_AUTHZ */ } else if ( strcasecmp( control, "bauthzid" ) == 0 ) { @@ -639,7 +593,7 @@ tool_args( int argc, char **argv ) } preread = 1 + crit; - preread_attrs = ber_strdup( cvalue ); + preread_attrs = cvalue; } else if ( strcasecmp( control, "postread" ) == 0 ) { if( postread ) { @@ -648,7 +602,7 @@ tool_args( int argc, char **argv ) } postread = 1 + crit; - postread_attrs = ber_strdup( cvalue ); + postread_attrs = cvalue; #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR } else if ( strcasecmp( control, "chaining" ) == 0 ) { @@ -713,7 +667,7 @@ tool_args( int argc, char **argv ) usage(); } if ( cvalue ) { - sessionTrackingName = ber_strdup( cvalue ); + sessionTrackingName = cvalue; } #endif /* LDAP_CONTROL_X_SESSION_TRACKING */ @@ -793,24 +747,20 @@ tool_args( int argc, char **argv ) control ); usage(); } - if ( control ) { - ber_memfree( control ); - control = NULL; - } break; case 'f': /* read from file */ if( infile != NULL ) { fprintf( stderr, "%s: -f previously specified\n", prog ); exit( EXIT_FAILURE ); } - infile = ber_strdup( optarg ); + infile = optarg; break; case 'h': /* ldap host */ if( ldaphost != NULL ) { fprintf( stderr, "%s: -h previously specified\n", prog ); exit( EXIT_FAILURE ); } - ldaphost = ber_strdup( optarg ); + ldaphost = optarg; break; case 'H': /* ldap URI */ if( ldapuri != NULL ) { @@ -846,7 +796,7 @@ tool_args( int argc, char **argv ) nocanon++; break; case 'o': - control = ber_strdup( optarg ); + control = optarg; if ( (cvalue = strchr( control, '=' )) != NULL ) { *cvalue++ = '\0'; } @@ -906,7 +856,6 @@ tool_args( int argc, char **argv ) control ); usage(); } - ber_memfree(control); break; case 'O': #ifdef HAVE_CYRUS_SASL @@ -920,7 +869,7 @@ tool_args( int argc, char **argv ) exit( EXIT_FAILURE ); } authmethod = LDAP_AUTH_SASL; - sasl_secprops = ber_strdup( optarg ); + sasl_secprops = optarg; #else fprintf( stderr, "%s: not compiled with SASL support\n", prog ); exit( EXIT_FAILURE ); @@ -996,7 +945,7 @@ tool_args( int argc, char **argv ) exit( EXIT_FAILURE ); } authmethod = LDAP_AUTH_SASL; - sasl_realm = ber_strdup( optarg ); + sasl_realm = optarg; #else fprintf( stderr, "%s: not compiled with SASL support\n", prog ); @@ -1016,7 +965,7 @@ tool_args( int argc, char **argv ) exit( EXIT_FAILURE ); } authmethod = LDAP_AUTH_SASL; - sasl_authc_id = ber_strdup( optarg ); + sasl_authc_id = optarg; #else fprintf( stderr, "%s: not compiled with SASL support\n", prog ); @@ -1058,7 +1007,7 @@ tool_args( int argc, char **argv ) exit( EXIT_FAILURE ); } authmethod = LDAP_AUTH_SASL; - sasl_mech = ber_strdup( optarg ); + sasl_mech = optarg; #else fprintf( stderr, "%s: not compiled with SASL support\n", prog ); exit( EXIT_FAILURE ); @@ -1084,7 +1033,7 @@ tool_args( int argc, char **argv ) exit( EXIT_FAILURE ); } authmethod = LDAP_AUTH_SASL; - sasl_authz_id = ber_strdup( optarg ); + sasl_authz_id = optarg; #else fprintf( stderr, "%s: not compiled with SASL support\n", prog ); exit( EXIT_FAILURE ); diff --git a/clients/tools/ldapcompare.c b/clients/tools/ldapcompare.c index 4d0bfa86a7..aee1c07ffc 100644 --- a/clients/tools/ldapcompare.c +++ b/clients/tools/ldapcompare.c @@ -135,7 +135,7 @@ handle_private_option( int i ) optarg++; } - control = ber_strdup( optarg ); + control = optarg; if ( (cvalue = strchr( control, '=' )) != NULL ) { *cvalue++ = '\0'; } diff --git a/clients/tools/ldapdelete.c b/clients/tools/ldapdelete.c index 16a14d41ea..000e486f0e 100644 --- a/clients/tools/ldapdelete.c +++ b/clients/tools/ldapdelete.c @@ -111,7 +111,7 @@ handle_private_option( int i ) optarg++; } - control = strdup( optarg ); + control = optarg; if ( (cvalue = strchr( control, '=' )) != NULL ) { *cvalue++ = '\0'; } diff --git a/clients/tools/ldapmodify.c b/clients/tools/ldapmodify.c index 57657fdaa2..ead93688ca 100644 --- a/clients/tools/ldapmodify.c +++ b/clients/tools/ldapmodify.c @@ -152,7 +152,7 @@ handle_private_option( int i ) optarg++; } - control = ber_strdup( optarg ); + control = optarg; if ( (cvalue = strchr( control, '=' )) != NULL ) { *cvalue++ = '\0'; } @@ -181,7 +181,6 @@ handle_private_option( int i ) control ); usage(); } - ber_memfree( control ); break; case 'a': /* add */ @@ -196,7 +195,7 @@ handle_private_option( int i ) fprintf( stderr, _("%s: -S previously specified\n"), prog ); exit( EXIT_FAILURE ); } - rejfile = ber_strdup( optarg ); + rejfile = optarg; break; default: diff --git a/clients/tools/ldapmodrdn.c b/clients/tools/ldapmodrdn.c index 868900fbd3..3c2f05202d 100644 --- a/clients/tools/ldapmodrdn.c +++ b/clients/tools/ldapmodrdn.c @@ -122,7 +122,7 @@ handle_private_option( int i ) optarg++; } - control = strdup( optarg ); + control = optarg; if ( (cvalue = strchr( control, '=' )) != NULL ) { *cvalue++ = '\0'; } @@ -140,7 +140,7 @@ handle_private_option( int i ) prog, protocol ); exit( EXIT_FAILURE ); } - newSuperior = strdup( optarg ); + newSuperior = optarg; protocol = LDAP_VERSION3; break; diff --git a/clients/tools/ldappasswd.c b/clients/tools/ldappasswd.c index 6029d94b41..313a8dea6b 100644 --- a/clients/tools/ldappasswd.c +++ b/clients/tools/ldappasswd.c @@ -108,7 +108,7 @@ handle_private_option( int i ) optarg++; } - control = strdup( optarg ); + control = optarg; if ( (cvalue = strchr( control, '=' )) != NULL ) { *cvalue++ = '\0'; } @@ -133,7 +133,7 @@ handle_private_option( int i ) break; case 's': /* new password (secret) */ - newpw.bv_val = strdup (optarg); + newpw.bv_val = strdup( optarg ); { char* p; for( p = optarg; *p != '\0'; p++ ) { diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c index 812d753d61..a89c8b9dfb 100644 --- a/clients/tools/ldapsearch.c +++ b/clients/tools/ldapsearch.c @@ -383,7 +383,7 @@ handle_private_option( int i ) ++attrsonly; break; case 'b': /* search base */ - base = ber_strdup( optarg ); + base = optarg; break; case 'E': /* search extensions */ if( protocol == LDAP_VERSION2 ) { @@ -403,7 +403,7 @@ handle_private_option( int i ) optarg++; } - control = ber_strdup( optarg ); + control = optarg; if ( (cvalue = strchr( control, '=' )) != NULL ) { *cvalue++ = '\0'; } @@ -873,7 +873,7 @@ handle_private_option( int i ) break; case 'F': /* uri prefix */ if( urlpre ) free( urlpre ); - urlpre = strdup( optarg ); + urlpre = optarg; break; case 'l': /* time limit */ if ( strcasecmp( optarg, "none" ) == 0 ) { @@ -917,14 +917,14 @@ handle_private_option( int i ) } break; case 'S': /* sort attribute */ - sortattr = strdup( optarg ); + sortattr = optarg; break; case 't': /* write attribute values to TMPDIR files */ ++vals2tmp; break; case 'T': /* tmpdir */ if( tmpdir ) free( tmpdir ); - tmpdir = strdup( optarg ); + tmpdir = optarg; break; case 'u': /* include UFN */ ++includeufn; @@ -1609,12 +1609,6 @@ getNextPage: goto getNextPage; } - if ( base != NULL ) { - ber_memfree( base ); - } - if ( control != NULL ) { - ber_memfree( control ); - } if ( sss_keys != NULL ) { ldap_free_sort_keylist( sss_keys ); } diff --git a/clients/tools/ldapvc.c b/clients/tools/ldapvc.c index 09e465d4b9..49be3769f0 100644 --- a/clients/tools/ldapvc.c +++ b/clients/tools/ldapvc.c @@ -112,7 +112,7 @@ handle_private_option( int i ) optarg++; } - control = strdup( optarg ); + control = optarg; if ( (cvalue = strchr( control, '=' )) != NULL ) { *cvalue++ = '\0'; } @@ -255,7 +255,6 @@ handle_private_option( int i ) fprintf( stderr, _("Invalid Verify Credentials extension name: %s\n"), control ); usage(); } - free( control ); break; case 'a': /* request authzid */ diff --git a/clients/tools/ldapwhoami.c b/clients/tools/ldapwhoami.c index e2326fc665..050038140d 100644 --- a/clients/tools/ldapwhoami.c +++ b/clients/tools/ldapwhoami.c @@ -89,7 +89,7 @@ handle_private_option( int i ) optarg++; } - control = strdup( optarg ); + control = optarg; if ( (cvalue = strchr( control, '=' )) != NULL ) { *cvalue++ = '\0'; } diff --git a/configure.in b/configure.in index b9f0c6267b..cca3b0bb7e 100644 --- a/configure.in +++ b/configure.in @@ -228,7 +228,6 @@ dnl set default to traditional to enable the original debug style OL_ARG_ENABLE(debug,[ --enable-debug enable debugging], yes, [no yes traditional])dnl OL_ARG_ENABLE(dynamic,[ --enable-dynamic enable linking built binaries with dynamic libs], auto)dnl OL_ARG_ENABLE(syslog,[ --enable-syslog enable syslog support], auto)dnl -OL_ARG_ENABLE(proctitle,[ --enable-proctitle enable proctitle support], yes)dnl dnl OL_ARG_ENABLE(referrals,[ --enable-referrals enable LDAPv2+ Referrals (experimental)], no)dnl ol_enable_referrals=${ol_enable_referrals-no} OL_ARG_ENABLE(ipv6,[ --enable-ipv6 enable IPv6 support], auto)dnl @@ -2159,23 +2158,6 @@ if test $ol_enable_crypt != no ; then fi fi -dnl ---------------------------------------------------------------- -dnl FreeBSD (and others) have setproctitle(3) in -lutil -if test $ol_enable_proctitle != no ; then - AC_CHECK_FUNC(setproctitle, [have_setproctitle=yes], [ - AC_CHECK_LIB(util, setproctitle, - [have_setproctitle=yes - LUTIL_LIBS="$LUTIL_LIBS -lutil"], - [have_setproctitle=no - AC_LIBOBJ(setproctitle) - LIBSRCS="$LIBSRCS setproctitle.c"])]) - - if test $have_setproctitle = yes ; then - AC_DEFINE(HAVE_SETPROCTITLE,1, - [define if setproctitle(3) is available]) - fi -fi - dnl ---------------------------------------------------------------- if test $ol_enable_slp != no ; then AC_CHECK_HEADERS( slp.h ) @@ -2505,10 +2487,6 @@ if test "$ol_enable_syslog" = yes ; then AC_DEFINE(LDAP_SYSLOG,1, [define this to add syslog code]) fi -if test "$ol_enable_proctitle" != no ; then - AC_DEFINE(LDAP_PROCTITLE,1, - [define this for LDAP process title support]) -fi if test "$ol_enable_referrals" != no ; then AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS,LDAP_VENDOR_VERSION, [define to LDAP VENDOR VERSION]) diff --git a/include/ac/setproctitle.h b/include/ac/setproctitle.h deleted file mode 100644 index 0bacbf3fae..0000000000 --- a/include/ac/setproctitle.h +++ /dev/null @@ -1,33 +0,0 @@ -/* Generic setproctitle.h */ -/* $OpenLDAP$ */ -/* This work is part of OpenLDAP Software . - * - * Copyright 1998-2020 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 file LICENSE in the - * top-level directory of the distribution or, alternatively, at - * . - */ - -#ifndef _AC_SETPROCTITLE_H -#define _AC_SETPROCTITLE_H - -#ifdef LDAP_PROCTITLE - -#if defined( HAVE_LIBUTIL_H ) -# include -#else - /* use lutil version */ - LDAP_LUTIL_F (void) (setproctitle) LDAP_P((const char *fmt, ...)) \ - LDAP_GCCATTR((format(printf, 1, 2))); - LDAP_LUTIL_V (int) Argc; - LDAP_LUTIL_V (char) **Argv; -#endif - -#endif /* LDAP_PROCTITLE */ -#endif /* _AC_SETPROCTITLE_H */ diff --git a/include/portable.hin b/include/portable.hin index 6d98db2265..a785d09763 100644 --- a/include/portable.hin +++ b/include/portable.hin @@ -493,9 +493,6 @@ /* Define to 1 if you have the `setgid' function. */ #undef HAVE_SETGID -/* define if setproctitle(3) is available */ -#undef HAVE_SETPROCTITLE - /* Define to 1 if you have the `setpwfile' function. */ #undef HAVE_SETPWFILE diff --git a/libraries/libldap/test.c b/libraries/libldap/test.c index 9f415bb455..e3e587dcb8 100644 --- a/libraries/libldap/test.c +++ b/libraries/libldap/test.c @@ -320,12 +320,12 @@ main( int argc, char **argv ) break; case 't': /* copy ber's to given file */ - copyfname = strdup( optarg ); + copyfname = optarg; /* copyoptions = LBER_TO_FILE; */ break; case 'T': /* only output ber's to given file */ - copyfname = strdup( optarg ); + copyfname = optarg; /* copyoptions = (LBER_TO_FILE | LBER_TO_FILE_ONLY); */ break; diff --git a/libraries/liblutil/setproctitle.c b/libraries/liblutil/setproctitle.c deleted file mode 100644 index 1c2fbf575b..0000000000 --- a/libraries/liblutil/setproctitle.c +++ /dev/null @@ -1,78 +0,0 @@ -/* $OpenLDAP$ */ -/* This work is part of OpenLDAP Software . - * - * Copyright 1998-2020 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) 1990,1991 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. - */ - -#include "portable.h" - -#ifndef HAVE_SETPROCTITLE - -#include - -#include - -#include -#include -#include - -char **Argv; /* pointer to original (main's) argv */ -int Argc; /* original argc */ - -/* - * takes a printf-style format string (fmt) and up to three parameters (a,b,c) - * this clobbers the original argv... - */ - -/* VARARGS */ -void setproctitle( const char *fmt, ... ) -{ - static char *endargv = (char *)0; - char *s; - int i; - char buf[ 1024 ]; - va_list ap; - - va_start(ap, fmt); - - buf[sizeof(buf) - 1] = '\0'; - vsnprintf( buf, sizeof(buf)-1, fmt, ap ); - - va_end(ap); - - if ( endargv == (char *)0 ) { - /* set pointer to end of original argv */ - endargv = Argv[ Argc-1 ] + strlen( Argv[ Argc-1 ] ); - } - /* make ps print "([prog name])" */ - s = Argv[0]; - *s++ = '-'; - i = strlen( buf ); - if ( i > endargv - s - 2 ) { - i = endargv - s - 2; - buf[ i ] = '\0'; - } - strcpy( s, buf ); - s += i; - while ( s < endargv ) *s++ = ' '; -} -#endif /* NOSETPROCTITLE */ diff --git a/servers/slapd/main.c b/servers/slapd/main.c index 44432d1b3f..0a76bc4cc2 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -494,7 +494,7 @@ int main( int argc, char **argv ) case 'h': /* listen URLs */ if ( urls != NULL ) free( urls ); - urls = ch_strdup( optarg ); + urls = optarg; break; case 'c': /* provide sync cookie, override if exist in replica */ @@ -546,11 +546,11 @@ int main( int argc, char **argv ) } break; case 'f': /* read config file */ - configfile = ch_strdup( optarg ); + configfile = optarg; break; case 'F': /* use config dir */ - configdir = ch_strdup( optarg ); + configdir = optarg; break; case 'o': { @@ -615,25 +615,22 @@ int main( int argc, char **argv ) #ifdef HAVE_CHROOT case 'r': - if( sandbox ) free(sandbox); - sandbox = ch_strdup( optarg ); + sandbox = optarg; break; #endif #if defined(HAVE_SETUID) && defined(HAVE_SETGID) case 'u': /* user name */ - if( username ) free(username); - username = ch_strdup( optarg ); + username = optarg; break; case 'g': /* group name */ - if( groupname ) free(groupname); - groupname = ch_strdup( optarg ); + groupname = optarg; break; #endif /* SETUID && GETUID */ case 'n': /* NT service name */ - serverName = ch_strdup( optarg ); + serverName = optarg; break; case 't': @@ -1100,12 +1097,6 @@ stop: config_destroy(); - if ( configfile ) - ch_free( configfile ); - if ( configdir ) - ch_free( configdir ); - if ( urls ) - ch_free( urls ); if ( global_host ) ch_free( global_host ); diff --git a/servers/slapd/slapcommon.c b/servers/slapd/slapcommon.c index f170496e2d..954cc38585 100644 --- a/servers/slapd/slapcommon.c +++ b/servers/slapd/slapcommon.c @@ -362,7 +362,7 @@ slap_tool_init( while ( (i = getopt( argc, argv, options )) != EOF ) { switch ( i ) { case 'a': - filterstr = ch_strdup( optarg ); + filterstr = optarg; break; case 'b': @@ -399,11 +399,11 @@ slap_tool_init( break; case 'f': /* specify a conf file */ - conffile = ch_strdup( optarg ); + conffile = optarg; break; case 'F': /* specify a conf dir */ - confdir = ch_strdup( optarg ); + confdir = optarg; break; case 'g': /* disable subordinate glue */ @@ -464,7 +464,7 @@ slap_tool_init( break; case 'l': /* LDIF file */ - ldiffile = ch_strdup( optarg ); + ldiffile = optarg; break; case 'M': @@ -530,7 +530,7 @@ slap_tool_init( case SLAPSCHEMA: /* dump subtree */ ch_free( subtree ); - subtree = ch_strdup( optarg ); + subtree = optarg; break; } break; @@ -753,9 +753,6 @@ slap_tool_init( fprintf( stderr, "Invalid filter '%s'\n", filterstr ); exit( EXIT_FAILURE ); } - - ch_free( filterstr ); - filterstr = NULL; } if( subtree ) { @@ -894,20 +891,6 @@ startup:; mal_leaktrace(1); #endif - if ( conffile != NULL ) { - ch_free( conffile ); - conffile = NULL; - } - - if ( confdir != NULL ) { - ch_free( confdir ); - confdir = NULL; - } - - if ( ldiffile != NULL ) { - ch_free( ldiffile ); - ldiffile = NULL; - } /* slapdn doesn't specify a backend to startup */ if ( !dryrun && tool != SLAPDN ) { diff --git a/servers/slapd/slappasswd.c b/servers/slapd/slappasswd.c index 95d081d6e1..1a782b2fc0 100644 --- a/servers/slapd/slappasswd.c +++ b/servers/slapd/slappasswd.c @@ -77,14 +77,10 @@ parse_slappasswdopt( void ) } if ( strncasecmp( optarg, "module-path", len ) == 0 ) { - if ( modulepath ) - ch_free( modulepath ); - modulepath = ch_strdup( p ); + modulepath = p; } else if ( strncasecmp( optarg, "module-load", len ) == 0 ) { - if ( moduleload ) - ch_free( moduleload ); - moduleload = ch_strdup( p ); + moduleload = p; } else { return -1; @@ -151,7 +147,7 @@ slappasswd( int argc, char *argv[] ) return EXIT_FAILURE; } else { - scheme = ch_strdup( optarg ); + scheme = optarg; } break; diff --git a/tests/progs/slapd-addel.c b/tests/progs/slapd-addel.c index cbb4cabc4b..9fab078968 100644 --- a/tests/progs/slapd-addel.c +++ b/tests/progs/slapd-addel.c @@ -84,7 +84,7 @@ main( int argc, char **argv ) break; case 'f': /* file with entry search request */ - filename = strdup( optarg ); + filename = optarg; break; default: diff --git a/tests/progs/slapd-auth.c b/tests/progs/slapd-auth.c index 20c73abede..d475f116e7 100644 --- a/tests/progs/slapd-auth.c +++ b/tests/progs/slapd-auth.c @@ -81,15 +81,15 @@ main( int argc, char **argv ) while ( (i = getopt( argc, argv, "b:D:H:w:f:n:i:t:r:R:" )) != EOF ) { switch( i ) { case 'b': /* base DN of a tree of user DNs */ - base = strdup( optarg ); + base = optarg; break; case 'D': - binder = strdup( optarg ); + binder = optarg; break; case 'H': /* the server uri */ - uri = strdup( optarg ); + uri = optarg; break; case 'w': diff --git a/tests/progs/slapd-common.c b/tests/progs/slapd-common.c index 101e43d848..774c35eb41 100644 --- a/tests/progs/slapd-common.c +++ b/tests/progs/slapd-common.c @@ -306,7 +306,7 @@ tester_config_opt( struct tester_conn_args *config, char opt, char *optarg ) break; case 'D': - config->binddn = strdup( optarg ); + config->binddn = optarg; break; case 'd': @@ -333,11 +333,11 @@ tester_config_opt( struct tester_conn_args *config, char opt, char *optarg ) } case 'H': - config->uri = strdup( optarg ); + config->uri = optarg; break; case 'h': - config->host = strdup( optarg ); + config->host = optarg; break; case 'i': @@ -365,7 +365,7 @@ tester_config_opt( struct tester_conn_args *config, char opt, char *optarg ) return -1; } config->authmethod = LDAP_AUTH_SASL; - config->secprops = ber_strdup( optarg ); + config->secprops = optarg; break; case 'R': @@ -376,7 +376,7 @@ tester_config_opt( struct tester_conn_args *config, char opt, char *optarg ) return -1; } config->authmethod = LDAP_AUTH_SASL; - config->realm = ber_strdup( optarg ); + config->realm = optarg; break; case 'U': @@ -387,7 +387,7 @@ tester_config_opt( struct tester_conn_args *config, char opt, char *optarg ) return -1; } config->authmethod = LDAP_AUTH_SASL; - config->authc_id = ber_strdup( optarg ); + config->authc_id = optarg; break; case 'X': @@ -398,7 +398,7 @@ tester_config_opt( struct tester_conn_args *config, char opt, char *optarg ) return -1; } config->authmethod = LDAP_AUTH_SASL; - config->authz_id = ber_strdup( optarg ); + config->authz_id = optarg; break; case 'Y': @@ -409,7 +409,7 @@ tester_config_opt( struct tester_conn_args *config, char opt, char *optarg ) return -1; } config->authmethod = LDAP_AUTH_SASL; - config->mech = ber_strdup( optarg ); + config->mech = optarg; break; #endif diff --git a/tests/progs/slapd-modify.c b/tests/progs/slapd-modify.c index 23bb7e9d90..ee67387e6a 100644 --- a/tests/progs/slapd-modify.c +++ b/tests/progs/slapd-modify.c @@ -78,11 +78,11 @@ main( int argc, char **argv ) break; case 'e': /* entry to modify */ - entry = strdup( optarg ); + entry = optarg; break; case 'a': - ava = strdup( optarg ); + ava = optarg; break; default: diff --git a/tests/progs/slapd-modrdn.c b/tests/progs/slapd-modrdn.c index d82d82c69e..d25be2ca97 100644 --- a/tests/progs/slapd-modrdn.c +++ b/tests/progs/slapd-modrdn.c @@ -79,7 +79,7 @@ main( int argc, char **argv ) break; case 'e': /* entry to rename */ - entry = strdup( optarg ); + entry = optarg; break; default: diff --git a/tests/progs/slapd-mtread.c b/tests/progs/slapd-mtread.c index c8024cb6e1..1b99b625c2 100644 --- a/tests/progs/slapd-mtread.c +++ b/tests/progs/slapd-mtread.c @@ -190,11 +190,11 @@ main( int argc, char **argv ) break; case 'e': /* DN to search for */ - entry = strdup( optarg ); + entry = optarg; break; case 'f': /* the search request */ - filter = strdup( optarg ); + filter = optarg; break; case 'F': diff --git a/tests/progs/slapd-read.c b/tests/progs/slapd-read.c index f95228317b..bf8b8f7f1b 100644 --- a/tests/progs/slapd-read.c +++ b/tests/progs/slapd-read.c @@ -105,11 +105,11 @@ main( int argc, char **argv ) break; case 'e': /* DN to search for */ - entry = strdup( optarg ); + entry = optarg; break; case 'f': /* the search request */ - filter = strdup( optarg ); + filter = optarg; break; case 'F': diff --git a/tests/progs/slapd-search.c b/tests/progs/slapd-search.c index 321fd80e38..f80b7a77a2 100644 --- a/tests/progs/slapd-search.c +++ b/tests/progs/slapd-search.c @@ -110,15 +110,15 @@ main( int argc, char **argv ) break; case 'a': - attr = strdup( optarg ); + attr = optarg; break; case 'b': /* file with search base */ - sbase = strdup( optarg ); + sbase = optarg; break; case 'f': /* the search request */ - filter = strdup( optarg ); + filter = optarg; break; case 'F': diff --git a/tests/progs/slapd-tester.c b/tests/progs/slapd-tester.c index bf9e10b964..959fb25195 100644 --- a/tests/progs/slapd-tester.c +++ b/tests/progs/slapd-tester.c @@ -251,7 +251,7 @@ main( int argc, char **argv ) break; case 'd': /* data directory */ - dirname = strdup( optarg ); + dirname = optarg; break; case 'F': @@ -259,11 +259,11 @@ main( int argc, char **argv ) break; case 'H': /* slapd uri */ - uri = strdup( optarg ); + uri = optarg; break; case 'h': /* slapd host */ - host = strdup( optarg ); + host = optarg; break; case 'I': @@ -325,7 +325,7 @@ main( int argc, char **argv ) break; case 'L': /* the number of outerloops per client */ - outerloops = strdup( optarg ); + outerloops = optarg; break; case 'N': @@ -333,15 +333,15 @@ main( int argc, char **argv ) break; case 'P': /* prog directory */ - progdir = strdup( optarg ); + progdir = optarg; break; case 'p': /* the servers port number */ - port = strdup( optarg ); + port = optarg; break; case 'r': /* the number of retries in case of error */ - retries = strdup( optarg ); + retries = optarg; break; case 'S': @@ -349,7 +349,7 @@ main( int argc, char **argv ) break; case 't': /* the delay in seconds between each retry */ - delay = strdup( optarg ); + delay = optarg; break; case 'w': /* the managers passwd */