Exemplo n.º 1
0
/*
 * smb_update_netlogon_seqnum
 *
 * This function should only be called upon a successful netlogon
 * credential chain establishment to set the sequence number of the
 * netlogon to match with that of the kpasswd.
 */
void
smb_update_netlogon_seqnum(void)
{
	int64_t num;

	(void) mutex_lock(&seqnum_mtx);
	(void) smb_config_getnum(SMB_CI_KPASSWD_SEQNUM, &num);
	(void) smb_config_setnum(SMB_CI_NETLOGON_SEQNUM, num);
	(void) mutex_unlock(&seqnum_mtx);
}
Exemplo n.º 2
0
/*
 * If this namespace hasn't been cached then return
 * without flushing the cache; otherwise clear the
 * name and flush the cache.
 */
static void
dfs_cache_flush(const char *name)
{
	(void) mutex_lock(&dfs_nsmtx);
	if (smb_strcasecmp(name, dfs_cached_ns, 0) != 0) {
		(void) mutex_unlock(&dfs_nsmtx);
		return;
	}
	*dfs_cached_ns = '\0';
	(void) smb_config_setnum(SMB_CI_DFS_STDROOT_NUM, 0);
	(void) mutex_unlock(&dfs_nsmtx);

	smb_cache_flush(&dfs_nscache);
}
Exemplo n.º 3
0
/*
 * smb_set_machine_passwd
 *
 * This function should be used when setting the machine password property.
 * The associated sequence number is incremented.
 */
static int
smb_set_machine_passwd(char *passwd)
{
	int64_t num;
	int rc = -1;

	if (smb_config_set(SMB_CI_MACHINE_PASSWD, passwd) != SMBD_SMF_OK)
		return (-1);

	(void) mutex_lock(&seqnum_mtx);
	(void) smb_config_getnum(SMB_CI_KPASSWD_SEQNUM, &num);
	if (smb_config_setnum(SMB_CI_KPASSWD_SEQNUM, ++num)
	    == SMBD_SMF_OK)
		rc = 0;
	(void) mutex_unlock(&seqnum_mtx);
	return (rc);
}
Exemplo n.º 4
0
/*
 * Caches the specified namespace
 */
static void *
dfs_namespace_cache(void *arg)
{
	char *share = arg;
	char uncpath[DFS_PATH_MAX];
	smb_share_t si;

	if (smb_shr_get(share, &si) != NERR_Success) {
		free(share);
		return (NULL);
	}

	/*
	 * This check should be removed when multiple standalone
	 * namespaces are supported.
	 */
	(void) mutex_lock(&dfs_nsmtx);
	if (*dfs_cached_ns != '\0') {
		syslog(LOG_WARNING, "dfs: trying to load %s namespace."
		    " Only one standalone namespace is supported."
		    " A namespace is already exported for %s",
		    share, dfs_cached_ns);
		(void) mutex_unlock(&dfs_nsmtx);
		free(share);
		return (NULL);
	}
	(void) strlcpy(dfs_cached_ns, share, sizeof (dfs_cached_ns));
	(void) smb_config_setnum(SMB_CI_DFS_STDROOT_NUM, 1);
	(void) mutex_unlock(&dfs_nsmtx);

	(void) snprintf(uncpath, DFS_PATH_MAX, "\\\\%s\\%s", dfs_nbname, share);
	(void) dfs_cache_add_byunc(uncpath, si.shr_path, DFS_OBJECT_ROOT);

	dfs_cache_populate(uncpath, si.shr_path);

	free(share);
	return (NULL);
}
Exemplo n.º 5
0
/*
 * Creates a DFS root with the given name and comment.
 *
 * This function does not create the root share, it
 * should already exist.
 */
uint32_t
dfs_namespace_add(const char *rootshr, const char *cmnt)
{
	dfs_info_t info;
	dfs_target_t t;
	smb_share_t si;
	uuid_t uuid;
	uint32_t status;

	if (*rootshr == '\\') {
		/* Windows has a special case here! */
		return (ERROR_BAD_PATHNAME);
	}

	if (smb_shr_get((char *)rootshr, &si) != NERR_Success)
		return (NERR_NetNameNotFound);

	(void) mutex_lock(&dfs_nsmtx);
	if (smb_strcasecmp(dfs_cached_ns, rootshr, 0) == 0) {
		/* This DFS root is already exported */
		(void) mutex_unlock(&dfs_nsmtx);
		return (ERROR_FILE_EXISTS);
	}

	if (*dfs_cached_ns != '\0') {
		syslog(LOG_WARNING, "dfs: trying to add %s namespace."
		    " Only one standalone namespace is supported."
		    " A namespace is already exported for %s",
		    rootshr, dfs_cached_ns);
		(void) mutex_unlock(&dfs_nsmtx);
		return (ERROR_NOT_SUPPORTED);
	}

	bzero(&info, sizeof (info));
	if (cmnt)
		(void) strlcpy(info.i_comment, cmnt, sizeof (info.i_comment));
	info.i_state = DFS_VOLUME_STATE_OK | DFS_VOLUME_FLAVOR_STANDALONE;
	info.i_timeout = DFS_ROOT_TIMEOUT;
	info.i_propflags = 0;

	uuid_generate_random(uuid);
	uuid_unparse(uuid, info.i_guid);

	dfs_target_init(&t, dfs_nbname, rootshr, DFS_STORAGE_STATE_ONLINE);

	info.i_ntargets = 1;
	info.i_targets = &t;

	if ((status = dfs_root_add(si.shr_path, &info)) != ERROR_SUCCESS) {
		(void) mutex_unlock(&dfs_nsmtx);
		return (status);
	}

	status = srvsvc_shr_setdfsroot(&si, B_TRUE);
	if (status == ERROR_SUCCESS) {
		(void) dfs_cache_add_byname(rootshr, NULL, DFS_OBJECT_ROOT);
		(void) strlcpy(dfs_cached_ns, rootshr, sizeof (dfs_cached_ns));
		(void) smb_config_setnum(SMB_CI_DFS_STDROOT_NUM, 1);
	}
	(void) mutex_unlock(&dfs_nsmtx);

	return (status);
}