mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-21 03:10:25 +08:00
ITS#2807: version option support (-V[V]) based on patch submitted
by <luca.scamoni@sys-net.it>.
This commit is contained in:
parent
3c3af90e46
commit
4898913fb6
@ -103,6 +103,7 @@ static int cnvt_str2int( char *, STRDISP_P, int );
|
||||
#endif /* LOG_LOCAL4 */
|
||||
|
||||
static int check_config = 0;
|
||||
static int version = 0;
|
||||
|
||||
static void
|
||||
usage( char *name )
|
||||
@ -130,6 +131,7 @@ usage( char *name )
|
||||
"\t-t\t\tCheck configuration file and exit\n"
|
||||
#if defined(HAVE_SETUID) && defined(HAVE_SETGID)
|
||||
"\t-u user\t\tUser (id or name) to run as\n"
|
||||
"\t-V\t\tprint version info (-VV only)\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
@ -239,7 +241,7 @@ int main( int argc, char **argv )
|
||||
#endif
|
||||
|
||||
while ( (i = getopt( argc, argv,
|
||||
"c:d:f:h:s:n:t"
|
||||
"c:d:f:h:s:n:t:V"
|
||||
#if LDAP_PF_INET6
|
||||
"46"
|
||||
#endif
|
||||
@ -346,6 +348,9 @@ int main( int argc, char **argv )
|
||||
case 't':
|
||||
check_config++;
|
||||
break;
|
||||
case 'V':
|
||||
version++;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage( argv[0] );
|
||||
@ -364,11 +369,10 @@ int main( int argc, char **argv )
|
||||
ldif_debug = slap_debug;
|
||||
#endif
|
||||
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG( SLAPD, INFO, "%s", Versionstr, 0, 0 );
|
||||
#else
|
||||
Debug( LDAP_DEBUG_TRACE, "%s", Versionstr, 0, 0 );
|
||||
#endif
|
||||
if ( version ) {
|
||||
fprintf( stderr, "%s\n", Versionstr );
|
||||
if ( version > 1 ) goto stop;
|
||||
}
|
||||
|
||||
if( serverName == NULL ) {
|
||||
if ( (serverName = strrchr( argv[0], *LDAP_DIRSEP )) == NULL ) {
|
||||
@ -384,6 +388,12 @@ int main( int argc, char **argv )
|
||||
openlog( serverName, OPENLOG_OPTIONS );
|
||||
#endif
|
||||
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG( SLAPD, INFO, "%s", Versionstr, 0, 0 );
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ANY, "%s", Versionstr, 0, 0 );
|
||||
#endif
|
||||
|
||||
if( !check_config && slapd_daemon_init( urls ) != 0 ) {
|
||||
rc = 1;
|
||||
SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 16 );
|
||||
|
@ -51,7 +51,7 @@ sslurpd: version.o
|
||||
|
||||
version.c: Makefile
|
||||
@-$(RM) $@
|
||||
$(MKVERSION) slurpd > $@
|
||||
$(MKVERSION) -s -n Versionstr slurpd > $@
|
||||
|
||||
version.o: version.c $(OBJS) $(SLURPD_L)
|
||||
|
||||
|
@ -80,7 +80,7 @@ doargs(
|
||||
g->myname = strdup( g->myname + 1 );
|
||||
}
|
||||
|
||||
while ( (i = getopt( argc, argv, "d:f:n:or:t:" )) != EOF ) {
|
||||
while ( (i = getopt( argc, argv, "d:f:n:or:t:V" )) != EOF ) {
|
||||
switch ( i ) {
|
||||
case 'd': /* set debug level and 'do not detach' flag */
|
||||
g->no_detach = 1;
|
||||
@ -140,6 +140,9 @@ doargs(
|
||||
snprintf(g->slurpd_rdir, sz,
|
||||
"%s" LDAP_DIRSEP "replica", optarg);
|
||||
} break;
|
||||
case 'V':
|
||||
(g->version)++;
|
||||
break;
|
||||
default:
|
||||
usage( g->myname );
|
||||
return( -1 );
|
||||
|
@ -84,6 +84,7 @@ init_globals( void )
|
||||
g->myname = NULL;
|
||||
g->serverName = NULL;
|
||||
g->srpos = 0L;
|
||||
g->version = 0;
|
||||
if ( St_init( &(g->st)) < 0 ) {
|
||||
fprintf( stderr, "Cannot initialize status data\n" );
|
||||
exit( EXIT_FAILURE );
|
||||
|
@ -81,6 +81,8 @@ typedef struct globals {
|
||||
/* Default name of kerberos srvtab file */
|
||||
char *default_srvtab;
|
||||
#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */
|
||||
/* Non-zero if we shall print the version */
|
||||
int version;
|
||||
} Globals;
|
||||
|
||||
|
||||
|
@ -60,6 +60,11 @@
|
||||
#define MAIN_RETURN(x) return(x)
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MKVERSION
|
||||
const char Versionstr[] =
|
||||
OPENLDAP_PACKAGE " " OPENLDAP_VERSION " Standalone LDAP Replicator (slurpd)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NT_SERVICE_MANAGER
|
||||
void WINAPI ServiceMain( DWORD argc, LPTSTR *argv )
|
||||
#else
|
||||
@ -139,6 +144,20 @@ int main( int argc, char **argv )
|
||||
goto stop;
|
||||
}
|
||||
|
||||
if ( sglob->version ) {
|
||||
fprintf(stderr, "%s\n", Versionstr);
|
||||
if (sglob->version > 1 ) {
|
||||
rc = 1;
|
||||
goto stop;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG( SLURPD, INFO, "%s\n", Versionstr, 0, 0 );
|
||||
#else
|
||||
Debug ( LDAP_DEBUG_ANY, "%s\n", Versionstr, 0, 0 );
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Read slapd config file and initialize Re (per-replica) structs.
|
||||
*/
|
||||
|
@ -107,4 +107,7 @@ int tsleep LDAP_P((time_t interval));
|
||||
void start_lwp_scheduler LDAP_P(( void ));
|
||||
#endif
|
||||
|
||||
/*main.c */
|
||||
extern const char Versionstr[];
|
||||
|
||||
#endif /* _PROTO_SLURP */
|
||||
|
Loading…
Reference in New Issue
Block a user