1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-02 09:47:23 +03:00

Restructure the connect function code to always call

down to NEXT-> before initializing. This allows us to
do cleanup (by calling DISCONNECT) if initialization
fails. Also fix vfs_acl_xattr which was failing to
call the NEXT connect function.
Jeremy.
This commit is contained in:
Jeremy Allison 2009-11-30 15:53:04 -08:00
parent b852a3494a
commit 8303bc49a4
16 changed files with 117 additions and 37 deletions

View File

@ -367,12 +367,11 @@ static int connect_acl_tdb(struct vfs_handle_struct *handle,
const char *user)
{
struct db_context *db;
int res;
int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
res = SMB_VFS_NEXT_CONNECT(handle, service, user);
if (res < 0) {
return res;
}
if (ret < 0) {
return ret;
}
if (!acl_tdb_init(&db)) {
SMB_VFS_NEXT_DISCONNECT(handle);

View File

@ -212,6 +212,12 @@ static int connect_acl_xattr(struct vfs_handle_struct *handle,
const char *service,
const char *user)
{
int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
if (ret < 0) {
return ret;
}
/* Ensure we have "inherit acls = yes" if we're
* using this module. */
DEBUG(2,("connect_acl_xattr: setting 'inherit acls = true' "

View File

@ -1065,14 +1065,19 @@ static int afsacl_connect(vfs_handle_struct *handle,
const char *service,
const char *user)
{
const char *spc;
const char *spc;
int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
if (ret < 0) {
return ret;
}
spc = lp_parm_const_string(SNUM(handle->conn), "afsacl", "space", "%");
if (spc != NULL)
space_replacement = spc[0];
return SMB_VFS_NEXT_CONNECT(handle, service, user);
return 0;
}
static struct vfs_fn_pointers vfs_afsacl_fns = {

View File

@ -78,15 +78,18 @@ static int audit_syslog_priority(vfs_handle_struct *handle)
static int audit_connect(vfs_handle_struct *handle, const char *svc, const char *user)
{
int result;
result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
if (result < 0) {
return result;
}
openlog("smbd_audit", LOG_PID, audit_syslog_facility(handle));
syslog(audit_syslog_priority(handle), "connect to service %s by user %s\n",
svc, user);
result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
return result;
return 0;
}
static void audit_disconnect(vfs_handle_struct *handle)

View File

@ -89,6 +89,8 @@ static int cprime_connect(
const char * service,
const char * user)
{
int ret;
module_debug = lp_parm_int(SNUM(handle->conn), MODULE, "debug", 100);
if (g_readbuf) {
/* Only allocate g_readbuf once. If the config changes and
@ -98,6 +100,11 @@ static int cprime_connect(
return SMB_VFS_NEXT_CONNECT(handle, service, user);
}
ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
if (ret < 0) {
return ret;
}
g_readsz = conv_str_size(lp_parm_const_string(SNUM(handle->conn),
MODULE, "rsize", NULL));
@ -118,7 +125,7 @@ static int cprime_connect(
g_readsz = 0;
}
return SMB_VFS_NEXT_CONNECT(handle, service, user);
return 0;
}
static ssize_t cprime_sendfile(

View File

@ -162,8 +162,14 @@ static int commit_connect(
const char * service,
const char * user)
{
int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
if (ret < 0) {
return ret;
}
module_debug = lp_parm_int(SNUM(handle->conn), MODULE, "debug", 100);
return SMB_VFS_NEXT_CONNECT(handle, service, user);
return 0;
}
static int commit_open(

View File

@ -80,7 +80,11 @@ static int audit_syslog_priority(vfs_handle_struct *handle)
static int audit_connect(vfs_handle_struct *handle, const char *svc, const char *user)
{
int result;
int result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
if (result < 0) {
return result;
}
openlog("smbd_audit", LOG_PID, audit_syslog_facility(handle));
@ -92,9 +96,7 @@ static int audit_connect(vfs_handle_struct *handle, const char *svc, const char
DEBUG(10, ("Connected to service %s as user %s\n",
svc, user));
result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
return result;
return 0;
}
static void audit_disconnect(vfs_handle_struct *handle)

View File

@ -181,9 +181,15 @@ static int fileid_connect(struct vfs_handle_struct *handle,
{
struct fileid_handle_data *data;
const char *algorithm;
int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
if (ret < 0) {
return ret;
}
data = talloc_zero(handle->conn, struct fileid_handle_data);
if (!data) {
SMB_VFS_NEXT_DISCONNECT(handle);
DEBUG(0, ("talloc_zero() failed\n"));
return -1;
}
@ -203,6 +209,7 @@ static int fileid_connect(struct vfs_handle_struct *handle,
} else if (strcmp("fsid", algorithm) == 0) {
data->device_mapping_fn = fileid_device_mapping_fsid;
} else {
SMB_VFS_NEXT_DISCONNECT(handle);
DEBUG(0,("fileid_connect(): unknown algorithm[%s]\n", algorithm));
return -1;
}
@ -214,7 +221,7 @@ static int fileid_connect(struct vfs_handle_struct *handle,
DEBUG(10, ("fileid_connect(): connect to service[%s] with algorithm[%s]\n",
service, algorithm));
return SMB_VFS_NEXT_CONNECT(handle, service, user);
return 0;
}
static void fileid_disconnect(struct vfs_handle_struct *handle)

View File

@ -606,12 +606,14 @@ static int smb_full_audit_connect(vfs_handle_struct *handle,
const char *none[] = { NULL };
const char *all [] = { "all" };
if (!handle) {
return -1;
result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
if (result < 0) {
return result;
}
pd = SMB_MALLOC_P(struct vfs_full_audit_private_data);
if (!pd) {
SMB_VFS_NEXT_DISCONNECT(handle);
return -1;
}
ZERO_STRUCTP(pd);
@ -631,12 +633,10 @@ static int smb_full_audit_connect(vfs_handle_struct *handle,
SMB_VFS_HANDLE_SET_DATA(handle, pd, free_private_data,
struct vfs_full_audit_private_data, return -1);
result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
do_log(SMB_VFS_OP_CONNECT, True, handle,
"%s", svc);
return result;
return 0;
}
static void smb_full_audit_disconnect(vfs_handle_struct *handle)

View File

@ -28,15 +28,20 @@
static int onefs_connect(struct vfs_handle_struct *handle, const char *service,
const char *user)
{
int ret;
int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
if (ret < 0) {
return ret;
}
ret = onefs_load_config(handle->conn);
if (ret) {
SMB_VFS_NEXT_DISCONNECT(handle);
DEBUG(3, ("Load config failed: %s\n", strerror(errno)));
return ret;
}
return SMB_VFS_NEXT_CONNECT(handle, service, user);
return 0;
}
static int onefs_mkdir(vfs_handle_struct *handle, const char *path,

View File

@ -101,10 +101,16 @@ static int prealloc_connect(
const char * service,
const char * user)
{
module_debug = lp_parm_int(SNUM(handle->conn),
int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
if (ret < 0) {
return ret;
}
module_debug = lp_parm_int(SNUM(handle->conn),
MODULE, "debug", 100);
return SMB_VFS_NEXT_CONNECT(handle, service, user);
return 0;
}
static int prealloc_open(vfs_handle_struct* handle,

View File

@ -127,8 +127,15 @@ static int readahead_connect(struct vfs_handle_struct *handle,
const char *service,
const char *user)
{
struct readahead_data *rhd = SMB_MALLOC_P(struct readahead_data);
struct readahead_data *rhd;
int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
if (ret < 0) {
return ret;
}
rhd = SMB_MALLOC_P(struct readahead_data);
if (!rhd) {
SMB_VFS_NEXT_DISCONNECT(handle);
DEBUG(0,("readahead_connect: out of memory\n"));
return -1;
}
@ -152,7 +159,7 @@ static int readahead_connect(struct vfs_handle_struct *handle,
handle->data = (void *)rhd;
handle->free_data = free_readahead_data;
return SMB_VFS_NEXT_CONNECT(handle, service, user);
return 0;
}
static struct vfs_fn_pointers vfs_readahead_fns = {

View File

@ -62,6 +62,11 @@ static int readonly_connect(vfs_handle_struct *handle,
const char **period = lp_parm_string_list(SNUM(handle->conn),
(handle->param ? handle->param : MODULE_NAME),
"period", period_def);
int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
if (ret < 0) {
return ret;
}
if (period && period[0] && period[1]) {
int i;
@ -85,11 +90,11 @@ static int readonly_connect(vfs_handle_struct *handle,
conn->vuid_cache.next_entry = 0;
}
return SMB_VFS_NEXT_CONNECT(handle, service, user);
return 0;
} else {
return 1;
return 0;
}
}

View File

@ -38,10 +38,16 @@ static int recycle_unlink(vfs_handle_struct *handle,
static int recycle_connect(vfs_handle_struct *handle, const char *service, const char *user)
{
int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
if (ret < 0) {
return ret;
}
DEBUG(10,("recycle_connect() connect to service[%s] as user[%s].\n",
service,user));
return SMB_VFS_NEXT_CONNECT(handle, service, user);
return 0;
}
static void recycle_disconnect(vfs_handle_struct *handle)

View File

@ -277,6 +277,11 @@ static int smb_traffic_analyzer_connect(struct vfs_handle_struct *handle,
uint16_t port = (st == UNIX_DOMAIN_SOCKET) ? 0 :
atoi( lp_parm_const_string(SNUM(conn),
"smb_traffic_analyzer", "port", "9430"));
int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
if (ret < 0) {
return ret;
}
/* Are we already connected ? */
for (rf_sock = sock_list; rf_sock; rf_sock = rf_sock->next) {
@ -294,11 +299,13 @@ static int smb_traffic_analyzer_connect(struct vfs_handle_struct *handle,
/* New connection. */
rf_sock = TALLOC_ZERO_P(NULL, struct refcounted_sock);
if (rf_sock == NULL) {
SMB_VFS_NEXT_DISCONNECT(handle);
errno = ENOMEM;
return -1;
}
rf_sock->name = talloc_strdup(rf_sock, name);
if (rf_sock->name == NULL) {
SMB_VFS_NEXT_DISCONNECT(handle);
TALLOC_FREE(rf_sock);
errno = ENOMEM;
return -1;
@ -316,6 +323,7 @@ static int smb_traffic_analyzer_connect(struct vfs_handle_struct *handle,
port);
}
if (rf_sock->sock == -1) {
SMB_VFS_NEXT_DISCONNECT(handle);
TALLOC_FREE(rf_sock);
return -1;
}
@ -325,7 +333,7 @@ static int smb_traffic_analyzer_connect(struct vfs_handle_struct *handle,
/* Store the private data. */
SMB_VFS_HANDLE_SET_DATA(handle, rf_sock, smb_traffic_analyzer_free_data,
struct refcounted_sock, return -1);
return SMB_VFS_NEXT_CONNECT(handle, service, user);
return 0;
}
/* VFS Functions: write, read, pread, pwrite for now */

View File

@ -87,16 +87,24 @@ static void tsmsm_free_data(void **pptr) {
static int tsmsm_connect(struct vfs_handle_struct *handle,
const char *service,
const char *user) {
struct tsmsm_struct *tsmd = TALLOC_ZERO_P(handle, struct tsmsm_struct);
struct tsmsm_struct *tsmd;
const char *fres;
const char *tsmname;
int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
if (ret < 0) {
return ret;
}
tsmd = TALLOC_ZERO_P(handle, struct tsmsm_struct);
if (!tsmd) {
SMB_VFS_NEXT_DISCONNECT(handle);
DEBUG(0,("tsmsm_connect: out of memory!\n"));
return -1;
}
if (!dmapi_have_session()) {
SMB_VFS_NEXT_DISCONNECT(handle);
DEBUG(0,("tsmsm_connect: no DMAPI session for Samba is available!\n"));
TALLOC_FREE(tsmd);
return -1;
@ -134,7 +142,7 @@ static int tsmsm_connect(struct vfs_handle_struct *handle,
/* Store the private data. */
SMB_VFS_HANDLE_SET_DATA(handle, tsmd, tsmsm_free_data,
struct tsmsm_struct, return -1);
return SMB_VFS_NEXT_CONNECT(handle, service, user);
return 0;
}
static bool tsmsm_is_offline(struct vfs_handle_struct *handle,