void session_yield(struct smbXsrv_session *session)
{
	struct auth_session_info *session_info =
		session->global->auth_session_info;
	const char *username;
	const char *hostname;
	unsigned int id_num;
	fstring id_str = "";

	id_num = session->global->session_global_id;

	snprintf(id_str, sizeof(id_str), "smb/%u", id_num);

	/* Make clear that we require the optional unix_token in the source3 code */
	SMB_ASSERT(session_info->unix_token);

	username = session_info->unix_info->unix_name;
	hostname = session->global->channels[0].remote_name;

	if (lp_utmp()) {
		sys_utmp_yield(username, hostname, id_str, id_num);
	}

	smb_pam_close_session(username, id_str, hostname);
}
Exemple #2
0
/* called when a session is destroyed */
void session_yield(user_struct *vuser)
{
	TDB_DATA dbuf;
	struct sessionid sessionid;
	struct in_addr *client_ip;
	TDB_DATA key;

	if (!tdb) return;

	if (!vuser->session_keystr) {
		return;
	}

	key.dptr = vuser->session_keystr;
	key.dsize = strlen(vuser->session_keystr)+1;

	dbuf = tdb_fetch(tdb, key);

	if (dbuf.dsize != sizeof(sessionid))
		return;

	memcpy(&sessionid, dbuf.dptr, sizeof(sessionid));

	client_ip = interpret_addr2(sessionid.ip_addr);

	SAFE_FREE(dbuf.dptr);

	if (lp_utmp()) {
		sys_utmp_yield(sessionid.username, sessionid.hostname, 
			       client_ip,
			       sessionid.id_str, sessionid.id_num);
	}

	smb_pam_close_session(sessionid.username, sessionid.id_str, sessionid.hostname);

	tdb_delete(tdb, key);
}