server.c revision 651c0131ccc65381cbda174bee44a4fd7a518d6b
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/*
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * CDDL HEADER START
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw *
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * The contents of this file are subject to the terms of the
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * Common Development and Distribution License (the "License").
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * You may not use this file except in compliance with the License.
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw *
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * or http://www.opensolaris.org/os/licensing.
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * See the License for the specific language governing permissions
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * and limitations under the License.
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw *
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * When distributing Covered Code, include this CDDL HEADER in each
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * If applicable, add the following below this CDDL HEADER, with the
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * fields enclosed by brackets "[]" replaced with your own identifying
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * information: Portions Copyright [yyyy] [name of copyright owner]
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw *
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * CDDL HEADER END
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/*
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * Use is subject to license terms.
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#pragma ident "%Z%%M% %I% %E% SMI"
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/*
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * Service routines
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#include "idmapd.h"
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#include "idmap_priv.h"
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#include <signal.h>
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#include <thread.h>
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#include <string.h>
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#include <strings.h>
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#include <errno.h>
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#include <assert.h>
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#include <sys/types.h>
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#include <sys/stat.h>
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#include <ucred.h>
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#include <pwd.h>
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#include <auth_attr.h>
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#include <secdb.h>
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#define _VALIDATE_LIST_CB_DATA(col, val, siz)\
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw retcode = validate_list_cb_data(cb_data, argc, argv, col,\
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (uchar_t **)val, siz);\
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (retcode == IDMAP_NEXT) {\
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = IDMAP_NEXT;\
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (0);\
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw } else if (retcode < 0) {\
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = retcode;\
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (1);\
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#define PROCESS_LIST_SVC_SQL(rcode, db, sql, limit, cb, res, len)\
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw rcode = process_list_svc_sql(db, sql, limit, cb, res);\
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (rcode == IDMAP_ERR_BUSY)\
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw res->retcode = IDMAP_ERR_BUSY;\
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw else if (rcode == IDMAP_SUCCESS && len == 0)\
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw res->retcode = IDMAP_ERR_NOTFOUND;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/* ARGSUSED */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwbool_t
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwidmap_null_1_svc(void *result, struct svc_req *rqstp) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (TRUE);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw}
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#define IS_BATCH_SID(batch, i)\
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw batch.idmap_mapping_batch_val[i].id1.idtype == IDMAP_SID
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#define IS_BATCH_UID(batch, i)\
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw batch.idmap_mapping_batch_val[i].id1.idtype == IDMAP_UID
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#define IS_BATCH_GID(batch, i)\
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw batch.idmap_mapping_batch_val[i].id1.idtype == IDMAP_GID
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#define IS_REQUEST_SID(request)\
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw request.id1.idtype == IDMAP_SID
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#define IS_REQUEST_UID(request)\
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw request.id1.idtype == IDMAP_UID
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#define IS_REQUEST_GID(request)\
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw request.id1.idtype == IDMAP_GID
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/* ARGSUSED */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwbool_t
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwidmap_get_mapped_ids_1_svc(idmap_mapping_batch batch,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmap_ids_res *result, struct svc_req *rqstp) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw sqlite *cache = NULL, *db = NULL;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw lookup_state_t state;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmap_retcode retcode, winrc;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw int i;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Init */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) memset(result, 0, sizeof (*result));
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) memset(&state, 0, sizeof (state));
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Return success if nothing was requested */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (batch.idmap_mapping_batch_len < 1)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Get cache handle */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = get_cache_handle(&cache);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (result->retcode != IDMAP_SUCCESS)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Get db handle */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = get_db_handle(&db);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (result->retcode != IDMAP_SUCCESS)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Allocate result array */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->ids.ids_val = calloc(batch.idmap_mapping_batch_len,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw sizeof (idmap_id_res));
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (result->ids.ids_val == NULL) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmapdlog(LOG_ERR, "Out of memory");
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = IDMAP_ERR_MEMORY;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->ids.ids_len = batch.idmap_mapping_batch_len;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Init our 'done' flags */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw state.sid2pid_done = state.pid2sid_done = TRUE;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* First stage */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw for (i = 0; i < batch.idmap_mapping_batch_len; i++) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (IS_BATCH_SID(batch, i)) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw retcode = sid2pid_first_pass(
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &state,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw cache,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &batch.idmap_mapping_batch_val[i],
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &result->ids.ids_val[i]);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw } else if (IS_BATCH_UID(batch, i)) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw retcode = pid2sid_first_pass(
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &state,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw cache,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw db,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &batch.idmap_mapping_batch_val[i],
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &result->ids.ids_val[i], 1, 0);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw } else if (IS_BATCH_GID(batch, i)) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw retcode = pid2sid_first_pass(
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &state,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw cache,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw db,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &batch.idmap_mapping_batch_val[i],
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &result->ids.ids_val[i], 0, 0);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw } else {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->ids.ids_val[i].retcode = IDMAP_ERR_IDTYPE;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw continue;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (IDMAP_FATAL_ERROR(retcode)) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = retcode;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Check if we are done */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (state.sid2pid_done == TRUE && state.pid2sid_done == TRUE)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Process Windows server lookups for sid2name */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (state.ad_nqueries) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw winrc = lookup_win_batch_sid2name(&state, &batch,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (IDMAP_FATAL_ERROR(winrc)) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = winrc;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw } else
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw winrc = IDMAP_SUCCESS;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Reset sid2pid 'done' flag */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw state.sid2pid_done = TRUE;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Second stage */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw for (i = 0; i < batch.idmap_mapping_batch_len; i++) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Process sid to pid ONLY */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (IS_BATCH_SID(batch, i)) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (IDMAP_ERROR(winrc))
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->ids.ids_val[i].retcode = winrc;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw retcode = sid2pid_second_pass(
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &state,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw cache,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw db,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &batch.idmap_mapping_batch_val[i],
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &result->ids.ids_val[i]);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (IDMAP_FATAL_ERROR(retcode)) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = retcode;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Check if we are done */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (state.sid2pid_done == TRUE && state.pid2sid_done == TRUE)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Reset our 'done' flags */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw state.sid2pid_done = state.pid2sid_done = TRUE;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Update cache in a single transaction */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (sql_exec_no_cb(cache, "BEGIN TRANSACTION;") != IDMAP_SUCCESS)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw for (i = 0; i < batch.idmap_mapping_batch_len; i++) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (IS_BATCH_SID(batch, i)) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) update_cache_sid2pid(
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &state,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw cache,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &batch.idmap_mapping_batch_val[i],
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &result->ids.ids_val[i]);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw } else if ((IS_BATCH_UID(batch, i)) ||
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (IS_BATCH_GID(batch, i))) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) update_cache_pid2sid(
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &state,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw cache,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &batch.idmap_mapping_batch_val[i],
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &result->ids.ids_val[i]);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Commit if we have atleast one successful update */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (state.sid2pid_done == FALSE || state.pid2sid_done == FALSE)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) sql_exec_no_cb(cache, "COMMIT TRANSACTION;");
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw else
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) sql_exec_no_cb(cache, "END TRANSACTION;");
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwout:
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (IDMAP_ERROR(result->retcode)) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw xdr_free(xdr_idmap_ids_res, (caddr_t)result);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->ids.ids_len = 0;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->ids.ids_val = NULL;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (cache)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) sqlite_close(cache);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (db)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) sqlite_close(db);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = idmap_stat4prot(result->retcode);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (TRUE);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw}
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/* ARGSUSED */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwstatic int
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwlist_mappings_cb(void *parg, int argc, char **argv, char **colnames) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw list_cb_data_t *cb_data;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw char *str;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmap_mappings_res *result;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmap_utf8str *ptr;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmap_retcode retcode;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw int w2u, u2w;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw char *end;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw cb_data = (list_cb_data_t *)parg;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result = (idmap_mappings_res *)cb_data->result;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw _VALIDATE_LIST_CB_DATA(9, &result->mappings.mappings_val,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw sizeof (idmap_mapping));
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->mappings.mappings_len++;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if ((str = strdup(argv[1])) == NULL)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (1);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->mappings.mappings_val[cb_data->next].id1.idmap_id_u.sid.prefix =
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw str;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->mappings.mappings_val[cb_data->next].id1.idmap_id_u.sid.rid =
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw strtoul(argv[2], &end, 10);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->mappings.mappings_val[cb_data->next].id1.idtype = IDMAP_SID;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->mappings.mappings_val[cb_data->next].id2.idmap_id_u.uid =
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw strtoul(argv[3], &end, 10);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->mappings.mappings_val[cb_data->next].id2.idtype = IDMAP_UID;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw w2u = argv[4]?strtol(argv[4], &end, 10):0;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw u2w = argv[5]?strtol(argv[5], &end, 10):0;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (w2u > 0 && u2w == 0)
651c0131ccc65381cbda174bee44a4fd7a518d6bbaban result->mappings.mappings_val[cb_data->next].direction =
651c0131ccc65381cbda174bee44a4fd7a518d6bbaban IDMAP_DIRECTION_W2U;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw else if (w2u == 0 && u2w > 0)
651c0131ccc65381cbda174bee44a4fd7a518d6bbaban result->mappings.mappings_val[cb_data->next].direction =
651c0131ccc65381cbda174bee44a4fd7a518d6bbaban IDMAP_DIRECTION_U2W;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw else
651c0131ccc65381cbda174bee44a4fd7a518d6bbaban result->mappings.mappings_val[cb_data->next].direction =
651c0131ccc65381cbda174bee44a4fd7a518d6bbaban IDMAP_DIRECTION_BI;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw ptr = &result->mappings.mappings_val[cb_data->next].id1domain;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (idmap_str2utf8(&ptr, argv[6], 0) != IDMAP_SUCCESS)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (1);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw ptr = &result->mappings.mappings_val[cb_data->next].id1name;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (idmap_str2utf8(&ptr, argv[7], 0) != IDMAP_SUCCESS)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (1);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw ptr = &result->mappings.mappings_val[cb_data->next].id2name;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (idmap_str2utf8(&ptr, argv[8], 0) != IDMAP_SUCCESS)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (1);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->lastrowid = strtoll(argv[0], &end, 10);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw cb_data->next++;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = IDMAP_SUCCESS;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (0);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw}
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/* ARGSUSED */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwbool_t
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwidmap_list_mappings_1_svc(bool_t is_user, int64_t lastrowid,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw uint64_t limit, idmap_mappings_res *result,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw struct svc_req *rqstp) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw sqlite *cache = NULL;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw char lbuf[30], rbuf[30];
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw uint64_t maxlimit;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmap_retcode retcode;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw char *sql = NULL;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) memset(result, 0, sizeof (*result));
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw lbuf[0] = rbuf[0] = 0;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw RDLOCK_CONFIG();
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw maxlimit = _idmapdstate.cfg->pgcfg.list_size_limit;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw UNLOCK_CONFIG();
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Get cache handle */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = get_cache_handle(&cache);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (result->retcode != IDMAP_SUCCESS)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = IDMAP_ERR_INTERNAL;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Create LIMIT expression. */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (limit == 0 || (maxlimit > 0 && maxlimit < limit))
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw limit = maxlimit;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (limit > 0)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) snprintf(lbuf, sizeof (lbuf),
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw "LIMIT %" PRIu64, limit + 1ULL);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) snprintf(rbuf, sizeof (rbuf), "rowid > %" PRIu64, lastrowid);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /*
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * Combine all the above into a giant SELECT statement that
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * will return the requested mappings
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw sql = sqlite_mprintf("SELECT rowid, sidprefix, rid, pid, w2u, u2w,"
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw " windomain, winname, unixname"
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw " FROM idmap_cache WHERE "
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw " %s AND is_user = %d %s;",
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw rbuf, is_user?1:0, lbuf);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (sql == NULL) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmapdlog(LOG_ERR, "Out of memory");
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Execute the SQL statement and update the return buffer */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw PROCESS_LIST_SVC_SQL(retcode, cache, sql, limit, list_mappings_cb,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result, result->mappings.mappings_len);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwout:
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (sql)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw sqlite_freemem(sql);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (IDMAP_ERROR(result->retcode))
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) xdr_free(xdr_idmap_mappings_res, (caddr_t)result);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (cache)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) sqlite_close(cache);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = idmap_stat4prot(result->retcode);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (TRUE);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw}
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/* ARGSUSED */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwstatic int
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwlist_namerules_cb(void *parg, int argc, char **argv, char **colnames) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw list_cb_data_t *cb_data;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmap_namerules_res *result;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmap_retcode retcode;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmap_utf8str *ptr;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw int w2u_order, u2w_order;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw char *end;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw cb_data = (list_cb_data_t *)parg;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result = (idmap_namerules_res *)cb_data->result;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw _VALIDATE_LIST_CB_DATA(8, &result->rules.rules_val,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw sizeof (idmap_namerule));
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->rules.rules_len++;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->rules.rules_val[cb_data->next].is_user =
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw strtol(argv[1], &end, 10);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw ptr = &result->rules.rules_val[cb_data->next].windomain;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (idmap_str2utf8(&ptr, argv[2], 0) != IDMAP_SUCCESS)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (1);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw ptr = &result->rules.rules_val[cb_data->next].winname;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (idmap_str2utf8(&ptr, argv[3], 0) != IDMAP_SUCCESS)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (1);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->rules.rules_val[cb_data->next].is_nt4 =
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw strtol(argv[4], &end, 10);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw ptr = &result->rules.rules_val[cb_data->next].unixname;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (idmap_str2utf8(&ptr, argv[5], 0) != IDMAP_SUCCESS)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (1);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw w2u_order = argv[6]?strtol(argv[6], &end, 10):0;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw u2w_order = argv[7]?strtol(argv[7], &end, 10):0;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (w2u_order > 0 && u2w_order == 0)
651c0131ccc65381cbda174bee44a4fd7a518d6bbaban result->rules.rules_val[cb_data->next].direction =
651c0131ccc65381cbda174bee44a4fd7a518d6bbaban IDMAP_DIRECTION_W2U;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw else if (w2u_order == 0 && u2w_order > 0)
651c0131ccc65381cbda174bee44a4fd7a518d6bbaban result->rules.rules_val[cb_data->next].direction =
651c0131ccc65381cbda174bee44a4fd7a518d6bbaban IDMAP_DIRECTION_U2W;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw else
651c0131ccc65381cbda174bee44a4fd7a518d6bbaban result->rules.rules_val[cb_data->next].direction =
651c0131ccc65381cbda174bee44a4fd7a518d6bbaban IDMAP_DIRECTION_BI;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->lastrowid = strtoll(argv[0], &end, 10);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw cb_data->next++;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = IDMAP_SUCCESS;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (0);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw}
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/* ARGSUSED */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwbool_t
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwidmap_list_namerules_1_svc(idmap_namerule rule, uint64_t lastrowid,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw uint64_t limit, idmap_namerules_res *result,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw struct svc_req *rqstp) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw sqlite *db = NULL;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw char w2ubuf[15], u2wbuf[15];
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw char lbuf[30], rbuf[30];
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw char *sql = NULL;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw char *s_windomain = NULL, *s_winname = NULL;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw char *s_unixname = NULL;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw uint64_t maxlimit;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmap_retcode retcode;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) memset(result, 0, sizeof (*result));
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw lbuf[0] = rbuf[0] = 0;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw RDLOCK_CONFIG();
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw maxlimit = _idmapdstate.cfg->pgcfg.list_size_limit;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw UNLOCK_CONFIG();
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Get db handle */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = get_db_handle(&db);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (result->retcode != IDMAP_SUCCESS)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = IDMAP_ERR_INTERNAL;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (rule.direction < 0) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw w2ubuf[0] = u2wbuf[0] = 0;
651c0131ccc65381cbda174bee44a4fd7a518d6bbaban } else if (rule.direction == IDMAP_DIRECTION_BI) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) snprintf(w2ubuf, sizeof (w2ubuf), "AND w2u_order > 0");
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) snprintf(u2wbuf, sizeof (u2wbuf), "AND u2w_order > 0");
651c0131ccc65381cbda174bee44a4fd7a518d6bbaban } else if (rule.direction == IDMAP_DIRECTION_W2U) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) snprintf(w2ubuf, sizeof (w2ubuf), "AND w2u_order > 0");
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) snprintf(u2wbuf, sizeof (u2wbuf),
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw "AND (u2w_order = 0 OR u2w_order ISNULL)");
651c0131ccc65381cbda174bee44a4fd7a518d6bbaban } else if (rule.direction == IDMAP_DIRECTION_U2W) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) snprintf(w2ubuf, sizeof (w2ubuf),
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw "AND (w2u_order = 0 OR w2u_order ISNULL)");
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) snprintf(u2wbuf, sizeof (u2wbuf), "AND u2w_order > 0");
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Create where statement for windomain */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (rule.windomain.idmap_utf8str_len > 0) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (gen_sql_expr_from_utf8str("AND", "windomain", "=",
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &rule.windomain,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw "", &s_windomain) != IDMAP_SUCCESS)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Create where statement for winname */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (rule.winname.idmap_utf8str_len > 0) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (gen_sql_expr_from_utf8str("AND", "winname", "=",
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &rule.winname,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw "", &s_winname) != IDMAP_SUCCESS)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Create where statement for unixname */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (rule.unixname.idmap_utf8str_len > 0) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (gen_sql_expr_from_utf8str("AND", "unixname", "=",
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &rule.unixname,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw "", &s_unixname) != IDMAP_SUCCESS)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Create LIMIT expression. */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (limit == 0 || (maxlimit > 0 && maxlimit < limit))
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw limit = maxlimit;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (limit > 0)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) snprintf(lbuf, sizeof (lbuf),
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw "LIMIT %" PRIu64, limit + 1ULL);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) snprintf(rbuf, sizeof (rbuf), "rowid > %" PRIu64, lastrowid);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /*
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * Combine all the above into a giant SELECT statement that
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * will return the requested rules
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw sql = sqlite_mprintf("SELECT rowid, is_user, windomain, winname, "
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw "is_nt4, unixname, w2u_order, u2w_order "
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw "FROM namerules WHERE "
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw " %s AND is_user = %d %s %s %s %s %s %s;",
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw rbuf, rule.is_user?1:0,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw s_windomain?s_windomain:"",
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw s_winname?s_winname:"",
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw s_unixname?s_unixname:"",
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw w2ubuf, u2wbuf, lbuf);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (sql == NULL) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmapdlog(LOG_ERR, "Out of memory");
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Execute the SQL statement and update the return buffer */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw PROCESS_LIST_SVC_SQL(retcode, db, sql, limit, list_namerules_cb,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result, result->rules.rules_len);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwout:
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (s_windomain)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw sqlite_freemem(s_windomain);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (s_winname)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw sqlite_freemem(s_winname);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (s_unixname)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw sqlite_freemem(s_unixname);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (sql)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw sqlite_freemem(sql);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (IDMAP_ERROR(result->retcode))
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) xdr_free(xdr_idmap_namerules_res, (caddr_t)result);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (db)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) sqlite_close(db);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = idmap_stat4prot(result->retcode);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (TRUE);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw}
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#define IDMAP_RULES_AUTH "solaris.admin.idmap.rules"
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwstatic int
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwverify_rules_auth(struct svc_req *rqstp) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw ucred_t *uc = NULL;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw uid_t uid;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw char buf[1024];
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw struct passwd pwd;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw const char *me = "verify_rules_auth";
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (svc_getcallerucred(rqstp->rq_xprt, &uc) != 0) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmapdlog(LOG_ERR,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw "%s: svc_getcallerucred failed (errno=%d)",
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw me, errno);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (-1);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw uid = ucred_geteuid(uc);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (uid == (uid_t)-1) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmapdlog(LOG_ERR,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw "%s: ucred_geteuid failed (errno=%d)",
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw me, errno);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw ucred_free(uc);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (-1);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (getpwuid_r(uid, &pwd, buf, sizeof (buf)) == NULL) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmapdlog(LOG_ERR,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw "%s: getpwuid_r(%u) failed (errno=%d)",
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw me, uid, errno);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw ucred_free(uc);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (-1);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (chkauthattr(IDMAP_RULES_AUTH, pwd.pw_name) != 1) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmapdlog(LOG_INFO,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw "%s: %s does not have authorization.",
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw me, pwd.pw_name);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw ucred_free(uc);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (-1);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw ucred_free(uc);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (1);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw}
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/* ARGSUSED */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwbool_t
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwidmap_update_1_svc(idmap_update_batch batch, idmap_retcode *result,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw struct svc_req *rqstp) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw sqlite *db = NULL;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmap_update_op *up;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw int i;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (verify_rules_auth(rqstp) < 0) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw *result = IDMAP_ERR_PERMISSION_DENIED;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (batch.idmap_update_batch_len == 0 ||
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw batch.idmap_update_batch_val == NULL) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw *result = IDMAP_SUCCESS;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Get db handle */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw *result = get_db_handle(&db);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (*result != IDMAP_SUCCESS)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw *result = sql_exec_no_cb(db, "BEGIN TRANSACTION;");
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (*result != IDMAP_SUCCESS)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw for (i = 0; i < batch.idmap_update_batch_len; i++) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw up = &batch.idmap_update_batch_val[i];
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw switch (up->opnum) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw case OP_NONE:
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw *result = IDMAP_SUCCESS;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw break;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw case OP_ADD_NAMERULE:
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw *result = add_namerule(db,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &up->idmap_update_op_u.rule);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw break;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw case OP_RM_NAMERULE:
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw *result = rm_namerule(db,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &up->idmap_update_op_u.rule);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw break;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw case OP_FLUSH_NAMERULES:
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw *result = flush_namerules(db,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw up->idmap_update_op_u.is_user);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw break;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw default:
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw *result = IDMAP_ERR_NOTSUPPORTED;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw };
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (*result != IDMAP_SUCCESS)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwout:
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (*result == IDMAP_SUCCESS && db) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw *result = sql_exec_no_cb(db, "COMMIT TRANSACTION;");
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (db)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) sqlite_close(db);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw *result = idmap_stat4prot(*result);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (TRUE);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw}
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/* ARGSUSED */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwbool_t
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwidmap_get_mapped_id_by_name_1_svc(idmap_mapping request,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmap_mappings_res *result, struct svc_req *rqstp) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw sqlite *cache = NULL, *db = NULL;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Init */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) memset(result, 0, sizeof (*result));
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Get cache handle */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = get_cache_handle(&cache);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (result->retcode != IDMAP_SUCCESS)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Get db handle */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = get_db_handle(&db);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (result->retcode != IDMAP_SUCCESS)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Allocate result */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->mappings.mappings_val = calloc(1, sizeof (idmap_mapping));
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (result->mappings.mappings_val == NULL) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmapdlog(LOG_ERR, "Out of memory");
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = IDMAP_ERR_MEMORY;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->mappings.mappings_len = 1;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (IS_REQUEST_SID(request)) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = get_w2u_mapping(
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw cache,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw db,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &request,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->mappings.mappings_val);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw } else if (IS_REQUEST_UID(request)) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = get_u2w_mapping(
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw cache,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw db,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &request,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->mappings.mappings_val,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw 1);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw } else if (IS_REQUEST_GID(request)) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = get_u2w_mapping(
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw cache,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw db,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw &request,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->mappings.mappings_val,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw 0);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw } else {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = IDMAP_ERR_IDTYPE;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwout:
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (IDMAP_FATAL_ERROR(result->retcode)) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw xdr_free(xdr_idmap_mappings_res, (caddr_t)result);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->mappings.mappings_len = 0;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->mappings.mappings_val = NULL;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (cache)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) sqlite_close(cache);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (db)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) sqlite_close(db);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = idmap_stat4prot(result->retcode);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (TRUE);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw}
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/* ARGSUSED */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwint
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwidmap_prog_1_freeresult(SVCXPRT *transp, xdrproc_t xdr_result,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw caddr_t result) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) xdr_free(xdr_result, result);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (TRUE);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw}