2006-07-23 22:43:07 +04:00
/*
Unix SMB / CIFS implementation .
2008-02-21 18:18:01 +03:00
Classic file based shares configuration
2006-07-23 22:43:07 +04:00
Copyright ( C ) Simo Sorce 2006
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
2007-07-10 06:07:03 +04:00
the Free Software Foundation ; either version 3 of the License , or
2006-07-23 22:43:07 +04:00
( 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
2007-07-10 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2006-07-23 22:43:07 +04:00
*/
# include "includes.h"
# include "param/share.h"
2007-09-08 16:42:09 +04:00
# include "param/param.h"
2006-07-23 22:43:07 +04:00
2017-04-20 22:24:43 +03:00
NTSTATUS share_classic_init ( TALLOC_CTX * ) ;
2011-03-19 02:44:36 +03:00
2007-12-04 01:33:22 +03:00
static NTSTATUS sclassic_init ( TALLOC_CTX * mem_ctx ,
const struct share_ops * ops ,
2007-12-14 00:46:55 +03:00
struct loadparm_context * lp_ctx ,
2007-12-04 01:33:22 +03:00
struct share_context * * ctx )
2006-07-23 22:43:07 +04:00
{
* ctx = talloc ( mem_ctx , struct share_context ) ;
if ( ! * ctx ) {
DEBUG ( 0 , ( " ERROR: Out of memory! \n " ) ) ;
return NT_STATUS_NO_MEMORY ;
}
( * ctx ) - > ops = ops ;
2007-12-14 00:46:55 +03:00
( * ctx ) - > priv_data = lp_ctx ;
2006-07-23 22:43:07 +04:00
return NT_STATUS_OK ;
}
2014-01-17 01:16:12 +04:00
static char * sclassic_string_option ( TALLOC_CTX * mem_ctx ,
struct share_config * scfg ,
const char * opt_name ,
const char * defval )
2006-07-23 22:43:07 +04:00
{
2007-09-09 00:03:19 +04:00
struct loadparm_service * s = talloc_get_type ( scfg - > opaque ,
struct loadparm_service ) ;
2010-07-16 08:32:42 +04:00
struct loadparm_context * lp_ctx = talloc_get_type ( scfg - > ctx - > priv_data ,
2007-12-10 06:33:16 +03:00
struct loadparm_context ) ;
2006-07-23 22:43:07 +04:00
char * parm , * val ;
const char * ret ;
if ( strchr ( opt_name , ' : ' ) ) {
parm = talloc_strdup ( scfg , opt_name ) ;
if ( ! parm ) {
return NULL ;
}
val = strchr ( parm , ' : ' ) ;
* val = ' \0 ' ;
val + + ;
2010-07-16 08:32:42 +04:00
ret = lpcfg_parm_string ( lp_ctx , s , parm , val ) ;
2006-07-23 22:43:07 +04:00
if ( ! ret ) {
ret = defval ;
}
talloc_free ( parm ) ;
2014-01-17 01:16:12 +04:00
return talloc_strdup ( mem_ctx , ret ) ;
2006-07-23 22:43:07 +04:00
}
if ( strcmp ( opt_name , SHARE_NAME ) = = 0 ) {
2014-01-17 01:16:12 +04:00
return talloc_strdup ( mem_ctx , scfg - > name ) ;
2006-07-23 22:43:07 +04:00
}
if ( strcmp ( opt_name , SHARE_PATH ) = = 0 ) {
2014-01-17 01:30:37 +04:00
return lpcfg_path ( s , lpcfg_default_service ( lp_ctx ) , mem_ctx ) ;
2006-07-23 22:43:07 +04:00
}
if ( strcmp ( opt_name , SHARE_COMMENT ) = = 0 ) {
2014-01-17 01:30:37 +04:00
return lpcfg_comment ( s , lpcfg_default_service ( lp_ctx ) , mem_ctx ) ;
2006-07-23 22:43:07 +04:00
}
if ( strcmp ( opt_name , SHARE_TYPE ) = = 0 ) {
2014-02-02 17:48:41 +04:00
if ( lpcfg_printable ( s , lpcfg_default_service ( lp_ctx ) ) ) {
2014-01-17 01:16:12 +04:00
return talloc_strdup ( mem_ctx , " PRINTER " ) ;
2006-07-23 22:43:07 +04:00
}
2010-07-16 08:32:42 +04:00
if ( strcmp ( " NTFS " , lpcfg_fstype ( s , lpcfg_default_service ( lp_ctx ) ) ) = = 0 ) {
2014-01-17 01:16:12 +04:00
return talloc_strdup ( mem_ctx , " DISK " ) ;
2006-09-15 20:27:55 +04:00
}
2014-01-17 01:16:12 +04:00
return talloc_strdup ( mem_ctx , lpcfg_fstype ( s , lpcfg_default_service ( lp_ctx ) ) ) ;
2006-07-23 22:43:07 +04:00
}
2007-09-03 08:05:50 +04:00
if ( strcmp ( opt_name , SHARE_PASSWORD ) = = 0 ) {
2014-01-17 01:16:12 +04:00
return talloc_strdup ( mem_ctx , defval ) ;
2007-09-03 08:05:50 +04:00
}
r23696: added the create mask and related share permissions options to Samba4,
using the new share_int_option() code from Simo
speaking of which, this is the first time I've looked closely at the
share_classic.c code. It is absolutely and completely braindead and
broken. Whatever drugs Simo was on at the time, he better not try to
cross a border with them on him!
Problems with it:
- if you actually set a value, it gets ignored, and the defvalue gets
used instead ('ret' is never returned). If you don't set a value,
then defvalue gets returned too. Sound useful?
- it means we now have to list parameters in source/param/ in lots
and lots of places, all of which have to match exactly. code like
this is supposed to reduce the likelyhood of errors, not increase
it!
- code which has a long line of if() statements with strcmp() should
cause your fingers to burn on the keyboard when you type it
in. That's what structure lists are for. Strangely enough, we have
all the info in loadparm.c in a structure list, but instead it gets
replicated in share_classic.c in this strange if() strcmp() form
expect some changes to this code shortly. I'll need a calming cup of
tea first though :-)
(This used to be commit 19a9fc2f444efc0894b06a249daf73ed555b61e2)
2007-07-04 08:15:07 +04:00
DEBUG ( 0 , ( " request for unknown share string option '%s' \n " ,
opt_name ) ) ;
2014-01-17 01:16:12 +04:00
return talloc_strdup ( mem_ctx , defval ) ;
2006-07-23 22:43:07 +04:00
}
2007-09-08 20:46:30 +04:00
static int sclassic_int_option ( struct share_config * scfg , const char * opt_name , int defval )
2006-07-23 22:43:07 +04:00
{
2007-09-09 00:03:19 +04:00
struct loadparm_service * s = talloc_get_type ( scfg - > opaque ,
struct loadparm_service ) ;
2010-07-16 08:32:42 +04:00
struct loadparm_context * lp_ctx = talloc_get_type ( scfg - > ctx - > priv_data ,
2007-12-10 06:33:16 +03:00
struct loadparm_context ) ;
2006-07-23 22:43:07 +04:00
char * parm , * val ;
int ret ;
if ( strchr ( opt_name , ' : ' ) ) {
parm = talloc_strdup ( scfg , opt_name ) ;
if ( ! parm ) {
return - 1 ;
}
val = strchr ( parm , ' : ' ) ;
* val = ' \0 ' ;
val + + ;
2010-07-16 08:32:42 +04:00
ret = lpcfg_parm_int ( lp_ctx , s , parm , val , defval ) ;
2006-07-23 22:43:07 +04:00
if ( ! ret ) {
ret = defval ;
}
talloc_free ( parm ) ;
return ret ;
}
if ( strcmp ( opt_name , SHARE_CSC_POLICY ) = = 0 ) {
2010-07-16 08:32:42 +04:00
return lpcfg_csc_policy ( s , lpcfg_default_service ( lp_ctx ) ) ;
2006-07-23 22:43:07 +04:00
}
if ( strcmp ( opt_name , SHARE_MAX_CONNECTIONS ) = = 0 ) {
2010-07-16 08:32:42 +04:00
return lpcfg_max_connections ( s , lpcfg_default_service ( lp_ctx ) ) ;
r23696: added the create mask and related share permissions options to Samba4,
using the new share_int_option() code from Simo
speaking of which, this is the first time I've looked closely at the
share_classic.c code. It is absolutely and completely braindead and
broken. Whatever drugs Simo was on at the time, he better not try to
cross a border with them on him!
Problems with it:
- if you actually set a value, it gets ignored, and the defvalue gets
used instead ('ret' is never returned). If you don't set a value,
then defvalue gets returned too. Sound useful?
- it means we now have to list parameters in source/param/ in lots
and lots of places, all of which have to match exactly. code like
this is supposed to reduce the likelyhood of errors, not increase
it!
- code which has a long line of if() statements with strcmp() should
cause your fingers to burn on the keyboard when you type it
in. That's what structure lists are for. Strangely enough, we have
all the info in loadparm.c in a structure list, but instead it gets
replicated in share_classic.c in this strange if() strcmp() form
expect some changes to this code shortly. I'll need a calming cup of
tea first though :-)
(This used to be commit 19a9fc2f444efc0894b06a249daf73ed555b61e2)
2007-07-04 08:15:07 +04:00
}
if ( strcmp ( opt_name , SHARE_CREATE_MASK ) = = 0 ) {
2010-07-16 08:32:42 +04:00
return lpcfg_create_mask ( s , lpcfg_default_service ( lp_ctx ) ) ;
r23696: added the create mask and related share permissions options to Samba4,
using the new share_int_option() code from Simo
speaking of which, this is the first time I've looked closely at the
share_classic.c code. It is absolutely and completely braindead and
broken. Whatever drugs Simo was on at the time, he better not try to
cross a border with them on him!
Problems with it:
- if you actually set a value, it gets ignored, and the defvalue gets
used instead ('ret' is never returned). If you don't set a value,
then defvalue gets returned too. Sound useful?
- it means we now have to list parameters in source/param/ in lots
and lots of places, all of which have to match exactly. code like
this is supposed to reduce the likelyhood of errors, not increase
it!
- code which has a long line of if() statements with strcmp() should
cause your fingers to burn on the keyboard when you type it
in. That's what structure lists are for. Strangely enough, we have
all the info in loadparm.c in a structure list, but instead it gets
replicated in share_classic.c in this strange if() strcmp() form
expect some changes to this code shortly. I'll need a calming cup of
tea first though :-)
(This used to be commit 19a9fc2f444efc0894b06a249daf73ed555b61e2)
2007-07-04 08:15:07 +04:00
}
if ( strcmp ( opt_name , SHARE_DIR_MASK ) = = 0 ) {
2014-02-02 17:59:30 +04:00
return lpcfg_directory_mask ( s , lpcfg_default_service ( lp_ctx ) ) ;
2006-07-23 22:43:07 +04:00
}
r23696: added the create mask and related share permissions options to Samba4,
using the new share_int_option() code from Simo
speaking of which, this is the first time I've looked closely at the
share_classic.c code. It is absolutely and completely braindead and
broken. Whatever drugs Simo was on at the time, he better not try to
cross a border with them on him!
Problems with it:
- if you actually set a value, it gets ignored, and the defvalue gets
used instead ('ret' is never returned). If you don't set a value,
then defvalue gets returned too. Sound useful?
- it means we now have to list parameters in source/param/ in lots
and lots of places, all of which have to match exactly. code like
this is supposed to reduce the likelyhood of errors, not increase
it!
- code which has a long line of if() statements with strcmp() should
cause your fingers to burn on the keyboard when you type it
in. That's what structure lists are for. Strangely enough, we have
all the info in loadparm.c in a structure list, but instead it gets
replicated in share_classic.c in this strange if() strcmp() form
expect some changes to this code shortly. I'll need a calming cup of
tea first though :-)
(This used to be commit 19a9fc2f444efc0894b06a249daf73ed555b61e2)
2007-07-04 08:15:07 +04:00
if ( strcmp ( opt_name , SHARE_FORCE_DIR_MODE ) = = 0 ) {
2014-02-03 05:48:28 +04:00
return lpcfg_force_directory_mode ( s , lpcfg_default_service ( lp_ctx ) ) ;
r23696: added the create mask and related share permissions options to Samba4,
using the new share_int_option() code from Simo
speaking of which, this is the first time I've looked closely at the
share_classic.c code. It is absolutely and completely braindead and
broken. Whatever drugs Simo was on at the time, he better not try to
cross a border with them on him!
Problems with it:
- if you actually set a value, it gets ignored, and the defvalue gets
used instead ('ret' is never returned). If you don't set a value,
then defvalue gets returned too. Sound useful?
- it means we now have to list parameters in source/param/ in lots
and lots of places, all of which have to match exactly. code like
this is supposed to reduce the likelyhood of errors, not increase
it!
- code which has a long line of if() statements with strcmp() should
cause your fingers to burn on the keyboard when you type it
in. That's what structure lists are for. Strangely enough, we have
all the info in loadparm.c in a structure list, but instead it gets
replicated in share_classic.c in this strange if() strcmp() form
expect some changes to this code shortly. I'll need a calming cup of
tea first though :-)
(This used to be commit 19a9fc2f444efc0894b06a249daf73ed555b61e2)
2007-07-04 08:15:07 +04:00
}
if ( strcmp ( opt_name , SHARE_FORCE_CREATE_MODE ) = = 0 ) {
2010-07-16 08:32:42 +04:00
return lpcfg_force_create_mode ( s , lpcfg_default_service ( lp_ctx ) ) ;
r23696: added the create mask and related share permissions options to Samba4,
using the new share_int_option() code from Simo
speaking of which, this is the first time I've looked closely at the
share_classic.c code. It is absolutely and completely braindead and
broken. Whatever drugs Simo was on at the time, he better not try to
cross a border with them on him!
Problems with it:
- if you actually set a value, it gets ignored, and the defvalue gets
used instead ('ret' is never returned). If you don't set a value,
then defvalue gets returned too. Sound useful?
- it means we now have to list parameters in source/param/ in lots
and lots of places, all of which have to match exactly. code like
this is supposed to reduce the likelyhood of errors, not increase
it!
- code which has a long line of if() statements with strcmp() should
cause your fingers to burn on the keyboard when you type it
in. That's what structure lists are for. Strangely enough, we have
all the info in loadparm.c in a structure list, but instead it gets
replicated in share_classic.c in this strange if() strcmp() form
expect some changes to this code shortly. I'll need a calming cup of
tea first though :-)
(This used to be commit 19a9fc2f444efc0894b06a249daf73ed555b61e2)
2007-07-04 08:15:07 +04:00
}
DEBUG ( 0 , ( " request for unknown share int option '%s' \n " ,
opt_name ) ) ;
2006-07-23 22:43:07 +04:00
return defval ;
}
2007-09-08 20:46:30 +04:00
static bool sclassic_bool_option ( struct share_config * scfg , const char * opt_name ,
bool defval )
2006-07-23 22:43:07 +04:00
{
2007-09-09 00:03:19 +04:00
struct loadparm_service * s = talloc_get_type ( scfg - > opaque ,
struct loadparm_service ) ;
2010-07-16 08:32:42 +04:00
struct loadparm_context * lp_ctx = talloc_get_type ( scfg - > ctx - > priv_data ,
2007-12-10 06:33:16 +03:00
struct loadparm_context ) ;
2006-07-23 22:43:07 +04:00
char * parm , * val ;
2007-10-07 01:39:52 +04:00
bool ret ;
2006-07-23 22:43:07 +04:00
if ( strchr ( opt_name , ' : ' ) ) {
parm = talloc_strdup ( scfg , opt_name ) ;
if ( ! parm ) {
2007-10-07 01:39:52 +04:00
return false ;
2006-07-23 22:43:07 +04:00
}
val = strchr ( parm , ' : ' ) ;
* val = ' \0 ' ;
val + + ;
2010-07-16 08:32:42 +04:00
ret = lpcfg_parm_bool ( lp_ctx , s , parm , val , defval ) ;
2006-07-23 22:43:07 +04:00
talloc_free ( parm ) ;
return ret ;
}
if ( strcmp ( opt_name , SHARE_AVAILABLE ) = = 0 ) {
2007-09-08 20:46:30 +04:00
return s ! = NULL ;
2006-07-23 22:43:07 +04:00
}
if ( strcmp ( opt_name , SHARE_BROWSEABLE ) = = 0 ) {
2010-07-16 08:32:42 +04:00
return lpcfg_browseable ( s , lpcfg_default_service ( lp_ctx ) ) ;
2006-07-23 22:43:07 +04:00
}
if ( strcmp ( opt_name , SHARE_READONLY ) = = 0 ) {
2014-02-02 17:37:34 +04:00
return lpcfg_read_only ( s , lpcfg_default_service ( lp_ctx ) ) ;
2006-07-23 22:43:07 +04:00
}
if ( strcmp ( opt_name , SHARE_MAP_SYSTEM ) = = 0 ) {
2010-07-16 08:32:42 +04:00
return lpcfg_map_system ( s , lpcfg_default_service ( lp_ctx ) ) ;
2006-07-23 22:43:07 +04:00
}
if ( strcmp ( opt_name , SHARE_MAP_HIDDEN ) = = 0 ) {
2010-07-16 08:32:42 +04:00
return lpcfg_map_hidden ( s , lpcfg_default_service ( lp_ctx ) ) ;
2006-07-23 22:43:07 +04:00
}
if ( strcmp ( opt_name , SHARE_MAP_ARCHIVE ) = = 0 ) {
2010-07-16 08:32:42 +04:00
return lpcfg_map_archive ( s , lpcfg_default_service ( lp_ctx ) ) ;
2006-07-23 22:43:07 +04:00
}
if ( strcmp ( opt_name , SHARE_STRICT_LOCKING ) = = 0 ) {
2010-07-16 08:32:42 +04:00
return lpcfg_strict_locking ( s , lpcfg_default_service ( lp_ctx ) ) ;
2006-07-23 22:43:07 +04:00
}
2008-03-27 12:50:39 +03:00
if ( strcmp ( opt_name , SHARE_OPLOCKS ) = = 0 ) {
2010-07-16 08:32:42 +04:00
return lpcfg_oplocks ( s , lpcfg_default_service ( lp_ctx ) ) ;
2008-03-27 12:50:39 +03:00
}
2006-07-23 22:43:07 +04:00
if ( strcmp ( opt_name , SHARE_STRICT_SYNC ) = = 0 ) {
2010-07-16 08:32:42 +04:00
return lpcfg_strict_sync ( s , lpcfg_default_service ( lp_ctx ) ) ;
2006-07-23 22:43:07 +04:00
}
if ( strcmp ( opt_name , SHARE_MSDFS_ROOT ) = = 0 ) {
2010-07-16 08:32:42 +04:00
return lpcfg_msdfs_root ( s , lpcfg_default_service ( lp_ctx ) ) ;
2006-07-23 22:43:07 +04:00
}
if ( strcmp ( opt_name , SHARE_CI_FILESYSTEM ) = = 0 ) {
2014-02-03 06:01:01 +04:00
int case_sensitive = lpcfg_case_sensitive ( s , lpcfg_default_service ( lp_ctx ) ) ;
2012-07-23 06:24:42 +04:00
/*
* Yes , this confusingly named option means Samba acts
* case sensitive , so that the filesystem can act case
* insensitive .
*
*/
if ( case_sensitive = = Auto ) {
/* Auto is for unix extensions and unix
* clients , which we don ' t support here .
* Samba needs to do the case changing ,
* because the filesystem is case
* sensitive */
return false ;
} else if ( case_sensitive ) {
/* True means that Samba won't do anything to
* change the case of incoming requests .
* Essentially this means we trust the file
* system to be case insensitive */
return true ;
} else {
/* False means that Smaba needs to do the case
* changing , because the filesystem is case
* sensitive */
return false ;
}
2006-07-23 22:43:07 +04:00
}
r23696: added the create mask and related share permissions options to Samba4,
using the new share_int_option() code from Simo
speaking of which, this is the first time I've looked closely at the
share_classic.c code. It is absolutely and completely braindead and
broken. Whatever drugs Simo was on at the time, he better not try to
cross a border with them on him!
Problems with it:
- if you actually set a value, it gets ignored, and the defvalue gets
used instead ('ret' is never returned). If you don't set a value,
then defvalue gets returned too. Sound useful?
- it means we now have to list parameters in source/param/ in lots
and lots of places, all of which have to match exactly. code like
this is supposed to reduce the likelyhood of errors, not increase
it!
- code which has a long line of if() statements with strcmp() should
cause your fingers to burn on the keyboard when you type it
in. That's what structure lists are for. Strangely enough, we have
all the info in loadparm.c in a structure list, but instead it gets
replicated in share_classic.c in this strange if() strcmp() form
expect some changes to this code shortly. I'll need a calming cup of
tea first though :-)
(This used to be commit 19a9fc2f444efc0894b06a249daf73ed555b61e2)
2007-07-04 08:15:07 +04:00
DEBUG ( 0 , ( " request for unknown share bool option '%s' \n " ,
opt_name ) ) ;
2006-07-23 22:43:07 +04:00
return defval ;
}
2007-09-08 20:46:30 +04:00
static const char * * sclassic_string_list_option ( TALLOC_CTX * mem_ctx , struct share_config * scfg , const char * opt_name )
2006-07-23 22:43:07 +04:00
{
2007-09-09 00:03:19 +04:00
struct loadparm_service * s = talloc_get_type ( scfg - > opaque ,
struct loadparm_service ) ;
2010-07-16 08:32:42 +04:00
struct loadparm_context * lp_ctx = talloc_get_type ( scfg - > ctx - > priv_data ,
2007-12-10 06:33:16 +03:00
struct loadparm_context ) ;
2006-07-23 22:43:07 +04:00
char * parm , * val ;
const char * * ret ;
if ( strchr ( opt_name , ' : ' ) ) {
parm = talloc_strdup ( scfg , opt_name ) ;
if ( ! parm ) {
return NULL ;
}
val = strchr ( parm , ' : ' ) ;
* val = ' \0 ' ;
val + + ;
2010-07-16 08:32:42 +04:00
ret = lpcfg_parm_string_list ( mem_ctx , lp_ctx , s , parm , val , " ,; " ) ;
2006-07-23 22:43:07 +04:00
talloc_free ( parm ) ;
return ret ;
}
if ( strcmp ( opt_name , SHARE_HOSTS_ALLOW ) = = 0 ) {
2014-02-02 17:14:09 +04:00
return lpcfg_hosts_allow ( s , lpcfg_default_service ( lp_ctx ) ) ;
2006-07-23 22:43:07 +04:00
}
if ( strcmp ( opt_name , SHARE_HOSTS_DENY ) = = 0 ) {
2014-02-02 17:21:12 +04:00
return lpcfg_hosts_deny ( s , lpcfg_default_service ( lp_ctx ) ) ;
2006-07-23 22:43:07 +04:00
}
if ( strcmp ( opt_name , SHARE_NTVFS_HANDLER ) = = 0 ) {
2010-07-16 08:32:42 +04:00
return lpcfg_ntvfs_handler ( s , lpcfg_default_service ( lp_ctx ) ) ;
2006-07-23 22:43:07 +04:00
}
r23696: added the create mask and related share permissions options to Samba4,
using the new share_int_option() code from Simo
speaking of which, this is the first time I've looked closely at the
share_classic.c code. It is absolutely and completely braindead and
broken. Whatever drugs Simo was on at the time, he better not try to
cross a border with them on him!
Problems with it:
- if you actually set a value, it gets ignored, and the defvalue gets
used instead ('ret' is never returned). If you don't set a value,
then defvalue gets returned too. Sound useful?
- it means we now have to list parameters in source/param/ in lots
and lots of places, all of which have to match exactly. code like
this is supposed to reduce the likelyhood of errors, not increase
it!
- code which has a long line of if() statements with strcmp() should
cause your fingers to burn on the keyboard when you type it
in. That's what structure lists are for. Strangely enough, we have
all the info in loadparm.c in a structure list, but instead it gets
replicated in share_classic.c in this strange if() strcmp() form
expect some changes to this code shortly. I'll need a calming cup of
tea first though :-)
(This used to be commit 19a9fc2f444efc0894b06a249daf73ed555b61e2)
2007-07-04 08:15:07 +04:00
DEBUG ( 0 , ( " request for unknown share list option '%s' \n " ,
opt_name ) ) ;
2006-07-23 22:43:07 +04:00
return NULL ;
}
2007-09-08 20:46:30 +04:00
static NTSTATUS sclassic_list_all ( TALLOC_CTX * mem_ctx ,
struct share_context * ctx ,
int * count ,
const char * * * names )
2006-07-23 22:43:07 +04:00
{
int i ;
int num_services ;
const char * * n ;
2010-07-16 08:32:42 +04:00
num_services = lpcfg_numservices ( ( struct loadparm_context * ) ctx - > priv_data ) ;
2006-07-23 22:43:07 +04:00
n = talloc_array ( mem_ctx , const char * , num_services ) ;
if ( ! n ) {
DEBUG ( 0 , ( " ERROR: Out of memory! \n " ) ) ;
return NT_STATUS_NO_MEMORY ;
}
for ( i = 0 ; i < num_services ; i + + ) {
2010-07-16 08:32:42 +04:00
n [ i ] = talloc_strdup ( n , lpcfg_servicename ( lpcfg_servicebynum ( ( struct loadparm_context * ) ctx - > priv_data , i ) ) ) ;
2006-07-23 22:43:07 +04:00
if ( ! n [ i ] ) {
DEBUG ( 0 , ( " ERROR: Out of memory! \n " ) ) ;
talloc_free ( n ) ;
return NT_STATUS_NO_MEMORY ;
}
}
* names = n ;
* count = num_services ;
return NT_STATUS_OK ;
}
2007-09-08 20:46:30 +04:00
static NTSTATUS sclassic_get_config ( TALLOC_CTX * mem_ctx ,
struct share_context * ctx ,
const char * name ,
struct share_config * * scfg )
2006-07-23 22:43:07 +04:00
{
struct share_config * s ;
2007-09-09 00:03:19 +04:00
struct loadparm_service * service ;
2006-07-23 22:43:07 +04:00
2010-07-16 08:32:42 +04:00
service = lpcfg_service ( ( struct loadparm_context * ) ctx - > priv_data , name ) ;
2006-07-23 22:43:07 +04:00
2007-09-08 20:46:30 +04:00
if ( service = = NULL ) {
2006-07-23 22:43:07 +04:00
return NT_STATUS_OBJECT_NAME_NOT_FOUND ;
}
s = talloc ( mem_ctx , struct share_config ) ;
if ( ! s ) {
DEBUG ( 0 , ( " ERROR: Out of memory! \n " ) ) ;
return NT_STATUS_NO_MEMORY ;
}
2010-07-16 08:32:42 +04:00
s - > name = talloc_strdup ( s , lpcfg_servicename ( service ) ) ;
2006-07-23 22:43:07 +04:00
if ( ! s - > name ) {
DEBUG ( 0 , ( " ERROR: Out of memory! \n " ) ) ;
talloc_free ( s ) ;
return NT_STATUS_NO_MEMORY ;
}
2007-09-08 20:46:30 +04:00
s - > opaque = ( void * ) service ;
2006-07-23 22:43:07 +04:00
s - > ctx = ctx ;
* scfg = s ;
return NT_STATUS_OK ;
}
2007-09-09 00:49:43 +04:00
static const struct share_ops ops = {
. name = " classic " ,
. init = sclassic_init ,
. string_option = sclassic_string_option ,
. int_option = sclassic_int_option ,
. bool_option = sclassic_bool_option ,
. string_list_option = sclassic_string_list_option ,
. list_all = sclassic_list_all ,
. get_config = sclassic_get_config
} ;
2017-04-20 22:24:43 +03:00
NTSTATUS share_classic_init ( TALLOC_CTX * ctx )
2006-07-23 22:43:07 +04:00
{
return share_register ( & ops ) ;
}