syslog(LOG_DEBUG, "master_startup() started\n");
time(&server_startup_time);
+ get_config();
syslog(LOG_INFO, "Opening databases\n");
open_databases();
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 {
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");
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 */
/* 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
}
if (viewed->room.QRflags & QR_PRIVATE) {
CtdlRoomAccess(&viewed->room, &viewer->user, &ra, NULL);
if ( (ra & UA_KNOWN) == 0) {
- strcpy(real_room, "<private room>");
+ strcpy(real_room, " ");
}
}
}
-/*
- * 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, "<internal program>");
- 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
*/
void begin_session(CitContext *con)
{
- socklen_t len;
- struct sockaddr_in sin;
-
/*
* Initialize some variables specific to our context.
*/
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,
}
+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() );
CtdlRegisterProtoHook(cmd_echo, "ECHO", "echo text back to the client");
CtdlRegisterProtoHook(cmd_more, "MORE", "fetch the paginator prompt");
CtdlRegisterProtoHook(cmd_iden, "IDEN", "identify the client software and location");
- CtdlRegisterProtoHook(cmd_ipgm, "IPGM", "perform privilege escalation for internal programs");
CtdlRegisterProtoHook(cmd_term, "TERM", "terminate another running session");
CtdlRegisterProtoHook(cmd_down, "DOWN", "perform a server shutdown");
CtdlRegisterProtoHook(cmd_halt, "HALT", "halt the server without exiting the server process");