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