/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdlib.h>
#include <string.h>
#include <synch.h>
static char *wka_nbdomain[] = {
"",
"NT Pseudo Domain",
"NT Authority",
"Builtin",
"Internet$"
};
/*
* Predefined well known accounts table
*/
{ 0, "S-1-0-0", "Null",
{ 0, "S-1-1-0", "Everyone",
{ 0, "S-1-2-0", "Local",
{ 0, "S-1-3-0", "Creator Owner",
{ 0, "S-1-3-1", "Creator Group",
{ 0, "S-1-3-2", "Creator Owner Server",
{ 0, "S-1-3-3", "Creator Group Server",
{ 0, "S-1-3-4", "Owner Rights",
{ 0, "S-1-3-5", "Group Rights",
{ 1, "S-1-5", "NT Pseudo Domain",
{ 2, "S-1-5-1", "Dialup",
{ 2, "S-1-5-2", "Network",
{ 2, "S-1-5-3", "Batch",
{ 2, "S-1-5-4", "Interactive",
{ 2, "S-1-5-6", "Service",
{ 2, "S-1-5-7", "Anonymous",
{ 2, "S-1-5-8", "Proxy",
{ 2, "S-1-5-9", "Enterprise Domain Controllers",
{ 2, "S-1-5-10", "Self",
{ 2, "S-1-5-11", "Authenticated Users",
{ 2, "S-1-5-12", "Restricted",
{ 2, "S-1-5-13", "Terminal Server User",
{ 2, "S-1-5-14", "Remote Interactive Logon",
{ 2, "S-1-5-15", "This Organization",
{ 2, "S-1-5-18", "System",
{ 2, "S-1-5-19", "Local Service",
{ 2, "S-1-5-20", "Network Service",
{ 2, "S-1-5-33", "Write Restricted",
{ 2, "S-1-5-1000", "Other Organization",
{ 3, "S-1-5-32", "Builtin",
{ 4, "S-1-7", "Internet$",
{ 3, "S-1-5-32-545", "Users",
{ 3, "S-1-5-32-546", "Guests",
{ 3, "S-1-5-32-548", "Account Operators",
{ 3, "S-1-5-32-549", "Server Operators",
{ 3, "S-1-5-32-550", "Print Operators",
"Members can bypass file security to back up files", NULL },
{ 3, "S-1-5-32-552", "Replicator",
{ 3, "S-1-5-32-766", "Current Owner",
{ 3, "S-1-5-32-767", "Current Group",
};
static int smb_wka_init(void);
static void smb_wka_fini(void);
/*
* Looks up well known accounts table for the given SID.
* Upon success returns a pointer to the account entry in
* the table, otherwise returns NULL.
*/
{
int i;
if (!smb_wka_init())
return (NULL);
for (i = 0; i < SMB_WKA_NUM; ++i) {
return (NULL);
return (entry);
}
return (NULL);
}
/*
* Looks up well known accounts table for the given name.
* Upon success returns a pointer to the binary SID of the
* entry, otherwise returns NULL.
*/
{
if (!smb_wka_init())
return (NULL);
return (sid);
}
/*
* Looks up well known accounts table for the given name.
* Upon success returns a pointer to the account entry in
* the table, otherwise returns NULL.
*/
{
int i;
for (i = 0; i < SMB_WKA_NUM; ++i) {
return (entry);
}
return (NULL);
}
/*
* Lookup a name in the BUILTIN domain.
*/
{
int i;
for (i = 0; i < SMB_WKA_NUM; ++i) {
continue;
return (entry);
}
return (NULL);
}
/*
* Returns the Netbios domain name for the given index
*/
char *
{
return (wka_nbdomain[idx]);
return (NULL);
}
/*
* This function adds well known groups to groups in a user's
* access token (gids).
*
* "Network" SID is added for all users connecting over CIFS.
*
* "Authenticated Users" SID is added for all users except Guest
* and Anonymous.
*
* "Guests" SID is added for guest users and Administrators SID
* is added for admin users.
*/
{
int total_cnt;
return (NT_STATUS_NO_MEMORY);
return (NT_STATUS_NO_MEMORY);
id++;
if ((flags & SMB_ATF_ANON) == 0) {
if (flags & SMB_ATF_GUEST)
else
return (NT_STATUS_NO_MEMORY);
id++;
}
if (flags & SMB_ATF_ADMIN) {
return (NT_STATUS_NO_MEMORY);
}
return (NT_STATUS_SUCCESS);
}
/*
* Generate binary SIDs from the string SIDs for the well-known
* accounts table. Callers MUST not free the binary SID pointer.
*/
static int
smb_wka_init(void)
{
int i;
(void) mutex_lock(&wka_mutex);
if (wka_init) {
(void) mutex_unlock(&wka_mutex);
return (B_TRUE);
}
for (i = 0; i < SMB_WKA_NUM; ++i) {
smb_wka_fini();
(void) mutex_unlock(&wka_mutex);
return (B_FALSE);
}
}
(void) mutex_unlock(&wka_mutex);
return (B_TRUE);
}
/*
* Private cleanup for smb_wka_init.
*/
static void
smb_wka_fini(void)
{
int i;
for (i = 0; i < SMB_WKA_NUM; ++i) {
if (wka_tbl[i].wka_binsid) {
}
}
}