mirror of
https://github.com/samba-team/samba.git
synced 2025-01-25 06:04:04 +03:00
75c51d6561
This avoids the whole fileserver.conf thing, and simply handles everything in C. The main challenge is that if s3fs is enabled in a member server configuration (unlikely) then these options will not be set, and it overrides any other attempt to set these as globals. (The previous approach essentially just changed defaults, because the include = of smb.conf was after the values were set in fileserver.conf). Andrew Bartlett Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Autobuild-User(master): Michael Adam <obnox@samba.org> Autobuild-Date(master): Thu Nov 1 11:47:22 CET 2012 on sn-devel-104
92 lines
2.5 KiB
C
92 lines
2.5 KiB
C
/*
|
|
Unix SMB/CIFS implementation.
|
|
|
|
run s3 file server within Samba4
|
|
|
|
Copyright (C) Andrew Tridgell 2011
|
|
|
|
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.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "includes.h"
|
|
#include "talloc.h"
|
|
#include "tevent.h"
|
|
#include "system/filesys.h"
|
|
#include "lib/param/param.h"
|
|
#include "source4/smbd/service.h"
|
|
#include "source4/smbd/process_model.h"
|
|
#include "file_server/file_server.h"
|
|
#include "dynconfig.h"
|
|
|
|
/*
|
|
called if smbd exits
|
|
*/
|
|
static void file_server_smbd_done(struct tevent_req *subreq)
|
|
{
|
|
struct task_server *task =
|
|
tevent_req_callback_data(subreq,
|
|
struct task_server);
|
|
int sys_errno;
|
|
int ret;
|
|
|
|
ret = samba_runcmd_recv(subreq, &sys_errno);
|
|
if (ret != 0) {
|
|
DEBUG(0,("file_server smbd daemon died with exit status %d\n", sys_errno));
|
|
} else {
|
|
DEBUG(0,("file_server smbd daemon exited normally\n"));
|
|
}
|
|
task_server_terminate(task, "smbd child process exited", true);
|
|
}
|
|
|
|
|
|
/*
|
|
startup a copy of smbd as a child daemon
|
|
*/
|
|
static void s3fs_task_init(struct task_server *task)
|
|
{
|
|
struct tevent_req *subreq;
|
|
const char *smbd_path;
|
|
const char *smbd_cmd[2] = { NULL, NULL };
|
|
|
|
task_server_set_title(task, "task[s3fs_parent]");
|
|
|
|
smbd_path = talloc_asprintf(task, "%s/smbd", dyn_SBINDIR);
|
|
smbd_cmd[0] = smbd_path;
|
|
|
|
/* start it as a child process */
|
|
subreq = samba_runcmd_send(task, task->event_ctx, timeval_zero(), 1, 0,
|
|
smbd_cmd,
|
|
"--option=server role check:inhibit=yes",
|
|
"--foreground",
|
|
debug_get_output_is_stdout()?"--log-stdout":NULL,
|
|
NULL);
|
|
if (subreq == NULL) {
|
|
DEBUG(0, ("Failed to start smbd as child daemon\n"));
|
|
task_server_terminate(task, "Failed to startup s3fs smb task", true);
|
|
return;
|
|
}
|
|
|
|
tevent_req_set_callback(subreq, file_server_smbd_done, task);
|
|
|
|
DEBUG(5,("Started file server child smbd\n"));
|
|
}
|
|
|
|
/* called at smbd startup - register ourselves as a server service */
|
|
NTSTATUS server_service_s3fs_init(void);
|
|
|
|
NTSTATUS server_service_s3fs_init(void)
|
|
{
|
|
return register_server_service("s3fs", s3fs_task_init);
|
|
}
|