terminal_t *null_new (ini_sct_t *ini) { null_t *nt; nt = malloc (sizeof (null_t)); if (nt == NULL) { return (NULL); } null_init (nt, ini); return (&nt->trm); }
int config_init(char *style, int readit) { int rv; if (strcmp(style, "emulab") == 0) { #ifdef USE_EMULAB_CONFIG extern struct config *emulab_init(); if (myconfig == NULL) { if ((myconfig = emulab_init()) != NULL) log("Using Emulab configuration"); } else log("Emulab config init failed"); #else log("Not built with Emulab configuration"); #endif } if (strcmp(style, "null") == 0) { #ifdef USE_NULL_CONFIG extern struct config *null_init(); if (myconfig == NULL) { if ((myconfig = null_init()) != NULL) log("Using null configuration"); } else log("Null config init failed"); #else log("Not built with Null configuration"); #endif } if (myconfig == NULL) { error("*** No configuration found"); return -1; } if (readit) { rv = myconfig->config_read(); if (rv) { myconfig->config_deinit(); return rv; } } signal(SIGHUP, config_signal); return 0; }
int main(int argc, char *argv[]) { #ifdef ARCH_PC_WIN95 int ret; #endif #ifndef ARCH_PC_WIN95 struct group *grp; struct passwd *pwd; #endif Alarm_set_types( CONF_SYS ); Alarm_set_priority( SPLOG_INFO ); Alarmp( SPLOG_PRINT, SYSTEM, "/===========================================================================\\\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| The Spread Toolkit. |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| Copyright (c) 1993-2013 Spread Concepts LLC |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| All rights reserved. |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| The Spread toolkit is licensed under the Spread Open-Source License. |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| You may only use this software in compliance with the License. |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| A copy of the license can be found at http://www.spread.org/license |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| This product uses software developed by Spread Concepts LLC for use |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| in the Spread toolkit. For more information about Spread, |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| see http://www.spread.org |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| This software is distributed on an \"AS IS\" basis, WITHOUT WARRANTY OF |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| ANY KIND, either express or implied. |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| Creators: |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| Yair Amir [email protected] |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| Michal Miskin-Amir [email protected] |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| Jonathan Stanton [email protected] |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| John Schultz [email protected] |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| Major Contributors: |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| Ryan Caudy [email protected] - contribution to process groups.|\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| Claudiu Danilov [email protected] - scalable, wide-area support. |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| Cristina Nita-Rotaru [email protected] - GC security. |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| Theo Schlossnagle [email protected] - Perl, autoconf, old skiplist. |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| Dan Schoenblum [email protected] - Java interface. |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| Special thanks to the following for discussions and ideas: |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| Ken Birman, Danny Dolev, Jacob Green, Mike Goodrich, Ben Laurie, |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| David Shaw, Gene Tsudik, Robbert VanRenesse. |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| Partial funding provided by the Defense Advanced Research Project Agency |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| (DARPA) and the National Security Agency (NSA) 2000-2004. The Spread |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| toolkit is not necessarily endorsed by DARPA or the NSA. |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| For a full list of contributors, see Readme.txt in the distribution. |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| WWW: www.spread.org www.spreadconcepts.com |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| Contact: [email protected] |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| |\n"); Alarmp( SPLOG_PRINT, SYSTEM, "| Version %d.%02d.%02d Built %-17s |\n", (int)SP_MAJOR_VERSION, (int)SP_MINOR_VERSION, (int)SP_PATCH_VERSION, Spread_build_date ); Alarmp( SPLOG_PRINT, SYSTEM, "\\===========================================================================/\n"); Usage( argc, argv ); #ifdef ARCH_PC_WIN95 ret = WSAStartup( MAKEWORD(1,1), &WSAData ); if( ret != 0 ) Alarmp( SPLOG_FATAL, NETWORK, "Spread: winsock initialization error %d\n", ret ); #endif /* ARCH_PC_WIN95 */ /* initialize each valid authentication protocol */ null_init(); ip_init(); #ifdef ENABLE_PASSWORD pword_init(); #endif permit_init(); /* Initialize Access Control & Authentication */ Acm_init(); Conf_init( Config_file, My_name ); E_init(); #ifndef ARCH_PC_WIN95 /* Verify that unix socket dir is safe if runing as root user */ if (geteuid() == (uid_t) 0) { struct stat usock_stat; Alarmp( SPLOG_INFO, SECURITY, "Spread is running as root so check file locations\n"); if (stat( SP_UNIX_SOCKET, &usock_stat)) { Alarmp( SPLOG_FATAL, SECURITY, "Spread unable to stat the unix domain socket dir (%s). Please verify the selected directory and restart the daemon\n", SP_UNIX_SOCKET ); exit( 0 ); } if ( (usock_stat.st_mode & S_IWOTH) || !(usock_stat.st_uid == (uid_t) 0) ) Alarmp( SPLOG_WARNING, PRINT, "Spread: SECURITY RISK! running as root, but unix domain socket is not in a root-only writable directory. May risk denial of service or malicious deletion of unexpected file in directory: %s\n", SP_UNIX_SOCKET ); } #endif Sess_init(); Stat_init(); if( Log ) Log_init(); #ifndef ARCH_PC_WIN95 /* Yupp, we're paranoid */ if (geteuid() != (uid_t) 0) { Alarmp( SPLOG_WARNING, SECURITY, "Spread: not running as root, won't chroot\n" ); } else if ( (grp = getgrnam(Conf_get_group())) == NULL || (pwd = getpwnam(Conf_get_user())) == NULL ) { Invalid_privilege_decrease(Conf_get_user(), Conf_get_group()); } else if (chdir(Conf_get_runtime_dir()) < 0 || chroot(Conf_get_runtime_dir()) < 0 ) { Alarmp( SPLOG_FATAL, SECURITY, "Spread: FAILED chroot to '%s'\n", Conf_get_runtime_dir() ); } else if ( setgroups(1, &grp->gr_gid) < 0 || setgid(grp->gr_gid) < 0 || setuid(pwd->pw_uid) < 0) { Invalid_privilege_decrease(Conf_get_user(), Conf_get_group()); } else { Alarmp( SPLOG_INFO, SECURITY, "Spread: setugid and chroot successeful\n" ); } #endif /* ARCH_PC_WIN95 */ E_handle_events(); return 0; }
INT null(INT cmd, ...) { va_list argptr; HNDLE hkey; INT status, size, timeout; void *info; char *str, *pattern; va_start(argptr, cmd); status = FE_SUCCESS; switch (cmd) { case CMD_INIT: hkey = va_arg(argptr, HNDLE); info = va_arg(argptr, void *); status = null_init(hkey, info); break; case CMD_EXIT: info = va_arg(argptr, void *); status = null_exit(info); break; case CMD_NAME: info = va_arg(argptr, void *); str = va_arg(argptr, char *); strcpy(str, "null"); break; case CMD_WRITE: info = va_arg(argptr, void *); str = va_arg(argptr, char *); size = va_arg(argptr, int); status = null_write(info, str, size); break; case CMD_READ: info = va_arg(argptr, void *); str = va_arg(argptr, char *); size = va_arg(argptr, INT); timeout = va_arg(argptr, INT); status = null_read(info, str, size, timeout); break; case CMD_PUTS: info = va_arg(argptr, void *); str = va_arg(argptr, char *); status = null_puts(info, str); break; case CMD_GETS: info = va_arg(argptr, void *); str = va_arg(argptr, char *); size = va_arg(argptr, INT); pattern = va_arg(argptr, char *); timeout = va_arg(argptr, INT); status = null_gets(info, str, size, pattern, timeout); break; case CMD_DEBUG: status = va_arg(argptr, INT); debug_flag = status; break; } va_end(argptr); return status; }