server.c revision 48258c6b4e17f36ab09fba0bd6307d1fec9dcbce
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/*
0dcc71495bad040a0c83830efc85acf8d897350dnw * Copyright 2008 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"
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban#include "nldaputils.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>
0dcc71495bad040a0c83830efc85acf8d897350dnw#include <sys/u8_textprep.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
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp#define PROCESS_LIST_SVC_SQL(rcode, db, dbname, sql, limit, flag, cb, res, len)\
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp rcode = process_list_svc_sql(db, dbname, sql, limit, flag, 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
8e22821528b08c6dba4e8176351560f316f6d0dedm#define STRDUP_OR_FAIL(to, from) \
8e22821528b08c6dba4e8176351560f316f6d0dedm if ((from) == NULL) \
8e22821528b08c6dba4e8176351560f316f6d0dedm to = NULL; \
8e22821528b08c6dba4e8176351560f316f6d0dedm else { \
8e22821528b08c6dba4e8176351560f316f6d0dedm if ((to = strdup(from)) == NULL) \
8e22821528b08c6dba4e8176351560f316f6d0dedm return (1); \
8e22821528b08c6dba4e8176351560f316f6d0dedm }
8e22821528b08c6dba4e8176351560f316f6d0dedm
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/* ARGSUSED */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwbool_t
cd37da7426f0c49c14ad9a8a07638ca971477566nwidmap_null_1_svc(void *result, struct svc_req *rqstp)
cd37da7426f0c49c14ad9a8a07638ca971477566nw{
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (TRUE);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw}
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
334e34639228c5021a69504cca69d70d851c52fababan/*
334e34639228c5021a69504cca69d70d851c52fababan * RPC layer allocates empty strings to replace NULL char *.
334e34639228c5021a69504cca69d70d851c52fababan * This utility function frees these empty strings.
334e34639228c5021a69504cca69d70d851c52fababan */
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3babanstatic
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3babanvoid
334e34639228c5021a69504cca69d70d851c52fababansanitize_mapping_request(idmap_mapping *req)
334e34639228c5021a69504cca69d70d851c52fababan{
334e34639228c5021a69504cca69d70d851c52fababan free(req->id1name);
334e34639228c5021a69504cca69d70d851c52fababan req->id1name = NULL;
334e34639228c5021a69504cca69d70d851c52fababan free(req->id1domain);
334e34639228c5021a69504cca69d70d851c52fababan req->id1domain = NULL;
334e34639228c5021a69504cca69d70d851c52fababan free(req->id2name);
334e34639228c5021a69504cca69d70d851c52fababan req->id2name = NULL;
334e34639228c5021a69504cca69d70d851c52fababan free(req->id2domain);
334e34639228c5021a69504cca69d70d851c52fababan req->id2domain = NULL;
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban req->direction = _IDMAP_F_DONE;
334e34639228c5021a69504cca69d70d851c52fababan}
334e34639228c5021a69504cca69d70d851c52fababan
0dcc71495bad040a0c83830efc85acf8d897350dnwstatic
0dcc71495bad040a0c83830efc85acf8d897350dnwint
0dcc71495bad040a0c83830efc85acf8d897350dnwvalidate_mapped_id_by_name_req(idmap_mapping *req)
0dcc71495bad040a0c83830efc85acf8d897350dnw{
0dcc71495bad040a0c83830efc85acf8d897350dnw int e;
0dcc71495bad040a0c83830efc85acf8d897350dnw
0dcc71495bad040a0c83830efc85acf8d897350dnw if (IS_REQUEST_UID(*req) || IS_REQUEST_GID(*req))
0dcc71495bad040a0c83830efc85acf8d897350dnw return (IDMAP_SUCCESS);
0dcc71495bad040a0c83830efc85acf8d897350dnw
0dcc71495bad040a0c83830efc85acf8d897350dnw if (IS_REQUEST_SID(*req, 1)) {
0dcc71495bad040a0c83830efc85acf8d897350dnw if (!EMPTY_STRING(req->id1name) &&
0dcc71495bad040a0c83830efc85acf8d897350dnw u8_validate(req->id1name, strlen(req->id1name),
0dcc71495bad040a0c83830efc85acf8d897350dnw NULL, U8_VALIDATE_ENTIRE, &e) < 0)
0dcc71495bad040a0c83830efc85acf8d897350dnw return (IDMAP_ERR_BAD_UTF8);
0dcc71495bad040a0c83830efc85acf8d897350dnw if (!EMPTY_STRING(req->id1domain) &&
0dcc71495bad040a0c83830efc85acf8d897350dnw u8_validate(req->id1domain, strlen(req->id1domain),
0dcc71495bad040a0c83830efc85acf8d897350dnw NULL, U8_VALIDATE_ENTIRE, &e) < 0)
0dcc71495bad040a0c83830efc85acf8d897350dnw return (IDMAP_ERR_BAD_UTF8);
0dcc71495bad040a0c83830efc85acf8d897350dnw }
0dcc71495bad040a0c83830efc85acf8d897350dnw
0dcc71495bad040a0c83830efc85acf8d897350dnw return (IDMAP_SUCCESS);
0dcc71495bad040a0c83830efc85acf8d897350dnw}
0dcc71495bad040a0c83830efc85acf8d897350dnw
0dcc71495bad040a0c83830efc85acf8d897350dnwstatic
0dcc71495bad040a0c83830efc85acf8d897350dnwint
0dcc71495bad040a0c83830efc85acf8d897350dnwvalidate_rule(idmap_namerule *rule)
0dcc71495bad040a0c83830efc85acf8d897350dnw{
0dcc71495bad040a0c83830efc85acf8d897350dnw int e;
0dcc71495bad040a0c83830efc85acf8d897350dnw
0dcc71495bad040a0c83830efc85acf8d897350dnw if (!EMPTY_STRING(rule->winname) &&
0dcc71495bad040a0c83830efc85acf8d897350dnw u8_validate(rule->winname, strlen(rule->winname),
0dcc71495bad040a0c83830efc85acf8d897350dnw NULL, U8_VALIDATE_ENTIRE, &e) < 0)
0dcc71495bad040a0c83830efc85acf8d897350dnw return (IDMAP_ERR_BAD_UTF8);
0dcc71495bad040a0c83830efc85acf8d897350dnw
0dcc71495bad040a0c83830efc85acf8d897350dnw if (!EMPTY_STRING(rule->windomain) &&
0dcc71495bad040a0c83830efc85acf8d897350dnw u8_validate(rule->windomain, strlen(rule->windomain),
0dcc71495bad040a0c83830efc85acf8d897350dnw NULL, U8_VALIDATE_ENTIRE, &e) < 0)
0dcc71495bad040a0c83830efc85acf8d897350dnw return (IDMAP_ERR_BAD_UTF8);
0dcc71495bad040a0c83830efc85acf8d897350dnw
0dcc71495bad040a0c83830efc85acf8d897350dnw return (IDMAP_SUCCESS);
0dcc71495bad040a0c83830efc85acf8d897350dnw
0dcc71495bad040a0c83830efc85acf8d897350dnw}
0dcc71495bad040a0c83830efc85acf8d897350dnw
0dcc71495bad040a0c83830efc85acf8d897350dnwstatic
0dcc71495bad040a0c83830efc85acf8d897350dnwbool_t
0dcc71495bad040a0c83830efc85acf8d897350dnwvalidate_rules(idmap_update_batch *batch)
0dcc71495bad040a0c83830efc85acf8d897350dnw{
0dcc71495bad040a0c83830efc85acf8d897350dnw idmap_update_op *up;
0dcc71495bad040a0c83830efc85acf8d897350dnw int i;
0dcc71495bad040a0c83830efc85acf8d897350dnw
0dcc71495bad040a0c83830efc85acf8d897350dnw for (i = 0; i < batch->idmap_update_batch_len; i++) {
0dcc71495bad040a0c83830efc85acf8d897350dnw up = &(batch->idmap_update_batch_val[i]);
0dcc71495bad040a0c83830efc85acf8d897350dnw if (validate_rule(&(up->idmap_update_op_u.rule))
0dcc71495bad040a0c83830efc85acf8d897350dnw != IDMAP_SUCCESS)
0dcc71495bad040a0c83830efc85acf8d897350dnw return (IDMAP_ERR_BAD_UTF8);
0dcc71495bad040a0c83830efc85acf8d897350dnw }
0dcc71495bad040a0c83830efc85acf8d897350dnw
0dcc71495bad040a0c83830efc85acf8d897350dnw return (IDMAP_SUCCESS);
0dcc71495bad040a0c83830efc85acf8d897350dnw}
0dcc71495bad040a0c83830efc85acf8d897350dnw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/* ARGSUSED */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwbool_t
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwidmap_get_mapped_ids_1_svc(idmap_mapping_batch batch,
cd37da7426f0c49c14ad9a8a07638ca971477566nw idmap_ids_res *result, struct svc_req *rqstp)
cd37da7426f0c49c14ad9a8a07638ca971477566nw{
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw sqlite *cache = NULL, *db = NULL;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw lookup_state_t state;
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban idmap_retcode retcode;
62c6006265c37877b7a5b3c8ffce913ef559b955baban uint_t 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,
cd37da7426f0c49c14ad9a8a07638ca971477566nw 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
62c6006265c37877b7a5b3c8ffce913ef559b955baban /* Allocate hash table to check for duplicate sids */
62c6006265c37877b7a5b3c8ffce913ef559b955baban state.sid_history = calloc(batch.idmap_mapping_batch_len,
cd37da7426f0c49c14ad9a8a07638ca971477566nw sizeof (*state.sid_history));
62c6006265c37877b7a5b3c8ffce913ef559b955baban if (state.sid_history == NULL) {
62c6006265c37877b7a5b3c8ffce913ef559b955baban idmapdlog(LOG_ERR, "Out of memory");
62c6006265c37877b7a5b3c8ffce913ef559b955baban result->retcode = IDMAP_ERR_MEMORY;
62c6006265c37877b7a5b3c8ffce913ef559b955baban goto out;
62c6006265c37877b7a5b3c8ffce913ef559b955baban }
62c6006265c37877b7a5b3c8ffce913ef559b955baban state.sid_history_size = batch.idmap_mapping_batch_len;
62c6006265c37877b7a5b3c8ffce913ef559b955baban for (i = 0; i < state.sid_history_size; i++) {
62c6006265c37877b7a5b3c8ffce913ef559b955baban state.sid_history[i].key = state.sid_history_size;
62c6006265c37877b7a5b3c8ffce913ef559b955baban state.sid_history[i].next = state.sid_history_size;
62c6006265c37877b7a5b3c8ffce913ef559b955baban }
62c6006265c37877b7a5b3c8ffce913ef559b955baban state.batch = &batch;
62c6006265c37877b7a5b3c8ffce913ef559b955baban state.result = result;
62c6006265c37877b7a5b3c8ffce913ef559b955baban
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban /* Get directory-based name mapping info */
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban result->retcode = get_ds_namemap_type(&state);
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban if (result->retcode != IDMAP_SUCCESS)
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban goto out;
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban
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++) {
62c6006265c37877b7a5b3c8ffce913ef559b955baban state.curpos = i;
334e34639228c5021a69504cca69d70d851c52fababan (void) sanitize_mapping_request(
334e34639228c5021a69504cca69d70d851c52fababan &batch.idmap_mapping_batch_val[i]);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (IS_BATCH_SID(batch, i)) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw retcode = sid2pid_first_pass(
cd37da7426f0c49c14ad9a8a07638ca971477566nw &state,
cd37da7426f0c49c14ad9a8a07638ca971477566nw cache,
cd37da7426f0c49c14ad9a8a07638ca971477566nw &batch.idmap_mapping_batch_val[i],
cd37da7426f0c49c14ad9a8a07638ca971477566nw &result->ids.ids_val[i]);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw } else if (IS_BATCH_UID(batch, i)) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw retcode = pid2sid_first_pass(
cd37da7426f0c49c14ad9a8a07638ca971477566nw &state,
cd37da7426f0c49c14ad9a8a07638ca971477566nw cache,
cd37da7426f0c49c14ad9a8a07638ca971477566nw &batch.idmap_mapping_batch_val[i],
cd37da7426f0c49c14ad9a8a07638ca971477566nw &result->ids.ids_val[i], 1, 0);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw } else if (IS_BATCH_GID(batch, i)) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw retcode = pid2sid_first_pass(
cd37da7426f0c49c14ad9a8a07638ca971477566nw &state,
cd37da7426f0c49c14ad9a8a07638ca971477566nw cache,
cd37da7426f0c49c14ad9a8a07638ca971477566nw &batch.idmap_mapping_batch_val[i],
cd37da7426f0c49c14ad9a8a07638ca971477566nw &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
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban /*
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban * native LDAP lookups:
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban * If nldap or mixed mode is enabled then pid2sid mapping requests
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban * need to lookup native LDAP directory service by uid/gid to get
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban * winname and unixname.
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban */
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban if (state.nldap_nqueries) {
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban retcode = nldap_lookup_batch(&state, &batch, result);
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban if (IDMAP_FATAL_ERROR(retcode)) {
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban result->retcode = retcode;
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban goto out;
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban }
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban }
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban /*
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban * AD lookups:
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban * 1. The pid2sid requests in the preceding step which successfully
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban * retrieved winname from native LDAP objects will now need to
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban * lookup AD by winname to get sid.
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban * 2. The sid2pid requests will need to lookup AD by sid to get
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban * winname and unixname (AD or mixed mode).
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban * 3. If AD-based name mapping is enabled then pid2sid mapping
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban * requests need to lookup AD by unixname to get winname and sid.
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (state.ad_nqueries) {
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban retcode = ad_lookup_batch(&state, &batch, result);
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban if (IDMAP_FATAL_ERROR(retcode)) {
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban result->retcode = retcode;
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban goto out;
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban }
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban }
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban /*
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban * native LDAP lookups:
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban * If nldap mode is enabled then sid2pid mapping requests
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban * which successfully retrieved winname from AD objects in the
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban * preceding step, will now need to lookup native LDAP directory
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban * service by winname to get unixname and pid.
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban */
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban if (state.nldap_nqueries) {
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban retcode = nldap_lookup_batch(&state, &batch, result);
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban if (IDMAP_FATAL_ERROR(retcode)) {
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban result->retcode = retcode;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban /* Reset 'done' flags */
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban state.sid2pid_done = state.pid2sid_done = TRUE;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Second stage */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw for (i = 0; i < batch.idmap_mapping_batch_len; i++) {
62c6006265c37877b7a5b3c8ffce913ef559b955baban state.curpos = i;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (IS_BATCH_SID(batch, i)) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw retcode = sid2pid_second_pass(
cd37da7426f0c49c14ad9a8a07638ca971477566nw &state,
cd37da7426f0c49c14ad9a8a07638ca971477566nw cache,
cd37da7426f0c49c14ad9a8a07638ca971477566nw db,
cd37da7426f0c49c14ad9a8a07638ca971477566nw &batch.idmap_mapping_batch_val[i],
cd37da7426f0c49c14ad9a8a07638ca971477566nw &result->ids.ids_val[i]);
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban } else if (IS_BATCH_UID(batch, i)) {
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban retcode = pid2sid_second_pass(
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban &state,
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban cache,
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban db,
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban &batch.idmap_mapping_batch_val[i],
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban &result->ids.ids_val[i], 1);
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban } else if (IS_BATCH_GID(batch, i)) {
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban retcode = pid2sid_second_pass(
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban &state,
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban cache,
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban db,
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban &batch.idmap_mapping_batch_val[i],
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban &result->ids.ids_val[i], 0);
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban } else {
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban /* First stage has already set the error */
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban continue;
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban }
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban if (IDMAP_FATAL_ERROR(retcode)) {
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban result->retcode = retcode;
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban 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 /* Reset our 'done' flags */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw state.sid2pid_done = state.pid2sid_done = TRUE;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Update cache in a single transaction */
71590c90e239661c113497da3ca8b7301dfbe24cnw if (sql_exec_no_cb(cache, IDMAP_CACHENAME, "BEGIN TRANSACTION;")
71590c90e239661c113497da3ca8b7301dfbe24cnw != IDMAP_SUCCESS)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw for (i = 0; i < batch.idmap_mapping_batch_len; i++) {
62c6006265c37877b7a5b3c8ffce913ef559b955baban state.curpos = i;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (IS_BATCH_SID(batch, i)) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) update_cache_sid2pid(
cd37da7426f0c49c14ad9a8a07638ca971477566nw &state,
cd37da7426f0c49c14ad9a8a07638ca971477566nw cache,
cd37da7426f0c49c14ad9a8a07638ca971477566nw &batch.idmap_mapping_batch_val[i],
cd37da7426f0c49c14ad9a8a07638ca971477566nw &result->ids.ids_val[i]);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw } else if ((IS_BATCH_UID(batch, i)) ||
cd37da7426f0c49c14ad9a8a07638ca971477566nw (IS_BATCH_GID(batch, i))) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) update_cache_pid2sid(
cd37da7426f0c49c14ad9a8a07638ca971477566nw &state,
cd37da7426f0c49c14ad9a8a07638ca971477566nw cache,
cd37da7426f0c49c14ad9a8a07638ca971477566nw &batch.idmap_mapping_batch_val[i],
cd37da7426f0c49c14ad9a8a07638ca971477566nw &result->ids.ids_val[i]);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* Commit if we have at least one successful update */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (state.sid2pid_done == FALSE || state.pid2sid_done == FALSE)
71590c90e239661c113497da3ca8b7301dfbe24cnw (void) sql_exec_no_cb(cache, IDMAP_CACHENAME,
71590c90e239661c113497da3ca8b7301dfbe24cnw "COMMIT TRANSACTION;");
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw else
71590c90e239661c113497da3ca8b7301dfbe24cnw (void) sql_exec_no_cb(cache, IDMAP_CACHENAME,
71590c90e239661c113497da3ca8b7301dfbe24cnw "END TRANSACTION;");
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwout:
e8c27ec857e6e2db8c4fe56938b70a89b5bed9f3baban cleanup_lookup_state(&state);
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 result->retcode = idmap_stat4prot(result->retcode);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (TRUE);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw}
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/* ARGSUSED */
cd37da7426f0c49c14ad9a8a07638ca971477566nwstatic
cd37da7426f0c49c14ad9a8a07638ca971477566nwint
cd37da7426f0c49c14ad9a8a07638ca971477566nwlist_mappings_cb(void *parg, int argc, char **argv, char **colnames)
cd37da7426f0c49c14ad9a8a07638ca971477566nw{
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw list_cb_data_t *cb_data;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw char *str;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmap_mappings_res *result;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmap_retcode retcode;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw int w2u, u2w;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw char *end;
cd37da7426f0c49c14ad9a8a07638ca971477566nw static int validated_column_names = 0;
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp idmap_how *how;
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp cb_data = (list_cb_data_t *)parg;
cd37da7426f0c49c14ad9a8a07638ca971477566nw
cd37da7426f0c49c14ad9a8a07638ca971477566nw if (!validated_column_names) {
cd37da7426f0c49c14ad9a8a07638ca971477566nw assert(strcmp(colnames[0], "rowid") == 0);
cd37da7426f0c49c14ad9a8a07638ca971477566nw assert(strcmp(colnames[1], "sidprefix") == 0);
cd37da7426f0c49c14ad9a8a07638ca971477566nw assert(strcmp(colnames[2], "rid") == 0);
cd37da7426f0c49c14ad9a8a07638ca971477566nw assert(strcmp(colnames[3], "pid") == 0);
cd37da7426f0c49c14ad9a8a07638ca971477566nw assert(strcmp(colnames[4], "w2u") == 0);
cd37da7426f0c49c14ad9a8a07638ca971477566nw assert(strcmp(colnames[5], "u2w") == 0);
cd37da7426f0c49c14ad9a8a07638ca971477566nw assert(strcmp(colnames[6], "windomain") == 0);
cd37da7426f0c49c14ad9a8a07638ca971477566nw assert(strcmp(colnames[7], "canon_winname") == 0);
cd37da7426f0c49c14ad9a8a07638ca971477566nw assert(strcmp(colnames[8], "unixname") == 0);
cd37da7426f0c49c14ad9a8a07638ca971477566nw assert(strcmp(colnames[9], "is_user") == 0);
cd37da7426f0c49c14ad9a8a07638ca971477566nw assert(strcmp(colnames[10], "is_wuser") == 0);
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp assert(strcmp(colnames[11], "map_type") == 0);
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp assert(strcmp(colnames[12], "map_dn") == 0);
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp assert(strcmp(colnames[13], "map_attr") == 0);
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp assert(strcmp(colnames[14], "map_value") == 0);
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp assert(strcmp(colnames[15], "map_windomain") == 0);
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp assert(strcmp(colnames[16], "map_winname") == 0);
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp assert(strcmp(colnames[17], "map_unixname") == 0);
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp assert(strcmp(colnames[18], "map_is_nt4") == 0);
cd37da7426f0c49c14ad9a8a07638ca971477566nw validated_column_names = 1;
cd37da7426f0c49c14ad9a8a07638ca971477566nw }
cd37da7426f0c49c14ad9a8a07638ca971477566nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result = (idmap_mappings_res *)cb_data->result;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp _VALIDATE_LIST_CB_DATA(19, &result->mappings.mappings_val,
cd37da7426f0c49c14ad9a8a07638ca971477566nw 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 =
cd37da7426f0c49c14ad9a8a07638ca971477566nw str;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->mappings.mappings_val[cb_data->next].id1.idmap_id_u.sid.rid =
cd37da7426f0c49c14ad9a8a07638ca971477566nw strtoul(argv[2], &end, 10);
cd37da7426f0c49c14ad9a8a07638ca971477566nw result->mappings.mappings_val[cb_data->next].id1.idtype =
cd37da7426f0c49c14ad9a8a07638ca971477566nw strtol(argv[10], &end, 10) ? IDMAP_USID : IDMAP_GSID;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->mappings.mappings_val[cb_data->next].id2.idmap_id_u.uid =
cd37da7426f0c49c14ad9a8a07638ca971477566nw strtoul(argv[3], &end, 10);
cd37da7426f0c49c14ad9a8a07638ca971477566nw result->mappings.mappings_val[cb_data->next].id2.idtype =
cd37da7426f0c49c14ad9a8a07638ca971477566nw strtol(argv[9], &end, 10) ? IDMAP_UID : IDMAP_GID;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
cd37da7426f0c49c14ad9a8a07638ca971477566nw w2u = argv[4] ? strtol(argv[4], &end, 10) : 0;
cd37da7426f0c49c14ad9a8a07638ca971477566nw 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
8e22821528b08c6dba4e8176351560f316f6d0dedm STRDUP_OR_FAIL(result->mappings.mappings_val[cb_data->next].id1domain,
8e22821528b08c6dba4e8176351560f316f6d0dedm argv[6]);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
8e22821528b08c6dba4e8176351560f316f6d0dedm STRDUP_OR_FAIL(result->mappings.mappings_val[cb_data->next].id1name,
8e22821528b08c6dba4e8176351560f316f6d0dedm argv[7]);
8e22821528b08c6dba4e8176351560f316f6d0dedm
8e22821528b08c6dba4e8176351560f316f6d0dedm STRDUP_OR_FAIL(result->mappings.mappings_val[cb_data->next].id2name,
8e22821528b08c6dba4e8176351560f316f6d0dedm argv[8]);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp if (cb_data->flag & IDMAP_REQ_FLG_MAPPING_INFO) {
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp how = &result->mappings.mappings_val[cb_data->next].info.how;
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp how->map_type = strtoul(argv[11], &end, 10);
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp switch (how->map_type) {
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp case IDMAP_MAP_TYPE_DS_AD:
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp how->idmap_how_u.ad.dn =
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp strdup(argv[12]);
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp how->idmap_how_u.ad.attr =
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp strdup(argv[13]);
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp how->idmap_how_u.ad.value =
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp strdup(argv[14]);
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp break;
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp case IDMAP_MAP_TYPE_DS_NLDAP:
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp how->idmap_how_u.nldap.dn =
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp strdup(argv[12]);
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp how->idmap_how_u.nldap.attr =
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp strdup(argv[13]);
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp how->idmap_how_u.nldap.value =
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp strdup(argv[14]);
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp break;
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp case IDMAP_MAP_TYPE_RULE_BASED:
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp how->idmap_how_u.rule.windomain =
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp strdup(argv[15]);
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp how->idmap_how_u.rule.winname =
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp strdup(argv[16]);
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp how->idmap_how_u.rule.unixname =
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp strdup(argv[17]);
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp how->idmap_how_u.rule.is_nt4 =
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp strtoul(argv[18], &end, 10);
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp how->idmap_how_u.rule.is_user =
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp strtol(argv[9], &end, 10);
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp how->idmap_how_u.rule.is_wuser =
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp strtol(argv[10], &end, 10);
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp break;
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp case IDMAP_MAP_TYPE_EPHEMERAL:
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp break;
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp case IDMAP_MAP_TYPE_LOCAL_SID:
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp break;
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp default:
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp /* Unknow mapping type */
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp assert(FALSE);
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp }
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp }
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
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejpidmap_list_mappings_1_svc(int64_t lastrowid, uint64_t limit, int32_t flag,
cd37da7426f0c49c14ad9a8a07638ca971477566nw idmap_mappings_res *result, struct svc_req *rqstp)
cd37da7426f0c49c14ad9a8a07638ca971477566nw{
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw sqlite *cache = NULL;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw char lbuf[30], rbuf[30];
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw uint64_t maxlimit;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmap_retcode retcode;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw char *sql = NULL;
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp time_t curtime;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) memset(result, 0, sizeof (*result));
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw lbuf[0] = rbuf[0] = 0;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp /* Current time */
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp errno = 0;
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp if ((curtime = time(NULL)) == (time_t)-1) {
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp idmapdlog(LOG_ERR, "Failed to get current time (%s)",
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp strerror(errno));
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp retcode = IDMAP_ERR_INTERNAL;
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp goto out;
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp }
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp
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),
cd37da7426f0c49c14ad9a8a07638ca971477566nw "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 */
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp sql = sqlite_mprintf("SELECT rowid, sidprefix, rid, pid, w2u, "
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp "u2w, windomain, canon_winname, unixname, is_user, is_wuser, "
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp "map_type, map_dn, map_attr, map_value, map_windomain, "
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp "map_winname, map_unixname, map_is_nt4 "
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp "FROM idmap_cache WHERE %s AND "
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp "(pid >= 2147483648 OR (expiration = 0 OR "
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp "expiration ISNULL OR expiration > %d)) "
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp "%s;",
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp rbuf, curtime, 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 */
71590c90e239661c113497da3ca8b7301dfbe24cnw PROCESS_LIST_SVC_SQL(retcode, cache, IDMAP_CACHENAME, sql, limit,
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp flag, list_mappings_cb, 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 result->retcode = idmap_stat4prot(result->retcode);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (TRUE);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw}
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/* ARGSUSED */
cd37da7426f0c49c14ad9a8a07638ca971477566nwstatic
cd37da7426f0c49c14ad9a8a07638ca971477566nwint
cd37da7426f0c49c14ad9a8a07638ca971477566nwlist_namerules_cb(void *parg, int argc, char **argv, char **colnames)
cd37da7426f0c49c14ad9a8a07638ca971477566nw{
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw list_cb_data_t *cb_data;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmap_namerules_res *result;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmap_retcode retcode;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw int w2u_order, u2w_order;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw char *end;
cd37da7426f0c49c14ad9a8a07638ca971477566nw static int validated_column_names = 0;
cd37da7426f0c49c14ad9a8a07638ca971477566nw
cd37da7426f0c49c14ad9a8a07638ca971477566nw if (!validated_column_names) {
cd37da7426f0c49c14ad9a8a07638ca971477566nw assert(strcmp(colnames[0], "rowid") == 0);
cd37da7426f0c49c14ad9a8a07638ca971477566nw assert(strcmp(colnames[1], "is_user") == 0);
cd37da7426f0c49c14ad9a8a07638ca971477566nw assert(strcmp(colnames[2], "is_wuser") == 0);
cd37da7426f0c49c14ad9a8a07638ca971477566nw assert(strcmp(colnames[3], "windomain") == 0);
cd37da7426f0c49c14ad9a8a07638ca971477566nw assert(strcmp(colnames[4], "winname_display") == 0);
cd37da7426f0c49c14ad9a8a07638ca971477566nw assert(strcmp(colnames[5], "is_nt4") == 0);
cd37da7426f0c49c14ad9a8a07638ca971477566nw assert(strcmp(colnames[6], "unixname") == 0);
cd37da7426f0c49c14ad9a8a07638ca971477566nw assert(strcmp(colnames[7], "w2u_order") == 0);
cd37da7426f0c49c14ad9a8a07638ca971477566nw assert(strcmp(colnames[8], "u2w_order") == 0);
cd37da7426f0c49c14ad9a8a07638ca971477566nw validated_column_names = 1;
cd37da7426f0c49c14ad9a8a07638ca971477566nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw cb_data = (list_cb_data_t *)parg;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result = (idmap_namerules_res *)cb_data->result;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
cd37da7426f0c49c14ad9a8a07638ca971477566nw _VALIDATE_LIST_CB_DATA(9, &result->rules.rules_val,
cd37da7426f0c49c14ad9a8a07638ca971477566nw sizeof (idmap_namerule));
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->rules.rules_len++;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->rules.rules_val[cb_data->next].is_user =
cd37da7426f0c49c14ad9a8a07638ca971477566nw strtol(argv[1], &end, 10);
cd37da7426f0c49c14ad9a8a07638ca971477566nw
cd37da7426f0c49c14ad9a8a07638ca971477566nw result->rules.rules_val[cb_data->next].is_wuser =
cd37da7426f0c49c14ad9a8a07638ca971477566nw strtol(argv[2], &end, 10);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
8e22821528b08c6dba4e8176351560f316f6d0dedm STRDUP_OR_FAIL(result->rules.rules_val[cb_data->next].windomain,
cd37da7426f0c49c14ad9a8a07638ca971477566nw argv[3]);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
8e22821528b08c6dba4e8176351560f316f6d0dedm STRDUP_OR_FAIL(result->rules.rules_val[cb_data->next].winname,
cd37da7426f0c49c14ad9a8a07638ca971477566nw argv[4]);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->rules.rules_val[cb_data->next].is_nt4 =
cd37da7426f0c49c14ad9a8a07638ca971477566nw strtol(argv[5], &end, 10);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
8e22821528b08c6dba4e8176351560f316f6d0dedm STRDUP_OR_FAIL(result->rules.rules_val[cb_data->next].unixname,
cd37da7426f0c49c14ad9a8a07638ca971477566nw argv[6]);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
cd37da7426f0c49c14ad9a8a07638ca971477566nw w2u_order = argv[7] ? strtol(argv[7], &end, 10) : 0;
cd37da7426f0c49c14ad9a8a07638ca971477566nw u2w_order = argv[8] ? strtol(argv[8], &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,
cd37da7426f0c49c14ad9a8a07638ca971477566nw struct svc_req *rqstp)
cd37da7426f0c49c14ad9a8a07638ca971477566nw{
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw sqlite *db = NULL;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw char w2ubuf[15], u2wbuf[15];
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw char lbuf[30], rbuf[30];
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw char *sql = NULL;
cd37da7426f0c49c14ad9a8a07638ca971477566nw char *expr = NULL;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw uint64_t maxlimit;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmap_retcode retcode;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) memset(result, 0, sizeof (*result));
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw lbuf[0] = rbuf[0] = 0;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
0dcc71495bad040a0c83830efc85acf8d897350dnw result->retcode = validate_rule(&rule);
0dcc71495bad040a0c83830efc85acf8d897350dnw if (result->retcode != IDMAP_SUCCESS)
0dcc71495bad040a0c83830efc85acf8d897350dnw goto out;
0dcc71495bad040a0c83830efc85acf8d897350dnw
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
cd37da7426f0c49c14ad9a8a07638ca971477566nw w2ubuf[0] = u2wbuf[0] = 0;
cd37da7426f0c49c14ad9a8a07638ca971477566nw 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),
cd37da7426f0c49c14ad9a8a07638ca971477566nw "AND (u2w_order = 0 OR u2w_order ISNULL)");
651c0131ccc65381cbda174bee44a4fd7a518d6bbaban } else if (rule.direction == IDMAP_DIRECTION_U2W) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) snprintf(w2ubuf, sizeof (w2ubuf),
cd37da7426f0c49c14ad9a8a07638ca971477566nw "AND (w2u_order = 0 OR w2u_order ISNULL)");
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) snprintf(u2wbuf, sizeof (u2wbuf), "AND u2w_order > 0");
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
0dcc71495bad040a0c83830efc85acf8d897350dnw result->retcode = gen_sql_expr_from_rule(&rule, &expr);
0dcc71495bad040a0c83830efc85acf8d897350dnw if (result->retcode != IDMAP_SUCCESS)
cd37da7426f0c49c14ad9a8a07638ca971477566nw goto out;
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),
cd37da7426f0c49c14ad9a8a07638ca971477566nw "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 */
cd37da7426f0c49c14ad9a8a07638ca971477566nw sql = sqlite_mprintf("SELECT rowid, is_user, is_wuser, windomain, "
cd37da7426f0c49c14ad9a8a07638ca971477566nw "winname_display, is_nt4, unixname, w2u_order, u2w_order "
cd37da7426f0c49c14ad9a8a07638ca971477566nw "FROM namerules WHERE "
cd37da7426f0c49c14ad9a8a07638ca971477566nw " %s %s %s %s %s;",
cd37da7426f0c49c14ad9a8a07638ca971477566nw rbuf, expr, w2ubuf, u2wbuf, lbuf);
cd37da7426f0c49c14ad9a8a07638ca971477566nw
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 */
71590c90e239661c113497da3ca8b7301dfbe24cnw PROCESS_LIST_SVC_SQL(retcode, db, IDMAP_DBNAME, sql, limit,
48258c6b4e17f36ab09fba0bd6307d1fec9dcbcejp 0, list_namerules_cb, result, result->rules.rules_len);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwout:
cd37da7426f0c49c14ad9a8a07638ca971477566nw if (expr)
cd37da7426f0c49c14ad9a8a07638ca971477566nw sqlite_freemem(expr);
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 result->retcode = idmap_stat4prot(result->retcode);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (TRUE);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw}
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#define IDMAP_RULES_AUTH "solaris.admin.idmap.rules"
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwstatic int
cd37da7426f0c49c14ad9a8a07638ca971477566nwverify_rules_auth(struct svc_req *rqstp)
cd37da7426f0c49c14ad9a8a07638ca971477566nw{
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw ucred_t *uc = NULL;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw uid_t uid;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw char buf[1024];
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw struct passwd pwd;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (svc_getcallerucred(rqstp->rq_xprt, &uc) != 0) {
71590c90e239661c113497da3ca8b7301dfbe24cnw idmapdlog(LOG_ERR, "svc_getcallerucred failed during "
71590c90e239661c113497da3ca8b7301dfbe24cnw "authorization (%s)", strerror(errno));
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (-1);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw uid = ucred_geteuid(uc);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (uid == (uid_t)-1) {
71590c90e239661c113497da3ca8b7301dfbe24cnw idmapdlog(LOG_ERR, "ucred_geteuid failed during "
71590c90e239661c113497da3ca8b7301dfbe24cnw "authorization (%s)", strerror(errno));
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw ucred_free(uc);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (-1);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (getpwuid_r(uid, &pwd, buf, sizeof (buf)) == NULL) {
71590c90e239661c113497da3ca8b7301dfbe24cnw idmapdlog(LOG_ERR, "getpwuid_r(%u) failed during "
71590c90e239661c113497da3ca8b7301dfbe24cnw "authorization (%s)", uid, strerror(errno));
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw ucred_free(uc);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (-1);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (chkauthattr(IDMAP_RULES_AUTH, pwd.pw_name) != 1) {
71590c90e239661c113497da3ca8b7301dfbe24cnw idmapdlog(LOG_INFO, "%s is not authorized (%s)",
71590c90e239661c113497da3ca8b7301dfbe24cnw pwd.pw_name, IDMAP_RULES_AUTH);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw ucred_free(uc);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (-1);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw ucred_free(uc);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (1);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw}
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
8e22821528b08c6dba4e8176351560f316f6d0dedm/*
8e22821528b08c6dba4e8176351560f316f6d0dedm * Meaning of the return values is the following: For retcode ==
8e22821528b08c6dba4e8176351560f316f6d0dedm * IDMAP_SUCCESS, everything went OK and error_index is
8e22821528b08c6dba4e8176351560f316f6d0dedm * undefined. Otherwise, error_index >=0 shows the failed batch
8e22821528b08c6dba4e8176351560f316f6d0dedm * element. errro_index == -1 indicates failure at the beginning,
8e22821528b08c6dba4e8176351560f316f6d0dedm * error_index == -2 at the end.
8e22821528b08c6dba4e8176351560f316f6d0dedm */
8e22821528b08c6dba4e8176351560f316f6d0dedm
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/* ARGSUSED */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwbool_t
8e22821528b08c6dba4e8176351560f316f6d0dedmidmap_update_1_svc(idmap_update_batch batch, idmap_update_res *res,
cd37da7426f0c49c14ad9a8a07638ca971477566nw struct svc_req *rqstp)
cd37da7426f0c49c14ad9a8a07638ca971477566nw{
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw sqlite *db = NULL;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw idmap_update_op *up;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw int i;
84decf41e1c0970e397cc8710dfcf81db5b8c6dajp int trans = FALSE;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
8e22821528b08c6dba4e8176351560f316f6d0dedm res->error_index = -1;
8e22821528b08c6dba4e8176351560f316f6d0dedm (void) memset(&res->error_rule, 0, sizeof (res->error_rule));
8e22821528b08c6dba4e8176351560f316f6d0dedm (void) memset(&res->conflict_rule, 0, sizeof (res->conflict_rule));
8e22821528b08c6dba4e8176351560f316f6d0dedm
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (verify_rules_auth(rqstp) < 0) {
8e22821528b08c6dba4e8176351560f316f6d0dedm res->retcode = IDMAP_ERR_PERMISSION_DENIED;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw if (batch.idmap_update_batch_len == 0 ||
cd37da7426f0c49c14ad9a8a07638ca971477566nw batch.idmap_update_batch_val == NULL) {
8e22821528b08c6dba4e8176351560f316f6d0dedm res->retcode = IDMAP_SUCCESS;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
0dcc71495bad040a0c83830efc85acf8d897350dnw res->retcode = validate_rules(&batch);
0dcc71495bad040a0c83830efc85acf8d897350dnw if (res->retcode != IDMAP_SUCCESS)
0dcc71495bad040a0c83830efc85acf8d897350dnw goto out;
0dcc71495bad040a0c83830efc85acf8d897350dnw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Get db handle */
8e22821528b08c6dba4e8176351560f316f6d0dedm res->retcode = get_db_handle(&db);
8e22821528b08c6dba4e8176351560f316f6d0dedm if (res->retcode != IDMAP_SUCCESS)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
71590c90e239661c113497da3ca8b7301dfbe24cnw res->retcode = sql_exec_no_cb(db, IDMAP_DBNAME, "BEGIN TRANSACTION;");
8e22821528b08c6dba4e8176351560f316f6d0dedm if (res->retcode != IDMAP_SUCCESS)
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
84decf41e1c0970e397cc8710dfcf81db5b8c6dajp trans = TRUE;
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:
8e22821528b08c6dba4e8176351560f316f6d0dedm res->retcode = IDMAP_SUCCESS;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw break;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw case OP_ADD_NAMERULE:
8e22821528b08c6dba4e8176351560f316f6d0dedm res->retcode = add_namerule(db,
cd37da7426f0c49c14ad9a8a07638ca971477566nw &up->idmap_update_op_u.rule);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw break;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw case OP_RM_NAMERULE:
8e22821528b08c6dba4e8176351560f316f6d0dedm res->retcode = rm_namerule(db,
cd37da7426f0c49c14ad9a8a07638ca971477566nw &up->idmap_update_op_u.rule);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw break;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw case OP_FLUSH_NAMERULES:
cd37da7426f0c49c14ad9a8a07638ca971477566nw res->retcode = flush_namerules(db);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw break;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw default:
8e22821528b08c6dba4e8176351560f316f6d0dedm res->retcode = IDMAP_ERR_NOTSUPPORTED;
8e22821528b08c6dba4e8176351560f316f6d0dedm break;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw };
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
8e22821528b08c6dba4e8176351560f316f6d0dedm if (res->retcode != IDMAP_SUCCESS) {
8e22821528b08c6dba4e8176351560f316f6d0dedm res->error_index = i;
8e22821528b08c6dba4e8176351560f316f6d0dedm if (up->opnum == OP_ADD_NAMERULE ||
8e22821528b08c6dba4e8176351560f316f6d0dedm up->opnum == OP_RM_NAMERULE) {
8e22821528b08c6dba4e8176351560f316f6d0dedm idmap_stat r2 =
8e22821528b08c6dba4e8176351560f316f6d0dedm idmap_namerule_cpy(&res->error_rule,
cd37da7426f0c49c14ad9a8a07638ca971477566nw &up->idmap_update_op_u.rule);
8e22821528b08c6dba4e8176351560f316f6d0dedm if (r2 != IDMAP_SUCCESS)
8e22821528b08c6dba4e8176351560f316f6d0dedm res->retcode = r2;
8e22821528b08c6dba4e8176351560f316f6d0dedm }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw goto out;
8e22821528b08c6dba4e8176351560f316f6d0dedm }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwout:
84decf41e1c0970e397cc8710dfcf81db5b8c6dajp if (trans) {
8e22821528b08c6dba4e8176351560f316f6d0dedm if (res->retcode == IDMAP_SUCCESS) {
8e22821528b08c6dba4e8176351560f316f6d0dedm res->retcode =
71590c90e239661c113497da3ca8b7301dfbe24cnw sql_exec_no_cb(db, IDMAP_DBNAME,
71590c90e239661c113497da3ca8b7301dfbe24cnw "COMMIT TRANSACTION;");
8e22821528b08c6dba4e8176351560f316f6d0dedm if (res->retcode != IDMAP_SUCCESS)
8e22821528b08c6dba4e8176351560f316f6d0dedm res->error_index = -2;
8e22821528b08c6dba4e8176351560f316f6d0dedm }
84decf41e1c0970e397cc8710dfcf81db5b8c6dajp else
71590c90e239661c113497da3ca8b7301dfbe24cnw (void) sql_exec_no_cb(db, IDMAP_DBNAME,
71590c90e239661c113497da3ca8b7301dfbe24cnw "ROLLBACK TRANSACTION;");
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw }
8e22821528b08c6dba4e8176351560f316f6d0dedm
8e22821528b08c6dba4e8176351560f316f6d0dedm res->retcode = idmap_stat4prot(res->retcode);
8e22821528b08c6dba4e8176351560f316f6d0dedm
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (TRUE);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw}
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/* ARGSUSED */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwbool_t
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwidmap_get_mapped_id_by_name_1_svc(idmap_mapping request,
cd37da7426f0c49c14ad9a8a07638ca971477566nw idmap_mappings_res *result, struct svc_req *rqstp)
cd37da7426f0c49c14ad9a8a07638ca971477566nw{
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw sqlite *cache = NULL, *db = NULL;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw /* Init */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) memset(result, 0, sizeof (*result));
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
0dcc71495bad040a0c83830efc85acf8d897350dnw result->retcode = validate_mapped_id_by_name_req(&request);
0dcc71495bad040a0c83830efc85acf8d897350dnw if (result->retcode != IDMAP_SUCCESS)
0dcc71495bad040a0c83830efc85acf8d897350dnw goto out;
0dcc71495bad040a0c83830efc85acf8d897350dnw
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
cd37da7426f0c49c14ad9a8a07638ca971477566nw
cd37da7426f0c49c14ad9a8a07638ca971477566nw if (IS_REQUEST_SID(request, 1)) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = get_w2u_mapping(
cd37da7426f0c49c14ad9a8a07638ca971477566nw cache,
cd37da7426f0c49c14ad9a8a07638ca971477566nw db,
cd37da7426f0c49c14ad9a8a07638ca971477566nw &request,
cd37da7426f0c49c14ad9a8a07638ca971477566nw result->mappings.mappings_val);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw } else if (IS_REQUEST_UID(request)) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = get_u2w_mapping(
cd37da7426f0c49c14ad9a8a07638ca971477566nw cache,
cd37da7426f0c49c14ad9a8a07638ca971477566nw db,
cd37da7426f0c49c14ad9a8a07638ca971477566nw &request,
cd37da7426f0c49c14ad9a8a07638ca971477566nw result->mappings.mappings_val,
cd37da7426f0c49c14ad9a8a07638ca971477566nw 1);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw } else if (IS_REQUEST_GID(request)) {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw result->retcode = get_u2w_mapping(
cd37da7426f0c49c14ad9a8a07638ca971477566nw cache,
cd37da7426f0c49c14ad9a8a07638ca971477566nw db,
cd37da7426f0c49c14ad9a8a07638ca971477566nw &request,
cd37da7426f0c49c14ad9a8a07638ca971477566nw result->mappings.mappings_val,
cd37da7426f0c49c14ad9a8a07638ca971477566nw 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 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,
cd37da7426f0c49c14ad9a8a07638ca971477566nw caddr_t result)
cd37da7426f0c49c14ad9a8a07638ca971477566nw{
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw (void) xdr_free(xdr_result, result);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw return (TRUE);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw}