s3:dbwrap: change dbwrap_store_int32() to NTSTATUS return type
[kai/samba.git] / source3 / utils / net_idmap.c
1 /*
2    Samba Unix/Linux SMB client library
3    Distributed SMB/CIFS Server Management Utility
4    Copyright (C) 2003 Andrew Bartlett (abartlet@samba.org)
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "includes.h"
21 #include "system/filesys.h"
22 #include "utils/net.h"
23 #include "secrets.h"
24 #include "idmap.h"
25 #include "dbwrap/dbwrap.h"
26 #include "dbwrap/dbwrap_open.h"
27 #include "../libcli/security/security.h"
28 #include "net_idmap_check.h"
29 #include "util_tdb.h"
30
31 #define ALLOC_CHECK(mem) do { \
32         if (!mem) { \
33                 d_fprintf(stderr, _("Out of memory!\n")); \
34                 talloc_free(ctx); \
35                 return -1; \
36         } } while(0)
37
38 /***********************************************************
39  Helper function for net_idmap_dump. Dump one entry.
40  **********************************************************/
41 static int net_idmap_dump_one_entry(struct db_record *rec,
42                                     void *unused)
43 {
44         TDB_DATA key;
45         TDB_DATA value;
46
47         key = dbwrap_record_get_key(rec);
48         value = dbwrap_record_get_value(rec);
49
50         if (strcmp((char *)key.dptr, "USER HWM") == 0) {
51                 printf(_("USER HWM %d\n"), IVAL(value.dptr,0));
52                 return 0;
53         }
54
55         if (strcmp((char *)key.dptr, "GROUP HWM") == 0) {
56                 printf(_("GROUP HWM %d\n"), IVAL(value.dptr,0));
57                 return 0;
58         }
59
60         if (strncmp((char *)key.dptr, "S-", 2) != 0)
61                 return 0;
62
63         printf("%s %s\n", value.dptr, key.dptr);
64         return 0;
65 }
66
67 static const char* net_idmap_dbfile(struct net_context *c)
68 {
69         const char* dbfile = NULL;
70
71         if (c->opt_db != NULL) {
72                 dbfile = talloc_strdup(talloc_tos(), c->opt_db);
73                 if (dbfile == NULL) {
74                         d_fprintf(stderr, _("Out of memory!\n"));
75                 }
76         } else if (strequal(lp_idmap_backend(), "tdb")) {
77                 dbfile = state_path("winbindd_idmap.tdb");
78                 if (dbfile == NULL) {
79                         d_fprintf(stderr, _("Out of memory!\n"));
80                 }
81         } else if (strequal(lp_idmap_backend(), "tdb2")) {
82                 dbfile = lp_parm_talloc_string(-1, "tdb", "idmap2.tdb", NULL);
83                 if (dbfile == NULL) {
84                         dbfile = talloc_asprintf(talloc_tos(), "%s/idmap2.tdb",
85                                                  lp_private_dir());
86                 }
87                 if (dbfile == NULL) {
88                         d_fprintf(stderr, _("Out of memory!\n"));
89                 }
90         } else {
91                 char* backend = talloc_strdup(talloc_tos(), lp_idmap_backend());
92                 char* args = strchr(backend, ':');
93                 if (args != NULL) {
94                         *args = '\0';
95                 }
96
97                 d_printf(_("Sorry, 'idmap backend = %s' is currently not supported\n"),
98                          backend);
99
100                 talloc_free(backend);
101         }
102
103         return dbfile;
104 }
105
106 /***********************************************************
107  Dump the current idmap
108  **********************************************************/
109 static int net_idmap_dump(struct net_context *c, int argc, const char **argv)
110 {
111         struct db_context *db;
112         TALLOC_CTX *mem_ctx;
113         const char* dbfile;
114         NTSTATUS status;
115         int ret = -1;
116
117         if ( argc > 1  || c->display_usage) {
118                 d_printf("%s\n%s",
119                          _("Usage:"),
120                          _("net idmap dump [[--db=]<inputfile>]\n"
121                            "  Dump current ID mapping.\n"
122                            "    inputfile\tTDB file to read mappings from.\n"));
123                 return c->display_usage?0:-1;
124         }
125
126         mem_ctx = talloc_stackframe();
127
128         dbfile = (argc > 0) ? argv[0] : net_idmap_dbfile(c);
129         if (dbfile == NULL) {
130                 goto done;
131         }
132         d_fprintf(stderr, _("dumping id mapping from %s\n"), dbfile);
133
134         db = db_open(mem_ctx, dbfile, 0, TDB_DEFAULT, O_RDONLY, 0);
135         if (db == NULL) {
136                 d_fprintf(stderr, _("Could not open idmap db (%s): %s\n"),
137                           dbfile, strerror(errno));
138                 goto done;
139         }
140
141         status = dbwrap_traverse_read(db, net_idmap_dump_one_entry, NULL, NULL);
142         if (!NT_STATUS_IS_OK(status)) {
143                 d_fprintf(stderr, _("error traversing the database\n"));
144                 ret = -1;
145                 goto done;
146         }
147
148         ret = 0;
149
150 done:
151         talloc_free(mem_ctx);
152         return ret;
153 }
154
155 /***********************************************************
156  Write entries from stdin to current local idmap
157  **********************************************************/
158
159 static int net_idmap_store_id_mapping(struct db_context *db,
160                                       enum id_type type,
161                                       unsigned long idval,
162                                       const char *sid_string)
163 {
164         NTSTATUS status;
165         char *idstr = NULL;
166
167         switch(type) {
168         case ID_TYPE_UID:
169                 idstr = talloc_asprintf(talloc_tos(), "UID %lu", idval);
170                 break;
171         case ID_TYPE_GID:
172                 idstr = talloc_asprintf(talloc_tos(), "GID %lu", idval);
173                 break;
174         default:
175                 d_fprintf(stderr, "Invalid id mapping type: %d\n", type);
176                 return -1;
177         }
178
179         status = dbwrap_store_bystring(db, idstr,
180                                        string_term_tdb_data(sid_string),
181                                        TDB_REPLACE);
182         if (!NT_STATUS_IS_OK(status)) {
183                 d_fprintf(stderr, "Error storing ID -> SID: "
184                          "%s\n", nt_errstr(status));
185                 talloc_free(idstr);
186                 return -1;
187         }
188         status = dbwrap_store_bystring(db, sid_string,
189                                        string_term_tdb_data(idstr),
190                                        TDB_REPLACE);
191         if (!NT_STATUS_IS_OK(status)) {
192                 d_fprintf(stderr, "Error storing SID -> ID: "
193                          "%s\n", nt_errstr(status));
194                 talloc_free(idstr);
195                 return -1;
196         }
197
198         return 0;
199 }
200
201 static int net_idmap_restore(struct net_context *c, int argc, const char **argv)
202 {
203         TALLOC_CTX *mem_ctx;
204         FILE *input = NULL;
205         struct db_context *db;
206         const char *dbfile = NULL;
207         int ret = 0;
208
209         if (c->display_usage) {
210                 d_printf("%s\n%s",
211                          _("Usage:"),
212                          _("net idmap restore [--db=<TDB>] [<inputfile>]\n"
213                            "  Restore ID mappings from file\n"
214                            "    TDB\tFile to store ID mappings to."
215                            "    inputfile\tFile to load ID mappings from. If not "
216                            "given, load data from stdin.\n"));
217                 return 0;
218         }
219
220         mem_ctx = talloc_stackframe();
221
222         dbfile = net_idmap_dbfile(c);
223
224         if (dbfile == NULL) {
225                 ret = -1;
226                 goto done;
227         }
228
229         d_fprintf(stderr, _("restoring id mapping to %s\n"), dbfile);
230
231         if (argc == 1) {
232                 input = fopen(argv[0], "r");
233                 if (input == NULL) {
234                         d_fprintf(stderr, _("Could not open input file (%s): %s\n"),
235                                   argv[0], strerror(errno));
236                         ret = -1;
237                         goto done;
238                 }
239         } else {
240                 input = stdin;
241         }
242
243         db = db_open(mem_ctx, dbfile, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0644);
244         if (db == NULL) {
245                 d_fprintf(stderr, _("Could not open idmap db (%s): %s\n"),
246                           dbfile, strerror(errno));
247                 ret = -1;
248                 goto done;
249         }
250
251         if (dbwrap_transaction_start(db) != 0) {
252                 d_fprintf(stderr, _("Failed to start transaction.\n"));
253                 ret = -1;
254                 goto done;
255         }
256
257         while (!feof(input)) {
258                 char line[128], sid_string[128];
259                 int len;
260                 unsigned long idval;
261                 NTSTATUS status;
262
263                 if (fgets(line, 127, input) == NULL)
264                         break;
265
266                 len = strlen(line);
267
268                 if ( (len > 0) && (line[len-1] == '\n') )
269                         line[len-1] = '\0';
270
271                 if (sscanf(line, "GID %lu %128s", &idval, sid_string) == 2)
272                 {
273                         ret = net_idmap_store_id_mapping(db, ID_TYPE_GID,
274                                                          idval, sid_string);
275                         if (ret != 0) {
276                                 break;
277                         }
278                 } else if (sscanf(line, "UID %lu %128s", &idval, sid_string) == 2)
279                 {
280                         ret = net_idmap_store_id_mapping(db, ID_TYPE_UID,
281                                                          idval, sid_string);
282                         if (ret != 0) {
283                                 break;
284                         }
285                 } else if (sscanf(line, "USER HWM %lu", &idval) == 1) {
286                         status = dbwrap_store_int32(db, "USER HWM", idval);
287                         if (!NT_STATUS_IS_OK(status)) {
288                                 d_fprintf(stderr,
289                                           _("Could not store USER HWM: %s\n"),
290                                           nt_errstr(status));
291                                 break;
292                         }
293                 } else if (sscanf(line, "GROUP HWM %lu", &idval) == 1) {
294                         status = dbwrap_store_int32(db, "GROUP HWM", idval);
295                         if (!NT_STATUS_IS_OK(status)) {
296                                 d_fprintf(stderr,
297                                           _("Could not store GROUP HWM: %s\n"),
298                                           nt_errstr(status));
299                                 break;
300                         }
301                 } else {
302                         d_fprintf(stderr, _("ignoring invalid line [%s]\n"),
303                                   line);
304                         continue;
305                 }
306         }
307
308         if (ret == 0) {
309                 if(dbwrap_transaction_commit(db) != 0) {
310                         d_fprintf(stderr, _("Failed to commit transaction.\n"));
311                         ret = -1;
312                 }
313         } else {
314                 if (dbwrap_transaction_cancel(db) != 0) {
315                         d_fprintf(stderr, _("Failed to cancel transaction.\n"));
316                 }
317         }
318
319 done:
320         if ((input != NULL) && (input != stdin)) {
321                 fclose(input);
322         }
323
324         talloc_free(mem_ctx);
325         return ret;
326 }
327
328 static
329 NTSTATUS dbwrap_delete_mapping(struct db_context *db, TDB_DATA key1, bool force)
330 {
331         TALLOC_CTX* mem_ctx = talloc_tos();
332         struct db_record *rec1=NULL, *rec2=NULL;
333         TDB_DATA key2;
334         bool is_valid_mapping;
335         NTSTATUS status = NT_STATUS_OK;
336         TDB_DATA value;
337
338         rec1 = dbwrap_fetch_locked(db, mem_ctx, key1);
339         if (rec1 == NULL) {
340                 DEBUG(1, ("failed to fetch: %.*s\n", (int)key1.dsize, key1.dptr));
341                 status = NT_STATUS_NO_MEMORY;
342                 goto done;
343         }
344         key2 = dbwrap_record_get_value(rec1);
345         if (key2.dptr == NULL) {
346                 DEBUG(1, ("could not find %.*s\n", (int)key1.dsize, key1.dptr));
347                 status = NT_STATUS_NOT_FOUND;
348                 goto done;
349         }
350
351         DEBUG(2, ("mapping: %.*s -> %.*s\n",
352                   (int)key1.dsize, key1.dptr, (int)key2.dsize, key2.dptr));
353
354         rec2 = dbwrap_fetch_locked(db, mem_ctx, key2);
355         if (rec2 == NULL) {
356                 DEBUG(1, ("failed to fetch: %.*s\n", (int)key2.dsize, key2.dptr));
357                 status = NT_STATUS_NO_MEMORY;
358                 goto done;
359         }
360
361         value = dbwrap_record_get_value(rec2);
362         is_valid_mapping = tdb_data_equal(key1, value);
363
364         if (!is_valid_mapping) {
365                 DEBUG(1, ("invalid mapping: %.*s -> %.*s -> %.*s\n",
366                           (int)key1.dsize, key1.dptr, (int)key2.dsize, key2.dptr,
367                           (int)value.dsize, value.dptr ));
368                 if ( !force ) {
369                         status = NT_STATUS_FILE_INVALID;
370                         goto done;
371                 }
372         }
373
374         status = dbwrap_record_delete(rec1);
375         if (!NT_STATUS_IS_OK(status)) {
376                 DEBUG(1, ("failed to delete: %.*s\n", (int)key1.dsize, key1.dptr));
377                 goto done;
378         }
379
380         if (is_valid_mapping) {
381                 status = dbwrap_record_delete(rec2);
382                 if (!NT_STATUS_IS_OK(status)) {
383                         DEBUG(1, ("failed to delete: %.*s\n", (int)key2.dsize, key2.dptr));
384                 }
385         }
386 done:
387         TALLOC_FREE(rec1);
388         TALLOC_FREE(rec2);
389         return status;
390 }
391
392 static
393 NTSTATUS delete_mapping_action(struct db_context *db, void* data)
394 {
395         return dbwrap_delete_mapping(db, *(TDB_DATA*)data, false);
396 }
397 static
398 NTSTATUS delete_mapping_action_force(struct db_context *db, void* data)
399 {
400         return dbwrap_delete_mapping(db, *(TDB_DATA*)data, true);
401 }
402
403 /***********************************************************
404  Delete a SID mapping from a winbindd_idmap.tdb
405  **********************************************************/
406 static bool delete_args_ok(int argc, const char **argv)
407 {
408         if (argc != 1)
409                 return false;
410         if (strncmp(argv[0], "S-", 2) == 0)
411                 return true;
412         if (strncmp(argv[0], "GID ", 4) == 0)
413                 return true;
414         if (strncmp(argv[0], "UID ", 4) == 0)
415                 return true;
416         return false;
417 }
418
419 static int net_idmap_delete(struct net_context *c, int argc, const char **argv)
420 {
421         int ret = -1;
422         struct db_context *db;
423         TALLOC_CTX *mem_ctx;
424         TDB_DATA key;
425         NTSTATUS status;
426         const char* dbfile;
427
428         if ( !delete_args_ok(argc,argv) || c->display_usage) {
429                 d_printf("%s\n%s",
430                          _("Usage:"),
431                          _("net idmap delete [-f] [--db=<TDB>] <ID>\n"
432                            "  Delete mapping of ID from TDB.\n"
433                            "    -f\tforce\n"
434                            "    TDB\tidmap database\n"
435                            "    ID\tSID|GID|UID\n"));
436                 return c->display_usage ? 0 : -1;
437         }
438
439         mem_ctx = talloc_stackframe();
440
441         dbfile = net_idmap_dbfile(c);
442         if (dbfile == NULL) {
443                 goto done;
444         }
445         d_fprintf(stderr, _("deleting id mapping from %s\n"), dbfile);
446
447         db = db_open(mem_ctx, dbfile, 0, TDB_DEFAULT, O_RDWR, 0);
448         if (db == NULL) {
449                 d_fprintf(stderr, _("Could not open idmap db (%s): %s\n"),
450                           dbfile, strerror(errno));
451                 goto done;
452         }
453
454         key = string_term_tdb_data(argv[0]);
455
456         status = dbwrap_trans_do(db, (c->opt_force
457                                       ? delete_mapping_action_force
458                                       : delete_mapping_action),  &key);
459
460         if (!NT_STATUS_IS_OK(status)) {
461                 d_fprintf(stderr, _("could not delete mapping: %s\n"),
462                           nt_errstr(status));
463                 goto done;
464         }
465         ret = 0;
466 done:
467         talloc_free(mem_ctx);
468         return ret;
469 }
470
471 static int net_idmap_set(struct net_context *c, int argc, const char **argv)
472 {
473         d_printf("%s\n", _("Not implemented yet"));
474         return -1;
475 }
476 static bool idmap_store_secret(const char *backend,
477                                const char *domain,
478                                const char *identity,
479                                const char *secret)
480 {
481         char *tmp;
482         int r;
483         bool ret;
484
485         r = asprintf(&tmp, "IDMAP_%s_%s", backend, domain);
486
487         if (r < 0) return false;
488
489         strupper_m(tmp); /* make sure the key is case insensitive */
490         ret = secrets_store_generic(tmp, identity, secret);
491
492         free(tmp);
493         return ret;
494 }
495
496
497 static int net_idmap_secret(struct net_context *c, int argc, const char **argv)
498 {
499         TALLOC_CTX *ctx;
500         const char *secret;
501         const char *dn;
502         char *domain;
503         char *backend;
504         char *opt = NULL;
505         bool ret;
506
507         if (argc != 2 || c->display_usage) {
508                 d_printf("%s\n%s",
509                          _("Usage:\n"),
510                          _("net idmap secret <DOMAIN> <secret>\n"
511                            "  Set the secret for the specified domain\n"
512                            "    DOMAIN\tDomain to set secret for.\n"
513                            "    secret\tNew secret to set.\n"));
514                 return c->display_usage?0:-1;
515         }
516
517         secret = argv[1];
518
519         ctx = talloc_new(NULL);
520         ALLOC_CHECK(ctx);
521
522         domain = talloc_strdup(ctx, argv[0]);
523         ALLOC_CHECK(domain);
524
525         opt = talloc_asprintf(ctx, "idmap config %s", domain);
526         ALLOC_CHECK(opt);
527
528         backend = talloc_strdup(ctx, lp_parm_const_string(-1, opt, "backend", "tdb"));
529         ALLOC_CHECK(backend);
530
531         if ( ( ! backend) || ( ! strequal(backend, "ldap"))) {
532                 d_fprintf(stderr,
533                           _("The only currently supported backend is LDAP\n"));
534                 talloc_free(ctx);
535                 return -1;
536         }
537
538         dn = lp_parm_const_string(-1, opt, "ldap_user_dn", NULL);
539         if ( ! dn) {
540                 d_fprintf(stderr,
541                           _("Missing ldap_user_dn option for domain %s\n"),
542                           domain);
543                 talloc_free(ctx);
544                 return -1;
545         }
546
547         ret = idmap_store_secret("ldap", domain, dn, secret);
548
549         if ( ! ret) {
550                 d_fprintf(stderr, _("Failed to store secret\n"));
551                 talloc_free(ctx);
552                 return -1;
553         }
554
555         d_printf(_("Secret stored\n"));
556         return 0;
557 }
558
559 static int net_idmap_check(struct net_context *c, int argc, const char **argv)
560 {
561         const char* dbfile;
562         struct check_options opts;
563
564         if ( argc > 1 || c->display_usage) {
565                 d_printf("%s\n%s",
566                          _("Usage:"),
567                          _("net idmap check  [-v] [-r] [-a] [-T] [-f] [-l] [[--db=]<TDB>]\n"
568                            "  Check an idmap database.\n"
569                            "    --verbose,-v\tverbose\n"
570                            "    --repair,-r\trepair\n"
571                            "    --auto,-a\tnoninteractive mode\n"
572                            "    --test,-T\tdry run\n"
573                            "    --fore,-f\tforce\n"
574                            "    --lock,-l\tlock db while doing the check\n"
575                            "    TDB\tidmap database\n"));
576                 return c->display_usage ? 0 : -1;
577         }
578
579         dbfile = (argc > 0) ? argv[0] : net_idmap_dbfile(c);
580         if (dbfile == NULL) {
581                 return -1;
582         }
583         d_fprintf(stderr, _("check database: %s\n"), dbfile);
584
585         opts = (struct check_options) {
586                 .lock = c->opt_lock || c->opt_long_list_entries,
587                 .test = c->opt_testmode,
588                 .automatic = c->opt_auto,
589                 .verbose = c->opt_verbose,
590                 .force = c->opt_force,
591                 .repair = c->opt_repair || c->opt_reboot,
592         };
593
594         return net_idmap_check_db(dbfile, &opts);
595 }
596
597 static int net_idmap_aclmapset(struct net_context *c, int argc, const char **argv)
598 {
599         TALLOC_CTX *mem_ctx;
600         int result = -1;
601         struct dom_sid src_sid, dst_sid;
602         char *src, *dst;
603         struct db_context *db;
604         struct db_record *rec;
605         NTSTATUS status;
606
607         if (argc != 3 || c->display_usage) {
608                 d_fprintf(stderr, "%s net idmap aclmapset <tdb> "
609                           "<src-sid> <dst-sid>\n", _("Usage:"));
610                 return -1;
611         }
612
613         if (!(mem_ctx = talloc_init("net idmap aclmapset"))) {
614                 d_fprintf(stderr, _("talloc_init failed\n"));
615                 return -1;
616         }
617
618         if (!(db = db_open(mem_ctx, argv[0], 0, TDB_DEFAULT,
619                            O_RDWR|O_CREAT, 0600))) {
620                 d_fprintf(stderr, _("db_open failed: %s\n"), strerror(errno));
621                 goto fail;
622         }
623
624         if (!string_to_sid(&src_sid, argv[1])) {
625                 d_fprintf(stderr, _("%s is not a valid sid\n"), argv[1]);
626                 goto fail;
627         }
628
629         if (!string_to_sid(&dst_sid, argv[2])) {
630                 d_fprintf(stderr, _("%s is not a valid sid\n"), argv[2]);
631                 goto fail;
632         }
633
634         if (!(src = sid_string_talloc(mem_ctx, &src_sid))
635             || !(dst = sid_string_talloc(mem_ctx, &dst_sid))) {
636                 d_fprintf(stderr, _("talloc_strdup failed\n"));
637                 goto fail;
638         }
639
640         if (!(rec = dbwrap_fetch_locked(
641                       db, mem_ctx, string_term_tdb_data(src)))) {
642                 d_fprintf(stderr, _("could not fetch db record\n"));
643                 goto fail;
644         }
645
646         status = dbwrap_record_store(rec, string_term_tdb_data(dst), 0);
647         TALLOC_FREE(rec);
648
649         if (!NT_STATUS_IS_OK(status)) {
650                 d_fprintf(stderr, _("could not store record: %s\n"),
651                           nt_errstr(status));
652                 goto fail;
653         }
654
655         result = 0;
656 fail:
657         TALLOC_FREE(mem_ctx);
658         return result;
659 }
660
661 /***********************************************************
662  Look at the current idmap
663  **********************************************************/
664 int net_idmap(struct net_context *c, int argc, const char **argv)
665 {
666         struct functable func[] = {
667                 {
668                         "dump",
669                         net_idmap_dump,
670                         NET_TRANSPORT_LOCAL,
671                         N_("Dump the current ID mappings"),
672                         N_("net idmap dump\n"
673                            "  Dump the current ID mappings")
674                 },
675                 {
676                         "restore",
677                         net_idmap_restore,
678                         NET_TRANSPORT_LOCAL,
679                         N_("Restore entries from stdin"),
680                         N_("net idmap restore\n"
681                            "  Restore entries from stdin")
682                 },
683                 {
684                         "setmap",
685                         net_idmap_set,
686                         NET_TRANSPORT_LOCAL,
687                         N_("Not implemented yet"),
688                         N_("net idmap setmap\n"
689                            "  Not implemented yet")
690                 },
691                 {
692                         "delete",
693                         net_idmap_delete,
694                         NET_TRANSPORT_LOCAL,
695                         N_("Delete ID mapping"),
696                         N_("net idmap delete <ID>\n"
697                            "  Delete ID mapping")
698                 },
699                 {
700                         "secret",
701                         net_idmap_secret,
702                         NET_TRANSPORT_LOCAL,
703                         N_("Set secret for specified domain"),
704                         N_("net idmap secret <DOMAIN> <secret>\n"
705                            "  Set secret for specified domain")
706                 },
707                 {
708                         "aclmapset",
709                         net_idmap_aclmapset,
710                         NET_TRANSPORT_LOCAL,
711                         N_("Set acl map"),
712                         N_("net idmap aclmapset\n"
713                            "  Set acl map")
714                 },
715                 {
716                         "check",
717                         net_idmap_check,
718                         NET_TRANSPORT_LOCAL,
719                         N_("Check id mappings"),
720                         N_("net idmap check\n"
721                            "  Check id mappings")
722                 },
723                 {NULL, NULL, 0, NULL, NULL}
724         };
725
726         return net_run_function(c, argc, argv, "net idmap", func);
727 }
728
729