static bool reload_services_file(const char *lfile) { bool ret; if (lp_loaded()) { char *fname = lp_configfile(talloc_tos()); if (file_exist(fname) && !strcsequal(fname,get_dyn_CONFIGFILE())) { set_dyn_CONFIGFILE(fname); } TALLOC_FREE(fname); } /* if this is a child, restore the logfile to the special name - <domain>, idmap, etc. */ if (lfile && *lfile) { lp_set_logfile(lfile); } reopen_logs(); ret = lp_load_global(get_dyn_CONFIGFILE()); reopen_logs(); load_interfaces(); return(ret); }
static bool reload_nmbd_services(bool test) { bool ret; set_remote_machine_name("nmbd", False); if ( lp_loaded() ) { const char *fname = lp_configfile(); if (file_exist(fname) && !strcsequal(fname,get_dyn_CONFIGFILE())) { set_dyn_CONFIGFILE(fname); test = False; } } if ( test && !lp_file_list_changed() ) return(True); ret = lp_load_global(get_dyn_CONFIGFILE()); /* perhaps the config filename is now set */ if ( !test ) { DEBUG( 3, ( "services not loaded\n" ) ); reload_nmbd_services( True ); } return(ret); }
/* ************************************************************************** ** * Print a Debug Header. * * Input: level - Debug level of the message (not the system-wide debug * level. * file - Pointer to a string containing the name of the file * from which this function was called, or an empty string * if the __FILE__ macro is not implemented. * func - Pointer to a string containing the name of the function * from which this function was called, or an empty string * if the __FUNCTION__ macro is not implemented. * line - line number of the call to dbghdr, assuming __LINE__ * works. * * Output: Always True. This makes it easy to fudge a call to dbghdr() * in a macro, since the function can be called as part of a test. * Eg: ( (level <= DEBUGLEVEL) && (dbghdr(level,"",line)) ) * * Notes: This function takes care of setting syslog_level. * * ************************************************************************** ** */ BOOL dbghdr (int level, const char *file, const char *func, int line) { if (format_pos) { /* This is a fudge. If there is stuff sitting in the format_bufr, then * the *right* thing to do is to call * format_debug_text( "\n" ); * to write the remainder, and then proceed with the new header. * Unfortunately, there are several places in the code at which * the DEBUG() macro is used to build partial lines. That in mind, * we'll work under the assumption that an incomplete line indicates * that a new header is *not* desired. */ return (True); } /* Don't print a header if we're logging to stdout. */ if (stdout_logging) return (True); /* Print the header if timestamps are turned on. If parameters are * not yet loaded, then default to timestamps on. */ if (lp_timestamp_logs () || !(lp_loaded ())) { /* Print it all out at once to prevent split syslog output. */ (void) Debug1 ("[%s, %d] %s:%s(%d)\n", timestring (), level, file, func, line); } return (True); } /* dbghdr */
static BOOL reload_nmbd_services(BOOL test) { BOOL ret; set_remote_machine_name("nmbd", False); if ( lp_loaded() ) { pstring fname; pstrcpy( fname,lp_configfile()); if (file_exist(fname,NULL) && !strcsequal(fname,dyn_CONFIGFILE)) { pstrcpy(dyn_CONFIGFILE,fname); test = False; } } if ( test && !lp_file_list_changed() ) return(True); ret = lp_load( dyn_CONFIGFILE, True , False, False, True); /* perhaps the config filename is now set */ if ( !test ) { DEBUG( 3, ( "services not loaded\n" ) ); reload_nmbd_services( True ); } return(ret); }
bool reload_services(struct smbd_server_connection *sconn, bool (*snumused) (struct smbd_server_connection *, int), bool test) { struct smbXsrv_connection *xconn = NULL; bool ret; if (sconn != NULL) { xconn = sconn->conn; } if (lp_loaded()) { char *fname = lp_next_configfile(talloc_tos()); if (file_exist(fname) && !strcsequal(fname, get_dyn_CONFIGFILE())) { set_dyn_CONFIGFILE(fname); test = False; } TALLOC_FREE(fname); } reopen_logs(); if (test && !lp_file_list_changed()) return(True); lp_killunused(sconn, snumused); ret = lp_load(get_dyn_CONFIGFILE(), false, /* global only */ false, /* save defaults */ true, /* add_ipc */ true); /* initialize globals */ /* perhaps the config filename is now set */ if (!test) { reload_services(sconn, snumused, true); } reopen_logs(); load_interfaces(); if (xconn != NULL) { set_socket_options(xconn->transport.sock, "SO_KEEPALIVE"); set_socket_options(xconn->transport.sock, lp_socket_options()); } mangle_reset_cache(); reset_stat_cache(); /* this forces service parameters to be flushed */ set_current_service(NULL,0,True); return(ret); }
BOOL dbghdr( int level, const char *file, const char *func, int line ) { /* Ensure we don't lose any real errno value. */ int old_errno = errno; if( format_pos ) { /* This is a fudge. If there is stuff sitting in the format_bufr, then * the *right* thing to do is to call * format_debug_text( "\n" ); * to write the remainder, and then proceed with the new header. * Unfortunately, there are several places in the code at which * the DEBUG() macro is used to build partial lines. That in mind, * we'll work under the assumption that an incomplete line indicates * that a new header is *not* desired. */ return( True ); } #ifdef WITH_SYSLOG /* Set syslog_level. */ syslog_level = level; #endif /* Don't print a header if we're logging to stdout. */ if( stdout_logging ) return( True ); /* Print the header if timestamps are turned on. If parameters are * not yet loaded, then default to timestamps on. */ if( lp_timestamp_logs() || !(lp_loaded()) ) { char header_str[200]; header_str[0] = '\0'; if( lp_debug_pid()) slprintf(header_str,sizeof(header_str)-1,", pid=%u",(unsigned int)sys_getpid()); if( lp_debug_uid()) { size_t hs_len = strlen(header_str); slprintf(header_str + hs_len, sizeof(header_str) - 1 - hs_len, ", effective(%u, %u), real(%u, %u)", (unsigned int)geteuid(), (unsigned int)getegid(), (unsigned int)getuid(), (unsigned int)getgid()); } /* Print it all out at once to prevent split syslog output. */ (void)Debug1( "[%s, %d%s] %s:%s(%d)\n", timestring(lp_debug_hires_timestamp()), level, header_str, file, func, line ); } errno = old_errno; return( True ); }
BOOL reopen_logs( void ) { pstring fname; mode_t oldumask; XFILE *new_dbf = NULL; XFILE *old_dbf = NULL; BOOL ret = True; if (stdout_logging) return True; oldumask = umask( 022 ); pstrcpy(fname, debugf ); if (lp_loaded()) { char *logfname; logfname = lp_logfile(); if (*logfname) pstrcpy(fname, logfname); } pstrcpy( debugf, fname ); new_dbf = x_fopen( debugf, O_WRONLY|O_APPEND|O_CREAT, 0644); if (!new_dbf) { log_overflow = True; DEBUG(0, ("Unable to open new log file %s: %s\n", debugf, strerror(errno))); log_overflow = False; if (dbf) x_fflush(dbf); ret = False; } else { x_setbuf(new_dbf, NULL); old_dbf = dbf; dbf = new_dbf; if (old_dbf) (void) x_fclose(old_dbf); } /* Fix from [email protected] * to fix problem where smbd's that generate less * than 100 messages keep growing the log. */ force_check_log_size(); (void)umask(oldumask); /* Take over stderr to catch ouput into logs */ if (dbf && sys_dup2(x_fileno(dbf), 2) == -1) { close_low_fds(True); /* Close stderr too, if dup2 can't point it at the logfile */ } return ret; }
BOOL reopen_logs( void ) { pstring fname; mode_t oldumask; FILE *new_dbf = NULL; BOOL ret = True; if (stdout_logging) return True; oldumask = umask( 022 ); pstrcpy(fname, debugf ); if (lp_loaded()) { char *logfname; logfname = lp_logfile(); if (*logfname) pstrcpy(fname, logfname); } pstrcpy(debugf, fname); if (append_log) new_dbf = sys_fopen( debugf, "a" ); else new_dbf = sys_fopen( debugf, "w" ); if (!new_dbf) { log_overflow = True; DEBUG(0, ("Unable to open new log file %s: %s\n", debugf, strerror(errno))); log_overflow = False; if (dbf) fflush(dbf); ret = False; } else { setbuf(new_dbf, NULL); if (dbf) (void) fclose(dbf); dbf = new_dbf; } /* Fix from [email protected] * to fix problem where smbd's that generate less * than 100 messages keep growing the log. */ force_check_log_size(); (void)umask(oldumask); return ret; }
BOOL reload_services(BOOL test) { BOOL ret; if (lp_loaded()) { pstring fname; pstrcpy(fname,lp_configfile()); if (file_exist(fname, NULL) && !strcsequal(fname, dyn_CONFIGFILE)) { pstrcpy(dyn_CONFIGFILE, fname); test = False; } } reopen_logs(); if (test && !lp_file_list_changed()) return(True); lp_killunused(conn_snum_used); ret = lp_load(dyn_CONFIGFILE, False, False, True); load_printers(); /* perhaps the config filename is now set */ if (!test) reload_services(True); reopen_logs(); load_interfaces(); { if (smbd_server_fd() != -1) { set_socket_options(smbd_server_fd(),"SO_KEEPALIVE"); set_socket_options(smbd_server_fd(), user_socket_options); } } mangle_reset_cache(); reset_stat_cache(); /* this forces service parameters to be flushed */ set_current_service(NULL,True); return (ret); }
bool reload_services(struct messaging_context *msg_ctx, int smb_sock, bool test) { bool ret; if (lp_loaded()) { char *fname = lp_configfile(); if (file_exist(fname) && !strcsequal(fname, get_dyn_CONFIGFILE())) { set_dyn_CONFIGFILE(fname); test = False; } TALLOC_FREE(fname); } reopen_logs(); if (test && !lp_file_list_changed()) return(True); lp_killunused(conn_snum_used); ret = lp_load(get_dyn_CONFIGFILE(), False, False, True, True); /* perhaps the config filename is now set */ if (!test) reload_services(msg_ctx, smb_sock, True); reopen_logs(); load_interfaces(); if (smb_sock != -1) { set_socket_options(smb_sock,"SO_KEEPALIVE"); set_socket_options(smb_sock, lp_socket_options()); } mangle_reset_cache(); reset_stat_cache(); /* this forces service parameters to be flushed */ set_current_service(NULL,0,True); return(ret); }
static BOOL reload_services_file(void) { BOOL ret; if (lp_loaded()) { pstring fname; pstrcpy(fname,lp_configfile()); if (file_exist(fname,NULL) && !strcsequal(fname,dyn_CONFIGFILE)) { pstrcpy(dyn_CONFIGFILE,fname); } } reopen_logs(); ret = lp_load(dyn_CONFIGFILE,False,False,True); reopen_logs(); load_interfaces(); return(ret); }
/* ************************************************************************** ** * reopen the log files * ************************************************************************** ** */ void reopen_logs( void ) { pstring fname; if( DEBUGLEVEL > 0 ) { pstrcpy( fname, debugf ); if( lp_loaded() && (*lp_logfile()) ) pstrcpy( fname, lp_logfile() ); if( !strcsequal( fname, debugf ) || !dbf || !file_exist( debugf, NULL ) ) { mode_t oldumask = umask( 022 ); pstrcpy( debugf, fname ); if( dbf ) (void)fclose( dbf ); if( append_log ) dbf = sys_fopen( debugf, "a" ); else dbf = sys_fopen( debugf, "w" ); /* Fix from [email protected] * to fix problem where smbd's that generate less * than 100 messages keep growing the log. */ force_check_log_size(); if( dbf ) setbuf( dbf, NULL ); (void)umask( oldumask ); } } else { if( dbf ) { (void)fclose( dbf ); dbf = NULL; } } } /* reopen_logs */
/**************************************************************************** ** reload the services file **************************************************************************** */ BOOL reload_services_nmbd(BOOL test) { BOOL ret; extern fstring remote_machine; fstrcpy( remote_machine, "nmb" ); if ( lp_loaded() ) { pstring fname; pstrcpy( fname,lp_configfile()); if (file_exist(fname,NULL) && !strcsequal(fname,servicesf_nmbd)) { pstrcpy(servicesf_nmbd,fname); test = False; } } if ( test && !lp_file_list_changed() ) return(True); ret = lp_load( servicesf_nmbd, True , False, False); /* perhaps the config filename is now set */ if ( !test ) { DEBUG( 3, ( "services not loaded\n" ) ); reload_services_nmbd( True ); } /* Do a sanity check for a misconfigured nmbd */ if( lp_wins_support() && *lp_wins_server() ) { DEBUG(0,("ERROR: both 'wins support = true' and 'wins server = <server>' \ cannot be set in the smb.conf file. nmbd aborting.\n")); exit(10); }
/* ************************************************************************** ** * Format the debug message text. * * Input: msg - Text to be added to the "current" debug message text. * * Output: none. * * Notes: The purpose of this is two-fold. First, each call to syslog() * (used by Debug1(), see above) generates a new line of syslog * output. This is fixed by storing the partial lines until the * newline character is encountered. Second, printing the debug * message lines when a newline is encountered allows us to add * spaces, thus indenting the body of the message and making it * more readable. * * ************************************************************************** ** */ static void format_debug_text (char *msg) { size_t i; BOOL timestamp = (!stdout_logging && (lp_timestamp_logs () || !(lp_loaded ()))); for (i = 0; msg[i]; i++) { /* Indent two spaces at each new line. */ if (timestamp && 0 == format_pos) { format_bufr[0] = format_bufr[1] = ' '; format_pos = 2; } /* If there's room, copy the character to the format buffer. */ if (format_pos < FORMAT_BUFR_MAX) format_bufr[format_pos++] = msg[i]; /* If a newline is encountered, print & restart. */ if ('\n' == msg[i]) bufr_print (); /* If the buffer is full dump it out, reset it, and put out a line * continuation indicator. */ if (format_pos >= FORMAT_BUFR_MAX) { bufr_print (); (void) Debug1 (" +>\n"); } } /* Just to be safe... */ format_bufr[format_pos] = '\0'; } /* format_debug_text */