Example #1
0
static int recycle_connect(vfs_handle_struct *handle, const char *service, const char *user)
{
	DEBUG(10,("recycle_connect() connect to service[%s] as user[%s].\n",
		service,user));

	return SMB_VFS_NEXT_CONNECT(handle, service, user);
}
Example #2
0
static int posix_eadb_connect(vfs_handle_struct *handle, const char *service,
			  const char *user)
{
	char *sname = NULL;
	int res, snum;
	struct tdb_wrap *db;

	res = SMB_VFS_NEXT_CONNECT(handle, service, user);
	if (res < 0) {
		return res;
	}

	snum = find_service(talloc_tos(), service, &sname);
	if (snum == -1 || sname == NULL) {
		/*
		 * Should not happen, but we should not fail just *here*.
		 */
		return 0;
	}

	if (!posix_eadb_init(snum, &db)) {
		DEBUG(5, ("Could not init xattr tdb\n"));
		lp_do_parameter(snum, "ea support", "False");
		return 0;
	}

	lp_do_parameter(snum, "ea support", "True");

	SMB_VFS_HANDLE_SET_DATA(handle, db, close_xattr_db,
				struct tdb_wrap, return -1);

	return 0;
}
Example #3
0
static int connect_acl_tdb(struct vfs_handle_struct *handle,
                           const char *service,
                           const char *user)
{
    struct db_context *db;
    int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);

    if (ret < 0) {
        return ret;
    }

    if (!acl_tdb_init(&db)) {
        SMB_VFS_NEXT_DISCONNECT(handle);
        return -1;
    }

    SMB_VFS_HANDLE_SET_DATA(handle, db, free_acl_tdb_data,
                            struct db_context, return -1);

    /* Ensure we have "inherit acls = yes" if we're
     * using this module. */
    DEBUG(2,("connect_acl_tdb: setting 'inherit acls = true' "
             "and 'dos filemode = true' for service %s\n",
             service ));
    lp_do_parameter(SNUM(handle->conn), "inherit acls", "true");
    lp_do_parameter(SNUM(handle->conn), "dos filemode", "true");

    return 0;
}
Example #4
0
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);
	if (!rhd) {
		DEBUG(0,("readahead_connect: out of memory\n"));
		return -1;
	}
	ZERO_STRUCTP(rhd);

	rhd->didmsg = False;
	rhd->off_bound = conv_str_size(lp_parm_const_string(SNUM(handle->conn),
						"readahead",
						"offset",
						NULL));
	if (rhd->off_bound == 0) {
		rhd->off_bound = 0x80000;
	}
	rhd->len = conv_str_size(lp_parm_const_string(SNUM(handle->conn),
						"readahead",
						"length",
						NULL));
	if (rhd->len == 0) {
		rhd->len = rhd->off_bound;
	}

	handle->data = (void *)rhd;
	handle->free_data = free_readahead_data;
	return SMB_VFS_NEXT_CONNECT(handle, service, user);
}
Example #5
0
static int connect_acl_tdb(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;
	}

	if (!acl_tdb_init()) {
		SMB_VFS_NEXT_DISCONNECT(handle);
		return -1;
	}

	/* Ensure we have the parameters correct if we're
	 * using this module. */
	DEBUG(2,("connect_acl_tdb: setting 'inherit acls = true' "
		"'dos filemode = true' and "
		"'force unknown acl user = true' for service %s\n",
		service ));

	lp_do_parameter(SNUM(handle->conn), "inherit acls", "true");
	lp_do_parameter(SNUM(handle->conn), "dos filemode", "true");
	lp_do_parameter(SNUM(handle->conn), "force unknown acl user", "true");

	return 0;
}
Example #6
0
/* 
   called when a client connects to a share
*/
static int tsmsm_connect(struct vfs_handle_struct *handle,
			 const char *service,
			 const char *user) {
	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(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;
	}

	tsmname = (handle->param ? handle->param : "tsmsm");
	
	/* Get 'hsm script' and 'dmapi attribute' parameters to tsmd context */
	tsmd->hsmscript = lp_parm_talloc_string(SNUM(handle->conn), tsmname,
						"hsm script", NULL);
	talloc_steal(tsmd, tsmd->hsmscript);
	
	tsmd->attrib_name = lp_parm_talloc_string(SNUM(handle->conn), tsmname, 
						  "dmapi attribute", DM_ATTRIB_OBJECT);
	talloc_steal(tsmd, tsmd->attrib_name);
	
	tsmd->attrib_value = lp_parm_talloc_string(SNUM(handle->conn), "tsmsm", 
						   "dmapi value", NULL);
	talloc_steal(tsmd, tsmd->attrib_value);
	
	/* retrieve 'online ratio'. In case of error default to FILE_IS_ONLINE_RATIO */
	fres = lp_parm_const_string(SNUM(handle->conn), tsmname, 
				    "online ratio", NULL);
	if (fres == NULL) {
		tsmd->online_ratio = FILE_IS_ONLINE_RATIO;
	} else {
		tsmd->online_ratio = strtof(fres, NULL);
		if (tsmd->online_ratio > 1.0 ||
		    tsmd->online_ratio <= 0.0) {
			DEBUG(1, ("tsmsm_connect: invalid online ration %f - using %f.\n",
				  tsmd->online_ratio, (float)FILE_IS_ONLINE_RATIO));
		}
	}

        /* Store the private data. */
        SMB_VFS_HANDLE_SET_DATA(handle, tsmd, tsmsm_free_data,
                                struct tsmsm_struct, return -1);
        return 0;
}
Example #7
0
static int syncops_connect(struct vfs_handle_struct *handle, const char *service,
			   const char *user)
{

	struct syncops_config_data *config;
	int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
	if (ret < 0) {
		return ret;
	}

	config = talloc_zero(handle->conn, struct syncops_config_data);
	if (!config) {
		SMB_VFS_NEXT_DISCONNECT(handle);
		DEBUG(0, ("talloc_zero() failed\n"));
		return -1;
	}

	config->onclose = lp_parm_bool(SNUM(handle->conn), "syncops",
					"onclose", true);

	config->onmeta = lp_parm_bool(SNUM(handle->conn), "syncops",
					"onmeta", true);

	config->disable = lp_parm_bool(SNUM(handle->conn), "syncops",
					"disable", false);

	SMB_VFS_HANDLE_SET_DATA(handle, config,
				NULL, struct syncops_config_data,
				return -1);

	return 0;

}
Example #8
0
static int connect_acl_tdb(struct vfs_handle_struct *handle,
				const char *service,
				const char *user)
{
	int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
	bool ok;
	struct acl_common_config *config = NULL;

	if (ret < 0) {
		return ret;
	}

	if (!acl_tdb_init()) {
		SMB_VFS_NEXT_DISCONNECT(handle);
		return -1;
	}

	ok = init_acl_common_config(handle);
	if (!ok) {
		DBG_ERR("init_acl_common_config failed\n");
		return -1;
	}

	/* Ensure we have the parameters correct if we're
	 * using this module. */
	DEBUG(2,("connect_acl_tdb: setting 'inherit acls = true' "
		"'dos filemode = true' and "
		"'force unknown acl user = true' for service %s\n",
		service ));

	lp_do_parameter(SNUM(handle->conn), "inherit acls", "true");
	lp_do_parameter(SNUM(handle->conn), "dos filemode", "true");
	lp_do_parameter(SNUM(handle->conn), "force unknown acl user", "true");

	SMB_VFS_HANDLE_GET_DATA(handle, config,
				struct acl_common_config,
				return -1);

	if (config->ignore_system_acls) {
		DBG_NOTICE("setting 'create mask = 0666', "
			   "'directory mask = 0777', "
			   "'store dos attributes = yes' and all "
			   "'map ...' options to 'no'\n");

		lp_do_parameter(SNUM(handle->conn), "create mask", "0666");
		lp_do_parameter(SNUM(handle->conn), "directory mask", "0777");
		lp_do_parameter(SNUM(handle->conn), "map archive", "no");
		lp_do_parameter(SNUM(handle->conn), "map hidden", "no");
		lp_do_parameter(SNUM(handle->conn), "map readonly", "no");
		lp_do_parameter(SNUM(handle->conn), "map system", "no");
		lp_do_parameter(SNUM(handle->conn), "store dos attributes",
				"yes");
	}

	return 0;
}
Example #9
0
static int prealloc_connect(
                struct vfs_handle_struct *  handle,
                const char *                service,
                const char *                user)
{
	    module_debug = lp_parm_int(SNUM(handle->conn),
					MODULE, "msglevel", 100);

	    return SMB_VFS_NEXT_CONNECT(handle, service, user);
}
Example #10
0
static int vfs_vxfs_connect(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;
	}
	return 0;
}
Example #11
0
static int vfsx_connect(vfs_handle_struct *handle, const char *svc, const char *user)
{
	int result = -1;
	int count;
	char buf[VFSX_MSG_OUT_SIZE];

	count = snprintf(buf, VFSX_MSG_OUT_SIZE, "connect:%s:%s", handle->conn->user, handle->conn->origpath);
	if (vfsx_execute(buf, count) == VFSX_SUCCESS_TRANSPARENT) {
		result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
	}
	return result;
}
static int greyhole_connect(vfs_handle_struct *handle, const char *svc, const char *user)
{
	int result;

	if (!handle) {
		return -1;
	}

	result = SMB_VFS_NEXT_CONNECT(handle, svc, user);

	return result;
}
Example #13
0
static int audit_connect(vfs_handle_struct *handle, const char *svc, const char *user)
{
	int 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;
}
Example #14
0
static int onefs_connect(struct vfs_handle_struct *handle, const char *service,
			 const char *user)
{
	int ret;

	ret = onefs_load_config(handle->conn);
	if (ret) {
		DEBUG(3, ("Load config failed: %s\n", strerror(errno)));
		return ret;
	}

	return SMB_VFS_NEXT_CONNECT(handle, service, user);
}
Example #15
0
static int afsacl_connect(vfs_handle_struct *handle, 
			  const char *service, 
			  const char *user)
{
	const char *spc;

	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);
}
static int greyhole_connect(vfs_handle_struct *handle, const char *svc, const char *user)
{
	int result;

	if (!handle) {
		return -1;
	}

	openlog("smbd_greyhole", 0, greyhole_syslog_facility(handle));

	result = SMB_VFS_NEXT_CONNECT(handle, svc, user);

	return result;
}
Example #17
0
static int cprime_connect(
                struct vfs_handle_struct *  handle,
                const char *                service,
                const char *                user)
{
        module_debug = lp_parm_int(SNUM(handle->conn), MODULE, "debug", 100);
        if (g_readbuf) {
                /* Only allocate g_readbuf once. If the config changes and
                 * another client multiplexes onto this smbd, we don't want
                 * to risk memory corruption.
                 */
                return SMB_VFS_NEXT_CONNECT(handle, service, user);
        }

        g_readsz = conv_str_size(lp_parm_const_string(SNUM(handle->conn),
                                        MODULE, "rsize", NULL));

        if (g_readsz < READAHEAD_MIN) {
                DEBUG(module_debug, ("%s: %ld bytes of readahead "
                            "requested, using minimum of %u\n",
                            MODULE, (long)g_readsz, READAHEAD_MIN));
                g_readsz = READAHEAD_MIN;
        } else if (g_readsz > READAHEAD_MAX) {
                DEBUG(module_debug, ("%s: %ld bytes of readahead "
                            "requested, using maximum of %u\n",
                            MODULE, (long)g_readsz, READAHEAD_MAX));
                g_readsz = READAHEAD_MAX;
        }

        if ((g_readbuf = SMB_MALLOC(g_readsz)) == NULL) {
                /* Turn off readahead if we can't get a buffer. */
                g_readsz = 0;
        }

        return SMB_VFS_NEXT_CONNECT(handle, service, user);
}
Example #18
0
static int prealloc_connect(
                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;
	}

	module_debug = lp_parm_int(SNUM(handle->conn),
					MODULE, "debug", 100);

	return 0;
}
Example #19
0
static int aio_posix_connect(vfs_handle_struct *handle, const char *service,
			     const char *user)
{
	if (aio_signal_event == NULL) {
		struct tevent_context *ev = handle->conn->sconn->ev_ctx;

		aio_signal_event = tevent_add_signal(
			ev, ev, RT_SIGNAL_AIO, SA_SIGINFO,
			aio_posix_signal_handler, NULL);

		if (aio_signal_event == NULL) {
			DEBUG(1, ("tevent_add_signal failed\n"));
			return -1;
		}
	}
	return SMB_VFS_NEXT_CONNECT(handle, service, user);
}
Example #20
0
static int crossrename_connect(
                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;
	}

	module_sizelimit = (off_t) lp_parm_int(SNUM(handle->conn),
					MODULE, "sizelimit", 20);
	/* convert from MiB to byte: */
	module_sizelimit *= 1048576;

	return 0;
}
Example #21
0
static int readonly_connect(vfs_handle_struct *handle, 
			    const char *service, 
			    const char *user)    
{
  const char *period_def[] = {"today 0:0:0", "tomorrow 0:0:0"};

  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;
    time_t current_time = time(NULL);
    time_t begin_period = get_date(period[0], &current_time);
    time_t end_period   = get_date(period[1], &current_time);

    if ((current_time >= begin_period) && (current_time <= end_period)) {
      connection_struct *conn = handle->conn;

      handle->conn->read_only = True;

      /* Wipe out the VUID cache. */
      for (i=0; i< VUID_CACHE_SIZE; i++) {
        struct vuid_cache_entry *ent = ent = &conn->vuid_cache.array[i];
        ent->vuid = UID_FIELD_INVALID;
        TALLOC_FREE(ent->session_info);
        ent->read_only = false;
      }
      conn->vuid_cache.next_entry = 0;
    }

    return 0;

  } else {
    
    return 0;
    
  }
}
Example #22
0
static int streams_xattr_connect(vfs_handle_struct *handle,
				 const char *service, const char *user)
{
	struct streams_xattr_config *config;
	const char *default_prefix = SAMBA_XATTR_DOSSTREAM_PREFIX;
	const char *prefix;
	int rc;

	rc = SMB_VFS_NEXT_CONNECT(handle, service, user);
	if (rc != 0) {
		return rc;
	}

	config = talloc_zero(handle->conn, struct streams_xattr_config);
	if (config == NULL) {
		DEBUG(1, ("talloc_zero() failed\n"));
		errno = ENOMEM;
		return -1;
	}

	prefix = lp_parm_const_string(SNUM(handle->conn),
				      "streams_xattr", "prefix",
				      default_prefix);
	config->prefix = talloc_strdup(config, prefix);
	if (config->prefix == NULL) {
		DEBUG(1, ("talloc_strdup() failed\n"));
		errno = ENOMEM;
		return -1;
	}
	config->prefix_len = strlen(config->prefix);
	DEBUG(10, ("streams_xattr using stream prefix: %s\n", config->prefix));

	config->store_stream_type = lp_parm_bool(SNUM(handle->conn),
						 "streams_xattr",
						 "store_stream_type",
						 true);

	SMB_VFS_HANDLE_SET_DATA(handle, config,
				NULL, struct stream_xattr_config,
				return -1);

	return 0;
}
Example #23
0
static int audit_connect(vfs_handle_struct *handle, const char *svc, const char *user)
{
	int result = SMB_VFS_NEXT_CONNECT(handle, svc, user);

	if (result < 0) {
		return result;
	}

	openlog("smbd_audit", LOG_PID, audit_syslog_facility(handle));

	if (lp_syslog() > 0) {
		syslog(audit_syslog_priority(handle),
		       "connect to service %s by user %s\n",
		       svc, user);
	}
	DEBUG(10, ("Connected to service %s as user %s\n",
	       svc, user));

	return 0;
}
Example #24
0
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' "
             "and 'dos filemode = true' for service %s\n",
             service ));

    lp_do_parameter(SNUM(handle->conn), "inherit acls", "true");
    lp_do_parameter(SNUM(handle->conn), "dos filemode", "true");

    return 0;
}
Example #25
0
static int connect_acl_tdb(struct vfs_handle_struct *handle,
				const char *service,
				const char *user)
{
	struct db_context *db;
	int res;

        res = SMB_VFS_NEXT_CONNECT(handle, service, user);
        if (res < 0) {
                return res;
        }

	if (!acl_tdb_init(&db)) {
		SMB_VFS_NEXT_DISCONNECT(handle);
		return -1;
	}

	SMB_VFS_HANDLE_SET_DATA(handle, db, free_acl_tdb_data,
				struct db_context, return -1);

	return 0;
}
Example #26
0
static int skel_connect(vfs_handle_struct *handle, const char *service,
			const char *user)
{
	return SMB_VFS_NEXT_CONNECT(handle, service, user);
}
Example #27
0
static int nfs4acl_connect(struct vfs_handle_struct *handle,
			   const char *service,
			   const char *user)
{
	struct nfs4acl_config *config = NULL;
	const struct enum_list *default_acl_style_list = NULL;
	const char *default_xattr_name = NULL;
	int enumval;
	unsigned nfs_version;
	int ret;

	default_acl_style_list = get_default_acl_style_list();

	config = talloc_zero(handle->conn, struct nfs4acl_config);
	if (config == NULL) {
		DBG_ERR("talloc_zero() failed\n");
		return -1;
	}

	ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
	if (ret < 0) {
		TALLOC_FREE(config);
		return ret;
	}

	ret = smbacl4_get_vfs_params(handle->conn, &config->nfs4_params);
	if (ret < 0) {
		TALLOC_FREE(config);
		return ret;
	}

	enumval = lp_parm_enum(SNUM(handle->conn),
			       "nfs4acl_xattr",
			       "encoding",
			       nfs4acl_encoding,
			       NFS4ACL_ENCODING_NDR);
	if (enumval == -1) {
		DBG_ERR("Invalid \"nfs4acl_xattr:encoding\" parameter\n");
		return -1;
	}
	config->encoding = (enum nfs4acl_encoding)enumval;

	switch (config->encoding) {
	case NFS4ACL_ENCODING_XDR:
		default_xattr_name = NFS4ACL_XDR_XATTR_NAME;
		break;
	case NFS4ACL_ENCODING_NDR:
	default:
		default_xattr_name = NFS4ACL_NDR_XATTR_NAME;
		break;
	}

	nfs_version = (unsigned)lp_parm_int(SNUM(handle->conn),
					    "nfs4acl_xattr",
					    "version",
					    41);
	switch (nfs_version) {
	case 40:
		config->nfs_version = ACL4_XATTR_VERSION_40;
		break;
	case 41:
		config->nfs_version = ACL4_XATTR_VERSION_41;
		break;
	default:
		config->nfs_version = ACL4_XATTR_VERSION_DEFAULT;
		break;
	}

	config->default_acl_style = lp_parm_enum(SNUM(handle->conn),
						 "nfs4acl_xattr",
						 "default acl style",
						 default_acl_style_list,
						 DEFAULT_ACL_EVERYONE);

	config->xattr_name = lp_parm_talloc_string(config,
						   SNUM(handle->conn),
						   "nfs4acl_xattr",
						   "xattr_name",
						   default_xattr_name);

	SMB_VFS_HANDLE_SET_DATA(handle, config, NULL, struct nfs4acl_config,
				return -1);

	/*
	 * Ensure we have the parameters correct if we're using this module.
	 */
	DBG_NOTICE("Setting 'inherit acls = true', "
		   "'dos filemode = true', "
		   "'force unknown acl user = true', "
		   "'create mask = 0666', "
		   "'directory mask = 0777' and "
		   "'store dos attributes = yes' "
		   "for service [%s]\n", service);

	lp_do_parameter(SNUM(handle->conn), "inherit acls", "true");
	lp_do_parameter(SNUM(handle->conn), "dos filemode", "true");
	lp_do_parameter(SNUM(handle->conn), "force unknown acl user", "true");
	lp_do_parameter(SNUM(handle->conn), "create mask", "0666");
	lp_do_parameter(SNUM(handle->conn), "directory mask", "0777");
	lp_do_parameter(SNUM(handle->conn), "store dos attributes", "yes");

	return 0;
}