X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fcitserver.c;h=088b584e1107a751cc5b935f4e08c8c858ea5f58;hb=dba8d7a9fb79dd7a776478781736c2425b19bd17;hp=2b70a2667d7249f4a9c85963f50edd4c0951daa0;hpb=2b402dc292b6dcdbc7a3786a6c722e06e3be5ab5;p=citadel.git diff --git a/citadel/citserver.c b/citadel/citserver.c index 2b70a2667..088b584e1 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -169,6 +169,7 @@ void master_startup(void) { syslog(LOG_DEBUG, "master_startup() started\n"); time(&server_startup_time); + get_config(); syslog(LOG_INFO, "Opening databases\n"); open_databases(); @@ -196,6 +197,9 @@ void master_startup(void) { urandom = fopen("/dev/urandom", "r"); if (urandom != NULL) { rv = fread(&seed, sizeof seed, 1, urandom); + if (rv == -1) + syslog(LOG_EMERG, "failed to read random seed: %s\n", + strerror(errno)); fclose(urandom); } else { @@ -205,9 +209,6 @@ void master_startup(void) { srand(seed); srandom(seed); - syslog(LOG_INFO, "Initializing ipgm secret\n"); - get_config(); - config.c_ipgm_secret = rand(); put_config(); syslog(LOG_DEBUG, "master_startup() finished\n"); @@ -221,7 +222,7 @@ void master_cleanup(int exitcode) { struct CleanupFunctionHook *fcn; static int already_cleaning_up = 0; - if (already_cleaning_up) while(1) sleep(1); + if (already_cleaning_up) while(1) usleep(1000); already_cleaning_up = 1; /* Run any cleanup routines registered by loadable modules */ @@ -343,9 +344,9 @@ void cmd_time(char *argbuf) /* timezone and daylight global variables are not portable. */ #ifdef HAVE_STRUCT_TM_TM_GMTOFF - cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, tmp.tm_gmtoff, tmp.tm_isdst); + cprintf("%d %ld|%ld|%d|%ld\n", CIT_OK, (long)tv, tmp.tm_gmtoff, tmp.tm_isdst, server_startup_time); #else - cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, timezone, tmp.tm_isdst); + cprintf("%d %ld|%ld|%d|%ld\n", CIT_OK, (long)tv, timezone, tmp.tm_isdst, server_startup_time); #endif } @@ -440,7 +441,7 @@ int is_public_client(void) for (i=0; ics_addr, addrbuf)) { - syslog(LOG_DEBUG, "... yes it is.\n"); + syslog(LOG_DEBUG, "... yes its local.\n"); return(1); } } @@ -652,7 +653,7 @@ void GenerateRoomDisplay(char *real_room, if (viewed->room.QRflags & QR_PRIVATE) { CtdlRoomAccess(&viewed->room, &viewer->user, &ra, NULL); if ( (ra & UA_KNOWN) == 0) { - strcpy(real_room, ""); + strcpy(real_room, " "); } } @@ -756,36 +757,6 @@ void cmd_echo(char *etext) } -/* - * Perform privilege escalation for an internal program - */ -void cmd_ipgm(char *argbuf) -{ - int secret; - - secret = extract_int(argbuf, 0); - - /* For security reasons, we do NOT allow this command to run - * over the network. Local sockets only. - */ - if (!CC->is_local_socket) { - sleep(5); - cprintf("%d Authentication failed.\n", ERROR + PASSWORD_REQUIRED); - } - else if (secret == config.c_ipgm_secret) { - CC->internal_pgm = 1; - strcpy(CC->curr_user, ""); - CC->cs_flags = CC->cs_flags|CS_STEALTH; - cprintf("%d Authenticated as an internal program.\n", CIT_OK); - } - else { - sleep(5); - cprintf("%d Authentication failed.\n", ERROR + PASSWORD_REQUIRED); - syslog(LOG_ERR, "Warning: ipgm authentication failed.\n"); - CC->kill_me = KILLME_AUTHFAILED; - } -} - /* * Shut down the server @@ -887,9 +858,6 @@ void cmd_asyn(char *argbuf) */ void begin_session(CitContext *con) { - socklen_t len; - struct sockaddr_in sin; - /* * Initialize some variables specific to our context. */ @@ -914,7 +882,6 @@ void begin_session(CitContext *con) safestrncpy(con->cs_addr, "", sizeof con->cs_addr); con->cs_UDSclientUID = -1; con->cs_host[sizeof con->cs_host - 1] = 0; - len = sizeof sin; if (!CC->is_local_socket) { locate_host(con->cs_host, sizeof con->cs_host, con->cs_addr, sizeof con->cs_addr, @@ -994,6 +961,12 @@ void citproto_begin_session() { } +void citproto_begin_admin_session() { + CC->internal_pgm = 1; + cprintf("%d %s Citadel server ADMIN CONNECTION ready.\n", CIT_OK, config.c_nodename); +} + + void cmd_noop(char *argbuf) { cprintf("%d%cok\n", CIT_OK, CtdlCheckExpress() ); @@ -1037,10 +1010,14 @@ void do_command_loop(void) { /* Log the server command, but don't show passwords... */ if ( (strncasecmp(cmdbuf, "PASS", 4)) && (strncasecmp(cmdbuf, "SETP", 4)) ) { - syslog(LOG_INFO, "CtdlCommand [%s] [%s] %s\n", CTDLUSERIP, CC->curr_user, cmdbuf); + syslog(LOG_INFO, "[%d][%s(%ld)] %s", + CC->cs_pid, CC->curr_user, CC->user.usernum, cmdbuf + ); } else { - syslog(LOG_INFO, "CtdlCommand [%s] [%s]