Пример #1
0
void standard_sub_conn(connection_struct *conn, char *str, size_t len)
{
	char *s;
	
	s = alloc_sub_advanced(SNUM(conn), conn->user, conn->connectpath,
			conn->gid, smb_user_name, str);

	if ( s ) {
		strncpy( str, s, len );
		SAFE_FREE( s );
	}
}
Пример #2
0
char *talloc_sub_advanced(TALLOC_CTX *mem_ctx,
			int snum,
			const char *user,
			const char *connectpath,
			gid_t gid,
			const char *smb_name,
			const char *str)
{
	char *a, *t;
       	a = alloc_sub_advanced(snum, user, connectpath, gid, smb_name, str);
	if (!a) return NULL;
	t = talloc_strdup(mem_ctx, a);
	SAFE_FREE(a);
	return t;
}
Пример #3
0
void standard_sub_snum(int snum, char *str, size_t len)
{
	static uid_t cached_uid = -1;
	static fstring cached_user;
	char *s;
	
	/* calling uidtoname() on every substitute would be too expensive, so
	   we cache the result here as nearly every call is for the same uid */

	if (cached_uid != current_user.ut.uid) {
		fstrcpy(cached_user, uidtoname(current_user.ut.uid));
		cached_uid = current_user.ut.uid;
	}

	s = alloc_sub_advanced(snum, cached_user, "", current_user.ut.gid,
			      smb_user_name, str);

	if ( s ) {
		strncpy( str, s, len );
		SAFE_FREE( s );
	}
}
Пример #4
0
char *alloc_sub_conn(connection_struct *conn, const char *str)
{
	return alloc_sub_advanced(SNUM(conn), conn->user, conn->connectpath,
			conn->gid, smb_user_name, str);
}