return result;
}
+static char *sanitize_username(TALLOC_CTX *mem_ctx, const char *username)
+{
+ fstring tmp;
+
+ alpha_strcpy(tmp, username, ". _-$", sizeof(tmp));
+ return talloc_strdup(mem_ctx, tmp);
+}
+
/***************************************************************************
Make (and fill) a user_info struct from a struct samu
***************************************************************************/
TALLOC_FREE(pwd);
+ result->sanitized_username = sanitize_username(result,
+ result->unix_name);
+ if (result->sanitized_username == NULL) {
+ TALLOC_FREE(result);
+ return NT_STATUS_NO_MEMORY;
+ }
+
status = pdb_enum_group_memberships(result, sampass,
&result->sids, &gids,
&result->num_sids);
return user_in_group_sid(username, &group_sid);
}
-
/***************************************************************************
Make (and fill) a server_info struct from a 'struct passwd' by conversion
to a struct samu
}
result->sam_account = sampass;
+
result->unix_name = talloc_strdup(result, unix_username);
+ result->sanitized_username = sanitize_username(result, unix_username);
+
+ if ((result->unix_name == NULL)
+ || (result->sanitized_username == NULL)) {
+ TALLOC_FREE(sampass);
+ TALLOC_FREE(result);
+ return NT_STATUS_NO_MEMORY;
+ }
+
result->uid = pwd->pw_uid;
result->gid = pwd->pw_gid;
struct auth_serversupplied_info **presult)
{
struct auth_serversupplied_info *result;
+ struct passwd *pwd;
NTSTATUS status;
- result = make_server_info(mem_ctx);
- if (result == NULL) {
- return NT_STATUS_NO_MEMORY;
+ pwd = getpwnam_alloc(talloc_tos(), username);
+ if (pwd == NULL) {
+ return NT_STATUS_NO_SUCH_USER;
}
- result->nss_token = true;
- result->guest = is_guest;
+ status = make_server_info_pw(&result, pwd->pw_name, pwd);
- result->unix_name = talloc_strdup(result, username);
- if (result->unix_name == NULL) {
- TALLOC_FREE(result);
- return NT_STATUS_NO_MEMORY;
+ TALLOC_FREE(pwd);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
+ result->nss_token = true;
+ result->guest = is_guest;
+
status = create_local_token(result);
if (!NT_STATUS_IS_OK(status)) {
result->sam_account = sam_account;
result->unix_name = talloc_strdup(result, found_username);
+ result->sanitized_username = sanitize_username(result,
+ result->unix_name);
+ if (result->sanitized_username == NULL) {
+ TALLOC_FREE(result);
+ return NT_STATUS_NO_MEMORY;
+ }
+
/* Fill in the unix info we found on the way */
result->uid = uid;
result->sam_account = sam_account;
result->unix_name = talloc_strdup(result, found_username);
+ result->sanitized_username = sanitize_username(result,
+ result->unix_name);
result->login_server = talloc_strdup(result, info->logon_server);
+ if ((result->unix_name == NULL)
+ || (result->sanitized_username == NULL)
+ || (result->login_server == NULL)) {
+ TALLOC_FREE(result);
+ return NT_STATUS_NO_MEMORY;
+ }
+
/* Fill in the unix info we found on the way */
result->uid = uid;