2011-05-03 03:35:07 +04:00
/*
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 )
{
2012-09-04 13:06:15 +04:00
struct task_server * task =
tevent_req_callback_data ( subreq ,
struct task_server ) ;
2011-05-03 03:35:07 +04:00
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 " ) ) ;
}
2012-09-04 13:06:15 +04:00
task_server_terminate ( task , " smbd child process exited " , true ) ;
2011-05-03 03:35:07 +04:00
}
/*
startup a copy of smbd as a child daemon
*/
static void s3fs_task_init ( struct task_server * task )
{
2012-09-04 13:04:16 +04:00
struct tevent_req * subreq ;
2011-05-03 03:35:07 +04:00
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 */
2012-09-04 13:04:16 +04:00
subreq = samba_runcmd_send ( task , task - > event_ctx , timeval_zero ( ) , 1 , 0 ,
2011-05-03 03:35:07 +04:00
smbd_cmd ,
2012-11-01 04:26:16 +04:00
" --option=server role check:inhibit=yes " ,
2012-02-09 07:07:00 +04:00
" --foreground " ,
debug_get_output_is_stdout ( ) ? " --log-stdout " : NULL ,
NULL ) ;
2012-09-04 13:04:16 +04:00
if ( subreq = = NULL ) {
2011-05-03 03:35:07 +04:00
DEBUG ( 0 , ( " Failed to start smbd as child daemon \n " ) ) ;
2012-09-04 11:18:45 +04:00
task_server_terminate ( task , " Failed to startup s3fs smb task " , true ) ;
return ;
2011-05-03 03:35:07 +04:00
}
2012-09-04 13:04:16 +04:00
tevent_req_set_callback ( subreq , file_server_smbd_done , task ) ;
2011-05-03 03:35:07 +04:00
2012-11-01 04:26:16 +04:00
DEBUG ( 5 , ( " Started file server child smbd \n " ) ) ;
2011-05-03 03:35:07 +04:00
}
/* 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 ) ;
}