Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
openldap
OpenLDAP
Commits
9a39dcb7
Commit
9a39dcb7
authored
Apr 15, 2003
by
Pierangelo Masarati
Browse files
add slurpd pid/args files
parent
adf3744d
Changes
5
Hide whitespace changes
Inline
Side-by-side
doc/man/man5/slapd.conf.5
View file @
9a39dcb7
...
...
@@ -550,6 +550,19 @@ Specify the referral to pass back when
cannot find a local database to handle a request.
If specified multiple times, each url is provided.
.TP
.B replica-argsfile
The ( absolute ) name of a file that will hold the
.B slurpd
server's command line options
if started without the debugging command line option.
.TP
.B replica-pidfile
The ( absolute ) name of a file that will hold the
.B slurpd
server's process ID ( see
.BR getpid (2)
) if started without the debugging command line option.
.TP
.B require <conditions>
Specify a set of conditions (separated by white space) to
require (default none).
...
...
servers/slurpd/ch_malloc.c
View file @
9a39dcb7
...
...
@@ -109,6 +109,25 @@ ch_calloc(
return
(
new
);
}
/*
* Just like strdup, except we check the returned value and exit
* if anything goes wrong.
*/
char
*
ch_strdup
(
const
char
*
string
)
{
char
*
new
;
if
(
(
new
=
ber_strdup
(
string
))
==
NULL
)
{
fprintf
(
stderr
,
"ch_strdup: duplication of
\"
%s
\"
failed
\n
"
,
string
);
exit
(
EXIT_FAILURE
);
}
return
(
new
);
}
/*
* Just like free, except we check to see if p is null.
...
...
servers/slurpd/config.c
View file @
9a39dcb7
...
...
@@ -48,7 +48,8 @@ char **cargv;
/* current config file line # */
static
int
lineno
;
char
*
slurpd_pid_file
=
NULL
;
char
*
slurpd_args_file
=
NULL
;
/*
* Read the slapd config file, looking only for config options we're
...
...
@@ -153,6 +154,41 @@ slurpd_read_config(
free
(
savefname
);
lineno
=
savelineno
-
1
;
}
else
if
(
strcasecmp
(
cargv
[
0
],
"replica-pidfile"
)
==
0
)
{
if
(
cargc
<
2
)
{
#ifdef NEW_LOGGING
LDAP_LOG
(
CONFIG
,
CRIT
,
"%s: line %d missing file name in
\"
replica-pidfile <file>
\"
"
"line.
\n
"
,
fname
,
lineno
,
0
);
#else
Debug
(
LDAP_DEBUG_ANY
,
"%s: line %d: missing file name in
\"
replica-pidfile <file>
\"
line
\n
"
,
fname
,
lineno
,
0
);
#endif
return
(
1
);
}
slurpd_pid_file
=
ch_strdup
(
cargv
[
1
]
);
}
else
if
(
strcasecmp
(
cargv
[
0
],
"replica-argsfile"
)
==
0
)
{
if
(
cargc
<
2
)
{
#ifdef NEW_LOGGING
LDAP_LOG
(
CONFIG
,
CRIT
,
"%s: %d: missing file name in "
"
\"
argsfile <file>
\"
line.
\n
"
,
fname
,
lineno
,
0
);
#else
Debug
(
LDAP_DEBUG_ANY
,
"%s: line %d: missing file name in
\"
argsfile <file>
\"
line
\n
"
,
fname
,
lineno
,
0
);
#endif
return
(
1
);
}
slurpd_args_file
=
ch_strdup
(
cargv
[
1
]
);
}
}
fclose
(
fp
);
...
...
servers/slurpd/main.c
View file @
9a39dcb7
...
...
@@ -25,6 +25,7 @@
#include
<stdio.h>
#include
<sys/stat.h>
#include
<ac/stdlib.h>
#include
<ac/unistd.h>
#include
"slurp.h"
#include
"globals.h"
...
...
@@ -176,6 +177,35 @@ int main( int argc, char **argv )
goto
stop
;
}
if
(
slurpd_pid_file
!=
NULL
)
{
FILE
*
fp
=
fopen
(
slurpd_pid_file
,
"w"
);
if
(
fp
!=
NULL
)
{
fprintf
(
fp
,
"%d
\n
"
,
(
int
)
getpid
()
);
fclose
(
fp
);
}
else
{
free
(
slurpd_pid_file
);
slurpd_pid_file
=
NULL
;
}
}
if
(
slurpd_args_file
!=
NULL
)
{
FILE
*
fp
=
fopen
(
slurpd_args_file
,
"w"
);
if
(
fp
!=
NULL
)
{
for
(
i
=
0
;
i
<
argc
;
i
++
)
{
fprintf
(
fp
,
"%s "
,
argv
[
i
]
);
}
fprintf
(
fp
,
"
\n
"
);
fclose
(
fp
);
}
else
{
free
(
slurpd_args_file
);
slurpd_args_file
=
NULL
;
}
}
/*
* Detach from the controlling terminal
* unless the -d flag is given or in one-shot mode.
...
...
@@ -262,6 +292,15 @@ stop:
#else
Debug
(
LDAP_DEBUG_ANY
,
"slurpd: terminated.
\n
"
,
0
,
0
,
0
);
#endif
if
(
slurpd_pid_file
!=
NULL
)
{
unlink
(
slurpd_pid_file
);
}
if
(
slurpd_args_file
!=
NULL
)
{
unlink
(
slurpd_args_file
);
}
MAIN_RETURN
(
rc
);
#endif
/* !NO_THREADS */
}
servers/slurpd/proto-slurp.h
View file @
9a39dcb7
...
...
@@ -21,17 +21,22 @@ int doargs LDAP_P((int argc, char **argv, struct globals *g));
#define ch_malloc malloc
#define ch_realloc realloc
#define ch_calloc calloc
#define ch_strdup strdup
#define ch_free free
#else
void
*
ch_malloc
LDAP_P
((
ber_len_t
size
));
void
*
ch_realloc
LDAP_P
((
void
*
block
,
ber_len_t
size
));
void
*
ch_calloc
LDAP_P
((
ber_len_t
nelem
,
ber_len_t
size
));
char
*
ch_strdup
LDAP_P
((
const
char
*
str
));
void
ch_free
LDAP_P
((
void
*
p
));
#endif
/* config.c */
int
slurpd_read_config
LDAP_P
((
char
*
fname
));
char
*
slurpd_pid_file
;
char
*
slurpd_args_file
;
/* ch_malloc.c */
void
ch_free
LDAP_P
((
void
*
p
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment