/*
* 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
*/
/*
*/
#include <strings.h>
extern int smb_pwd_num(void);
extern int smb_lgrp_numbydomain(smb_domain_type_t, int *);
/*
* Local well-known accounts data structure table and prototypes
*/
typedef struct smb_lwka {
char *lwka_name;
} smb_lwka_t;
};
static smb_lwka_t *smb_lwka_lookup_name(char *);
/*
* Looks up the given name in local account databases:
*
* SMB Local groups are looked up in /var/smb/smbgroup.db
*
* If the account is found, its information is populated
* in the passed smb_account_t structure. Caller must free
* allocated memories by calling smb_account_free() upon
* successful return.
*
* The type of account is specified by 'type', which can be user,
* alias (local group) or unknown. If the caller doesn't know
* whether the name is a user or group name then SidTypeUnknown
* should be passed.
*
* If a local user and group have the same name, the user will
* always be picked. Note that this situation cannot happen on
* Windows systems.
*
* failed and NT_STATUS_NONE_MAPPED is returned.
*
* Return status:
*
* NT_STATUS_NOT_FOUND This is not a local account
* NT_STATUS_NONE_MAPPED It's a local account but cannot be
* translated.
* other error status codes.
*/
{
return (NT_STATUS_NOT_FOUND);
/* Only Netbios hostname is accepted */
return (NT_STATUS_NONE_MAPPED);
} else {
return (NT_STATUS_CANT_ACCESS_DOMAIN_INFO);
}
/* This is the local domain name */
if (!smb_account_validate(account)) {
return (NT_STATUS_NO_MEMORY);
}
return (NT_STATUS_SUCCESS);
}
} else {
switch (type) {
case SidTypeUser:
if (status != NT_STATUS_SUCCESS)
return (status);
break;
case SidTypeAlias:
if (status != NT_STATUS_SUCCESS)
return (status);
break;
case SidTypeUnknown:
type = SidTypeUser;
if (status == NT_STATUS_SUCCESS)
break;
if (status == NT_STATUS_NONE_MAPPED)
return (status);
type = SidTypeAlias;
if (status != NT_STATUS_SUCCESS)
return (status);
break;
default:
return (NT_STATUS_INVALID_PARAMETER);
}
}
if (!smb_account_validate(account)) {
return (NT_STATUS_NO_MEMORY);
}
return (NT_STATUS_SUCCESS);
}
/*
* Looks up the given SID in local account databases:
*
* SMB Local groups are looked up in /var/smb/smbgroup.db
*
* If the account is found, its information is populated
* in the passed smb_account_t structure. Caller must free
* allocated memories by calling smb_account_free() upon
* successful return.
*
* Return status:
*
* NT_STATUS_NOT_FOUND This is not a local account
* NT_STATUS_NONE_MAPPED It's a local account but cannot be
* translated.
* other error status codes.
*/
{
int id_type;
int rc;
return (NT_STATUS_CANT_ACCESS_DOMAIN_INFO);
/* This is the local domain SID */
if (!smb_account_validate(account)) {
return (NT_STATUS_NO_MEMORY);
}
return (NT_STATUS_SUCCESS);
}
/* This is not a local SID */
return (NT_STATUS_NOT_FOUND);
}
} else {
return (NT_STATUS_NONE_MAPPED);
switch (id_type) {
case SMB_IDMAP_USER:
return (NT_STATUS_NO_SUCH_USER);
break;
case SMB_IDMAP_GROUP:
if (rc != SMB_LGRP_SUCCESS)
return (NT_STATUS_NO_SUCH_ALIAS);
smb_lgrp_free(&grp);
break;
default:
return (NT_STATUS_NONE_MAPPED);
}
}
if (!smb_account_validate(account)) {
return (NT_STATUS_NO_MEMORY);
}
return (NT_STATUS_SUCCESS);
}
/*
* Returns number of SMB users, i.e. users who have entry
*/
int
smb_sam_usr_cnt(void)
{
return (smb_pwd_num());
}
/*
* Returns a list of local groups which the given user is
* their member. A pointer to an array of smb_ids_t
* structure is returned which must be freed by caller.
*/
{
gcnt = 0;
return (NT_STATUS_INTERNAL_ERROR);
gcnt++;
}
if (gcnt == 0)
return (NT_STATUS_SUCCESS);
return (NT_STATUS_NO_MEMORY);
return (NT_STATUS_INTERNAL_ERROR);
if (gcnt == 0) {
break;
}
return (NT_STATUS_NO_MEMORY);
}
gcnt--;
ids++;
}
}
return (NT_STATUS_SUCCESS);
}
/*
* Returns the number of built-in or local groups stored
* in /var/smb/smbgroup.db
*/
int
{
int grpcnt;
int rc;
switch (dtype) {
case SMB_DOMAIN_BUILTIN:
break;
case SMB_DOMAIN_LOCAL:
break;
default:
}
}
/*
* Determines whether the given SID is a member of the group
* specified by gname.
*/
{
smb_lgrp_free(&grp);
}
return (ismember);
}
/*
* Frees memories allocated for the passed account fields.
*/
void
{
}
/*
* Validates the given account.
*/
{
}
/*
* if there's a match query its SID from idmap service and make
* sure the SID is a local SID.
*
* The memory for the returned SID must be freed by the caller.
*/
static uint32_t
{
return (NT_STATUS_NO_SUCH_USER);
return (NT_STATUS_ACCOUNT_DISABLED);
!= IDMAP_SUCCESS)
return (NT_STATUS_NONE_MAPPED);
if (!smb_sid_islocal(*sid)) {
smb_sid_free(*sid);
return (NT_STATUS_NONE_MAPPED);
}
return (NT_STATUS_SUCCESS);
}
/*
* Lookup local SMB group account database (/var/smb/smbgroup.db)
* The memory for the returned SID must be freed by the caller.
*/
static uint32_t
{
return (NT_STATUS_NO_SUCH_ALIAS);
smb_lgrp_free(&grp);
}
static smb_lwka_t *
{
int i;
for (i = 0; i < SMB_LWKA_NUM; i++) {
return (&lwka_tbl[i]);
}
return (NULL);
}
static smb_lwka_t *
{
int i;
if (rid > 999)
return (NULL);
for (i = 0; i < SMB_LWKA_NUM; i++) {
return (&lwka_tbl[i]);
}
return (NULL);
}