Doing correct server initialization using `glibtop_set_parameter_l' and
1998-07-14 Martin Baulig <martin@home-of-linux.org> * src/daemon/gnuserv.c: Doing correct server initialization using `glibtop_set_parameter_l' and `glibtop_init_r'. * src/daemon/main.c: Removed call to `glibtop_init_r'. * lib/open.c (glibtop_open_l): We now call the open function of the sysdeps directory (glibtop_open_r) for server method `GLIBTOP_METHOD_DIRECT'. * sysdeps/{linux, sun4, stub}/open.c: No longer `memset' server to zero.
This commit is contained in:
committed by
Martin Baulig
parent
aa04293fc3
commit
ef693a93bc
12
ChangeLog
12
ChangeLog
@@ -1,5 +1,17 @@
|
|||||||
1998-07-14 Martin Baulig <martin@home-of-linux.org>
|
1998-07-14 Martin Baulig <martin@home-of-linux.org>
|
||||||
|
|
||||||
|
* src/daemon/gnuserv.c: Doing correct server initialization
|
||||||
|
using `glibtop_set_parameter_l' and `glibtop_init_r'.
|
||||||
|
|
||||||
|
* src/daemon/main.c: Removed call to `glibtop_init_r'.
|
||||||
|
|
||||||
|
* lib/open.c (glibtop_open_l): We now call the open function
|
||||||
|
of the sysdeps directory (glibtop_open_r) for server method
|
||||||
|
`GLIBTOP_METHOD_DIRECT'.
|
||||||
|
|
||||||
|
* sysdeps/{linux, sun4, stub}/open.c: No longer `memset'
|
||||||
|
server to zero.
|
||||||
|
|
||||||
* src/daemon/slave.c: New file.
|
* src/daemon/slave.c: New file.
|
||||||
|
|
||||||
* src/daemon/*.c: Done some more work on the daemon.
|
* src/daemon/*.c: Done some more work on the daemon.
|
||||||
|
@@ -43,6 +43,12 @@ glibtop_open_l (glibtop *server, const char *program_name,
|
|||||||
server->flags |= _GLIBTOP_INIT_STATE_OPEN;
|
server->flags |= _GLIBTOP_INIT_STATE_OPEN;
|
||||||
|
|
||||||
switch (server->method) {
|
switch (server->method) {
|
||||||
|
case GLIBTOP_METHOD_DIRECT:
|
||||||
|
fprintf (stderr, "Calling sysdeps open function.\n");
|
||||||
|
|
||||||
|
glibtop_open_r (server, program_name, features, flags);
|
||||||
|
|
||||||
|
break;
|
||||||
case GLIBTOP_METHOD_INET:
|
case GLIBTOP_METHOD_INET:
|
||||||
fprintf (stderr, "Connecting to '%s' port %ld.\n",
|
fprintf (stderr, "Connecting to '%s' port %ld.\n",
|
||||||
server->server_host, server->server_port);
|
server->server_host, server->server_port);
|
||||||
|
@@ -35,6 +35,8 @@
|
|||||||
#include <glibtop/command.h>
|
#include <glibtop/command.h>
|
||||||
#include <glibtop/xmalloc.h>
|
#include <glibtop/xmalloc.h>
|
||||||
|
|
||||||
|
#include <glibtop/parameter.h>
|
||||||
|
|
||||||
#include "server_config.h"
|
#include "server_config.h"
|
||||||
|
|
||||||
#include <glibtop/gnuserv.h>
|
#include <glibtop/gnuserv.h>
|
||||||
@@ -483,11 +485,13 @@ handle_signal (int sig)
|
|||||||
int
|
int
|
||||||
main (int argc, char *argv [])
|
main (int argc, char *argv [])
|
||||||
{
|
{
|
||||||
|
glibtop *server = glibtop_global_server;
|
||||||
|
|
||||||
int ils = -1; /* internet domain listen socket */
|
int ils = -1; /* internet domain listen socket */
|
||||||
int uls = -1; /* unix domain listen socket */
|
int uls = -1; /* unix domain listen socket */
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_OPEN_NO_OVERRIDE);
|
glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_INIT_NO_INIT);
|
||||||
|
|
||||||
/* Fork a child.
|
/* Fork a child.
|
||||||
*
|
*
|
||||||
@@ -505,6 +509,8 @@ main (int argc, char *argv [])
|
|||||||
else if (pid == 0) {
|
else if (pid == 0) {
|
||||||
/* We are the child. */
|
/* We are the child. */
|
||||||
|
|
||||||
|
const unsigned method = GLIBTOP_METHOD_DIRECT;
|
||||||
|
|
||||||
/* Temporarily drop our priviledges. */
|
/* Temporarily drop our priviledges. */
|
||||||
|
|
||||||
fprintf (stderr, "Child ID: (%d, %d) - (%d, %d)\n",
|
fprintf (stderr, "Child ID: (%d, %d) - (%d, %d)\n",
|
||||||
@@ -523,9 +529,23 @@ main (int argc, char *argv [])
|
|||||||
/* get a unix domain socket to listen on. */
|
/* get a unix domain socket to listen on. */
|
||||||
uls = unix_init ();
|
uls = unix_init ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
glibtop_set_parameter_l (server, GLIBTOP_PARAM_METHOD,
|
||||||
|
&method, sizeof (method));
|
||||||
|
|
||||||
|
glibtop_set_parameter_l (server, GLIBTOP_PARAM_FEATURES,
|
||||||
|
&glibtop_server_features,
|
||||||
|
sizeof (glibtop_server_features));
|
||||||
|
|
||||||
|
glibtop_init_r (&server, 0, 0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* We are the parent. */
|
/* We are the parent. */
|
||||||
|
|
||||||
|
const unsigned method = GLIBTOP_METHOD_UNIX;
|
||||||
|
|
||||||
|
const unsigned long features = GLIBTOP_SYSDEPS_ALL;
|
||||||
|
|
||||||
/* If we are root, completely switch to SERVER_UID and
|
/* If we are root, completely switch to SERVER_UID and
|
||||||
* SERVER_GID. Otherwise we completely drop any priviledges.
|
* SERVER_GID. Otherwise we completely drop any priviledges.
|
||||||
*/
|
*/
|
||||||
@@ -575,6 +595,15 @@ main (int argc, char *argv [])
|
|||||||
/* get a internet domain socket to listen on. */
|
/* get a internet domain socket to listen on. */
|
||||||
ils = internet_init ();
|
ils = internet_init ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
glibtop_set_parameter_l (server, GLIBTOP_PARAM_METHOD,
|
||||||
|
&method, sizeof (method));
|
||||||
|
|
||||||
|
glibtop_set_parameter_l (server, GLIBTOP_PARAM_FEATURES,
|
||||||
|
&features, sizeof (features));
|
||||||
|
|
||||||
|
glibtop_init_r (&server, 0, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@@ -117,19 +117,9 @@ handle_parent_connection (int s)
|
|||||||
glibtop_response _resp, *resp = &_resp;
|
glibtop_response _resp, *resp = &_resp;
|
||||||
glibtop_command _cmnd, *cmnd = &_cmnd;
|
glibtop_command _cmnd, *cmnd = &_cmnd;
|
||||||
char parameter [BUFSIZ];
|
char parameter [BUFSIZ];
|
||||||
unsigned method;
|
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
method = GLIBTOP_METHOD_UNIX;
|
|
||||||
|
|
||||||
glibtop_set_parameter_l (server, GLIBTOP_PARAM_METHOD,
|
|
||||||
&method, sizeof (method));
|
|
||||||
|
|
||||||
glibtop_set_parameter_l (server, GLIBTOP_PARAM_FEATURES,
|
|
||||||
&glibtop_server_features,
|
|
||||||
sizeof (glibtop_server_features));
|
|
||||||
|
|
||||||
fprintf (stderr, "Parent features = %lu\n", glibtop_server_features);
|
fprintf (stderr, "Parent features = %lu\n", glibtop_server_features);
|
||||||
|
|
||||||
while (do_read (s, &cmnd, sizeof (glibtop_command))) {
|
while (do_read (s, &cmnd, sizeof (glibtop_command))) {
|
||||||
|
@@ -54,7 +54,6 @@ void
|
|||||||
glibtop_open_r (glibtop *server, const char *program_name,
|
glibtop_open_r (glibtop *server, const char *program_name,
|
||||||
const unsigned long features, const unsigned flags)
|
const unsigned long features, const unsigned flags)
|
||||||
{
|
{
|
||||||
memset (server, 0, sizeof (glibtop));
|
|
||||||
server->name = program_name;
|
server->name = program_name;
|
||||||
|
|
||||||
set_linux_version ();
|
set_linux_version ();
|
||||||
|
@@ -27,6 +27,5 @@ void
|
|||||||
glibtop_open_r (glibtop *server, const char *program_name,
|
glibtop_open_r (glibtop *server, const char *program_name,
|
||||||
const unsigned long features, const unsigned flags)
|
const unsigned long features, const unsigned flags)
|
||||||
{
|
{
|
||||||
memset (server, 0, sizeof (glibtop));
|
|
||||||
server->name = program_name;
|
server->name = program_name;
|
||||||
}
|
}
|
||||||
|
@@ -64,7 +64,6 @@ glibtop_open_r (glibtop *server, const char *program_name,
|
|||||||
|
|
||||||
/* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
|
/* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
|
||||||
|
|
||||||
memset (server, 0, sizeof (glibtop));
|
|
||||||
server->name = program_name;
|
server->name = program_name;
|
||||||
|
|
||||||
server->machine.uid = getuid ();
|
server->machine.uid = getuid ();
|
||||||
|
Reference in New Issue
Block a user