/*
* 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 <pwd.h>
#include <idmap.h>
#include <ctype.h>
#include "ad_common.h"
/* passwd attributes and filters */
static const char *pwd_attrs[] = {
(char *)NULL
};
static int
{
int buflen;
char *buffer;
/*
* The canonical name obtained from AD lookup may not match
* the case of the name (i.e. key) in the request. Therefore,
* use the name from the request to construct the result.
*/
} else {
}
return (-1);
} else {
return (-1);
}
else
return (0);
}
/*
* 1) If the homeDirectory string is in UNC format then convert it into
* a /net format. This needs to be revisited later but is fine for now
* because Solaris does not support -hosts automount map for CIFS yet.
*
* 2) If homeDirectory contains ':' then return NULL because ':' is the
* delimiter in passwd entries and may break apps that parse these entries.
*
* 3) For all other cases return the same string that was passed to
* this function.
*/
static
char *
{
char *smb_homedir;
int i, slash = 0;
/*
* Ignore paths that have colon ':' because ':' is a
* delimiter for the passwd entry.
*/
return (NULL);
/* Keep homedir intact if not in UNC format */
return (homedir);
/*
* Convert UNC string into /net format
*/
return (NULL);
if (*homedir == '\\') {
/* Reduce double backslashes into one */
if (slash)
slash = 0;
else {
slash = 1;
smb_homedir[i++] = '/';
}
} else {
smb_homedir[i++] = *homedir;
slash = 0;
}
}
return (smb_homedir);
}
/*
* _nss_ad_passwd2str is the data marshaling method for the passwd getXbyY
* (e.g., getbyuid(), getbyname(), getpwent()) backend processes. This method is
* called after a successful AD search has been performed. This method will
* parse the AD search values into the file format.
* e.g.
*
* blue@whale:x:123456:10:Blue Whale:/:
*
*/
static int
{
int nss_result;
return (NSS_STR_PARSE_PARSE);
/* Create handles for idmap service */
if (idmap_get_create(&ig) != 0)
goto result_pwd2str;
/* Get name */
goto result_pwd2str;
/* Get domain */
goto result_pwd2str;
/* Get objectSID (in text format) */
goto result_pwd2str;
/* Break SID into prefix and rid */
goto result_pwd2str;
*ptr = '\0';
goto result_pwd2str;
/* We already have uid -- no need to call idmapd */
else
/* Get primaryGroupID */
/*
* If primaryGroupID is not found then we request
* a GID to be mapped to the given user's objectSID
* (diagonal mapping) and use this GID as the primary
* GID for the entry.
*/
else {
goto result_pwd2str;
}
/* Map group SID to GID using idmap service */
goto result_pwd2str;
RESET_ERRNO();
goto result_pwd2str;
}
/* Get gecos, homedirectory and shell information if available */
else
return ((int)nss_result);
}
/*
* getbyname gets a passwd entry by winname. This function constructs an ldap
* search filter using the name invocation parameter and the getpwnam search
* filter defined. Once the filter is constructed, we search for a matching
* entry and marshal the data results into struct passwd for the frontend
* process. The function _nss_ad_passwd2ent performs the data marshaling.
*/
static nss_status_t
{
char *searchfilter;
char *dname;
int flag;
/* Sanitize name so that it can be used in our LDAP filter */
return ((nss_status_t)NSS_NOTFOUND);
return ((nss_status_t)NSS_NOTFOUND);
*dname = '\0';
dname++;
/*
* Map the given name to UID using idmap service. If idmap
* call fails then this will save us doing AD discovery and
* AD lookup here.
*/
is_wuser = -1;
is_user = 1;
RESET_ERRNO();
return ((nss_status_t)NSS_NOTFOUND);
}
/* If this is not a Well-Known SID then try AD lookup. */
/* Assemble filter using the given name */
return ((nss_status_t)NSS_NOTFOUND);
if (!try_idmap)
return (stat);
}
/*
* Either this is a Well-Known SID or AD lookup failed. Map
* the given name to GID using idmap service and construct
* the passwd entry.
*/
is_wuser = -1;
is_user = 0; /* Map name to primary gid */
if (idmaprc != IDMAP_SUCCESS) {
RESET_ERRNO();
return ((nss_status_t)NSS_NOTFOUND);
}
/* Create passwd(4) style string */
return ((nss_status_t)NSS_NOTFOUND);
/* Marshall the data, sanitize the return status and return */
}
/*
* getbyuid gets a passwd entry by uid number. This function constructs an ldap
* search filter using the uid invocation parameter and the getpwuid search
* filter defined. Once the filter is constructed, we search for a matching
* entry and marshal the data results into struct passwd for the frontend
* process. The function _nss_ad_passwd2ent performs the data marshaling.
*/
static nss_status_t
{
/* nss_ad does not support non ephemeral uids */
goto out;
/* Map the given UID to a SID using the idmap service */
RESET_ERRNO();
goto out;
}
/*
* NULL winname implies a local SID or unresolvable SID both of
* which cannot be used to generated passwd(4) entry
*/
goto out;
/* If this is not a Well-Known SID try AD lookup */
goto out;
goto out;
if (!try_idmap)
goto out;
}
/* Map winname to primary gid using idmap service */
is_user = 0;
is_wuser = -1;
if (idmaprc != IDMAP_SUCCESS) {
RESET_ERRNO();
goto out;
}
/* Create passwd(4) style string */
goto out;
/* Marshall the data, sanitize the return status and return */
out:
return (stat);
}
};
/*
* _nss_ad_passwd_constr is where life begins. This function calls the
* generic AD constructor function to define and build the abstract
* data types required to support AD operations.
*/
/*ARGSUSED0*/
const char *dummy3)
{
sizeof (passwd_ops)/sizeof (passwd_ops[0]),
}