4 * nfs idmapping library, primarily for nfs4 client/server kernel idmapping
5 * and for userland nfs4 idmapping by acl libraries.
7 * Copyright (c) 2004 The Regents of the University of Michigan.
10 * Andy Adamson <andros@umich.edu>
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. Neither the name of the University nor the names of its
22 * contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
26 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
32 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 * libtest: Test the translation table functions
40 * Reads /etc/idmapd.conf
43 * gcc -g libtest.c -lnfsidmap -o libtest
49 #include <sys/types.h>
52 #define QUIT_ON_ERROR 1
53 #define PATH_IDMAPDCONF "/etc/idmapd.conf"
54 char *conf_path
= PATH_IDMAPDCONF
;
56 main(int ac
, char **av
)
59 int err
, uid
= 0, gid
= 0;
65 printf("Usage: %s <user@nfsv4domain> <k5princ@REALM>\n",av
[0]);
69 nfs4_set_debug(3, NULL
);
73 err
= nfs4_init_name_mapping(NULL
);
75 printf("nfs4_init_name_mapping: error %d\n", err
);
79 err
= nfs4_gss_princ_to_ids("krb5", princ
, &uid
, &gid
);
81 printf("nfs4_gss_princ_to_ids: error %d\n", err
);
83 printf("nfs4_gss_princ_to_ids: princ %s has uid %d gid %d\n",
87 printf("calling it quits!\n");
92 err
= nfs4_name_to_uid(name
, &uid
);
94 printf("nfs4_name_to_uid: error %d\n", err
);
96 printf("nfs4_name_to_uid: name %s has uid %d\n",
101 printf("calling it quits!\n");
105 err
= nfs4_name_to_gid(name
, &gid
);
107 printf("nfs4_name_to_gid: error %d\n", err
);
109 printf("nfs4_name_to_gid: name %s has gid %d\n",
113 err
= nfs4_gss_princ_to_grouplist("krb5", princ
, gids
, &ngids
);
115 printf(" nfs4_gss_princ_to_grouplist: error %d\n", err
);
117 printf(" nfs4_gss_princ_to_grouplist: princ %s has gids ",
119 for (i
= 0; i
< ngids
; i
++) printf("%d ", gids
[i
]);
125 printf("calling it quits!\n");
129 /* uid is set by nfs4_name_to_uid() */
130 memset(name_buf
, 0, 32);
131 err
= nfs4_uid_to_name(uid
, NULL
, name_buf
, 32);
133 printf("nfs4_uid_to_name: error %d\n", err
);
135 printf("nfs4_uid_to_name: uid %d has name %s\n",
140 printf("calling it quits!\n");
144 /* gid is set by nfs4_name_to_gid() */
145 memset(name_buf
, 0, 32);
146 err
= nfs4_gid_to_name(gid
, NULL
, name_buf
, 32);
148 printf("nfs4_gid_to_name: error %d\n", err
);
150 printf("nfs4_gid_to_name: gid %d has name %s\n",
155 printf("calling it quits!\n");