dgaudet 99/09/07 15:31:09
Modified: src/os/beos beosd.c beosd.h Log: beos updates from David Reid <[EMAIL PROTECTED]> Submitted by: David Reid <[EMAIL PROTECTED]> Revision Changes Path 1.3 +30 -23 apache-2.0/src/os/beos/beosd.c Index: beosd.c =================================================================== RCS file: /home/cvs/apache-2.0/src/os/beos/beosd.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- beosd.c 1999/07/26 07:03:09 1.2 +++ beosd.c 1999/09/07 22:30:59 1.3 @@ -59,17 +59,23 @@ #include "http_config.h" #include "http_main.h" #include "http_log.h" -#include "unixd.h" +#include "beosd.h" -unixd_config_rec unixd_config; +beosd_config_rec beosd_config; -void unixd_detach(void) +void beosd_detach(void) { - int x; +/* int x; This isn't needed due to the fork() issue */ pid_t pgrp; chdir("/"); +/* ZZZ + * fork() is evil if we're also doing spawn_thread...so we don't use it. + * This means that it won't detach properly, so we'll have to find a way + * round this. + */ +/* if ((x = fork()) > 0) exit(0); else if (x == -1) { @@ -77,6 +83,7 @@ fprintf(stderr, "%s: unable to fork new process\n", ap_server_argv0); exit(1); } +*/ RAISE_SIGSTOP(DETACH); if ((pgrp = setsid()) == -1) { @@ -119,9 +126,9 @@ /* Get username if passed as a uid */ - if (unixd_config.user_name[0] == '#') { + if (beosd_config.user_name[0] == '#') { struct passwd *ent; - uid_t uid = atoi(&unixd_config.user_name[1]); + uid_t uid = atoi(&beosd_config.user_name[1]); if ((ent = getpwuid(uid)) == NULL) { ap_log_error(APLOG_MARK, APLOG_ALERT, NULL, @@ -134,21 +141,21 @@ name = ent->pw_name; } else - name = unixd_config.user_name; + name = beosd_config.user_name; - if (setgid(unixd_config.group_id) == -1) { + if (setgid(beosd_config.group_id) == -1) { ap_log_error(APLOG_MARK, APLOG_ALERT, NULL, "setgid: unable to set group id to Group %u", - (unsigned)unixd_config.group_id); + (unsigned)beosd_config.group_id); return -1; } /* Reset `groups' attributes. */ - if (initgroups(name, unixd_config.group_id) == -1) { + if (initgroups(name, beosd_config.group_id) == -1) { ap_log_error(APLOG_MARK, APLOG_ALERT, NULL, "initgroups: unable to set groups for User %s " - "and Group %u", name, (unsigned)unixd_config.group_id); + "and Group %u", name, (unsigned)beosd_config.group_id); return -1; } } @@ -156,7 +163,7 @@ } -int unixd_setup_child(void) +int beosd_setup_child(void) { if (set_group_privs()) { return -1; @@ -164,7 +171,7 @@ /* Only try to switch if we're running as root */ if (!geteuid() && ( - setuid(unixd_config.user_id) == -1)) { + setuid(beosd_config.user_id) == -1)) { ap_log_error(APLOG_MARK, APLOG_ALERT, NULL, "setuid: unable to change uid"); return -1; @@ -173,17 +180,17 @@ } -const char *unixd_set_user(cmd_parms *cmd, void *dummy, char *arg) +const char *beosd_set_user(cmd_parms *cmd, void *dummy, char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { return err; } - unixd_config.user_name = arg; - unixd_config.user_id = ap_uname2id(arg); + beosd_config.user_name = arg; + beosd_config.user_id = ap_uname2id(arg); #if !defined (BIG_SECURITY_HOLE) && !defined (OS2) - if (unixd_config.user_id == 0) { + if (beosd_config.user_id == 0) { return "Error:\tApache has not been designed to serve pages while\n" "\trunning as root. There are known race conditions that\n" "\twill allow any local user to read any file on the system.\n" @@ -199,21 +206,21 @@ return NULL; } -const char *unixd_set_group(cmd_parms *cmd, void *dummy, char *arg) +const char *beosd_set_group(cmd_parms *cmd, void *dummy, char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { return err; } - unixd_config.group_id = ap_gname2id(arg); + beosd_config.group_id = ap_gname2id(arg); return NULL; } -void unixd_pre_config(void) +void beosd_pre_config(void) { - unixd_config.user_name = DEFAULT_USER; - unixd_config.user_id = ap_uname2id(DEFAULT_USER); - unixd_config.group_id = ap_gname2id(DEFAULT_GROUP); + beosd_config.user_name = DEFAULT_USER; + beosd_config.user_id = ap_uname2id(DEFAULT_USER); + beosd_config.group_id = ap_gname2id(DEFAULT_GROUP); } 1.2 +22 -10 apache-2.0/src/os/beos/beosd.h Index: beosd.h =================================================================== RCS file: /home/cvs/apache-2.0/src/os/beos/beosd.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- beosd.h 1999/07/12 22:51:13 1.1 +++ beosd.h 1999/09/07 22:31:02 1.2 @@ -58,25 +58,37 @@ #ifndef UNIXD_H #define UNIXD_H -/* common stuff that unix MPMs will want */ +/* common stuff that beos MPMs will want */ typedef struct { char *user_name; uid_t user_id; gid_t group_id; -} unixd_config_rec; -extern unixd_config_rec unixd_config; +} beosd_config_rec; +extern beosd_config_rec beosd_config; -void unixd_detach(void); -int unixd_setup_child(void); -void unixd_pre_config(void); -const char *unixd_set_user(cmd_parms *cmd, void *dummy, char *arg); -const char *unixd_set_group(cmd_parms *cmd, void *dummy, char *arg); +void beosd_detach(void); +int beosd_setup_child(void); +void beosd_pre_config(void); +const char *beosd_set_user(cmd_parms *cmd, void *dummy, char *arg); +const char *beosd_set_group(cmd_parms *cmd, void *dummy, char *arg); +#if defined(NSIG) +#define NumSIG NSIG +#elif defined(_NSIG) +#define NumSIG _NSIG +#elif defined(__NSIG) +#define NumSIG __NSIG +#else +#define NumSIG 32 /* for 1998's unixes, this is still a good assumption */ +#endif + +#define INIT_SIGLIST() /* nothing */ + #define UNIX_DAEMON_COMMANDS \ -{ "User", unixd_set_user, NULL, RSRC_CONF, TAKE1, \ +{ "User", beosd_set_user, NULL, RSRC_CONF, TAKE1, \ "Effective user id for this server"}, \ -{ "Group", unixd_set_group, NULL, RSRC_CONF, TAKE1, \ +{ "Group", beosd_set_group, NULL, RSRC_CONF, TAKE1, \ "Effective group id for this server"}, \ #endif