| 1 |
/*************************************************************************** |
/* SPDX-License-Identifier: GPL-3.0-or-later */ |
| 2 |
net_server.c - description |
/* |
| 3 |
------------------- |
* net_server |
| 4 |
Copyright : (C) 2004-2025 by Leaflet |
* - network server with SSH support |
| 5 |
Email : leaflet@leafok.com |
* |
| 6 |
***************************************************************************/ |
* Copyright (C) 2004-2025 Leaflet <leaflet@leafok.com> |
| 7 |
|
*/ |
|
/*************************************************************************** |
|
|
* * |
|
|
* This program is free software; you can redistribute it and/or modify * |
|
|
* it under the terms of the GNU General Public License as published by * |
|
|
* the Free Software Foundation; either version 3 of the License, or * |
|
|
* (at your option) any later version. * |
|
|
* * |
|
|
***************************************************************************/ |
|
| 8 |
|
|
| 9 |
#include "bbs.h" |
#include "bbs.h" |
| 10 |
#include "bbs_main.h" |
#include "bbs_main.h" |
| 11 |
|
#include "bwf.h" |
| 12 |
#include "common.h" |
#include "common.h" |
| 13 |
#include "database.h" |
#include "database.h" |
| 14 |
#include "file_loader.h" |
#include "file_loader.h" |
| 40 |
#include <sys/wait.h> |
#include <sys/wait.h> |
| 41 |
#include <systemd/sd-daemon.h> |
#include <systemd/sd-daemon.h> |
| 42 |
|
|
| 43 |
#define WAIT_CHILD_PROCESS_EXIT_TIMEOUT 5 // second |
enum _net_server_constant_t |
| 44 |
#define WAIT_CHILD_PROCESS_KILL_TIMEOUT 1 // second |
{ |
| 45 |
|
WAIT_CHILD_PROCESS_EXIT_TIMEOUT = 5, // second |
| 46 |
|
WAIT_CHILD_PROCESS_KILL_TIMEOUT = 1, // second |
| 47 |
|
|
| 48 |
|
SSH_AUTH_MAX_DURATION = 60 * 1000, // milliseconds |
| 49 |
|
}; |
| 50 |
|
|
| 51 |
struct process_sockaddr_t |
struct process_sockaddr_t |
| 52 |
{ |
{ |
| 57 |
|
|
| 58 |
static PROCESS_SOCKADDR process_sockaddr_pool[MAX_CLIENT_LIMIT]; |
static PROCESS_SOCKADDR process_sockaddr_pool[MAX_CLIENT_LIMIT]; |
| 59 |
|
|
| 60 |
#define SSH_AUTH_MAX_DURATION (60 * 1000) // milliseconds |
static const char SFTP_SERVER_PATH[] = "/usr/lib/sftp-server"; |
|
|
|
|
#define SFTP_SERVER_PATH "/usr/lib/sftp-server" |
|
| 61 |
|
|
| 62 |
/* A userdata struct for session. */ |
/* A userdata struct for session. */ |
| 63 |
struct session_data_struct |
struct session_data_struct |
| 654 |
log_error("Reload conf failed\n"); |
log_error("Reload conf failed\n"); |
| 655 |
} |
} |
| 656 |
|
|
| 657 |
|
// Reload BWF config |
| 658 |
|
if (bwf_load(CONF_BWF) < 0) |
| 659 |
|
{ |
| 660 |
|
log_error("Reload BWF conf failed\n"); |
| 661 |
|
} |
| 662 |
|
|
| 663 |
if (load_menu(&bbs_menu_new, CONF_MENU) < 0) |
if (load_menu(&bbs_menu_new, CONF_MENU) < 0) |
| 664 |
{ |
{ |
| 665 |
unload_menu(&bbs_menu_new); |
unload_menu(&bbs_menu_new); |
| 689 |
{ |
{ |
| 690 |
if (load_file(data_files_load_startup[i]) < 0) |
if (load_file(data_files_load_startup[i]) < 0) |
| 691 |
{ |
{ |
| 692 |
log_error("load_file_mmap(%s) error\n", data_files_load_startup[i]); |
log_error("load_file(%s) error\n", data_files_load_startup[i]); |
| 693 |
} |
} |
| 694 |
} |
} |
| 695 |
log_common("Reload data files successfully\n"); |
log_common("Reload data files successfully\n"); |