blob: a98b22a1272a6e8411cdd4c5277f566882c2dd9a [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001/*
2 * Copyright (c) 2015 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#include <stdio.h>
17#include <stdlib.h>
18#include <sys/types.h>
19#include <sys/mman.h>
20#include <sys/stat.h>
Dave Barach98cfc1a2016-07-18 14:23:36 -040021#include <pwd.h>
22#include <grp.h>
Ed Warnickecb9cada2015-12-08 15:45:58 -070023#include <netinet/in.h>
24#include <signal.h>
25#include <pthread.h>
26#include <unistd.h>
27#include <time.h>
28#include <fcntl.h>
29#include <string.h>
30#include <vppinfra/clib.h>
31#include <vppinfra/vec.h>
32#include <vppinfra/hash.h>
33#include <vppinfra/bitmap.h>
34#include <vppinfra/fifo.h>
35#include <vppinfra/time.h>
36#include <vppinfra/mheap.h>
37#include <vppinfra/heap.h>
38#include <vppinfra/pool.h>
39#include <vppinfra/format.h>
40#include <vppinfra/serialize.h>
41#include "svmdb.h"
42
Dave Barach98cfc1a2016-07-18 14:23:36 -040043typedef struct
44{
45 svmdb_map_args_t map_args;
46 int uid, gid;
47 uword size;
48} svmdbtool_main_t;
49
50svmdbtool_main_t svmdbtool_main;
51
Ed Warnicke853e7202016-08-12 11:42:26 -070052static inline svmdb_map_args_t *
53map_arg_setup (char *chroot_path)
Dave Barach98cfc1a2016-07-18 14:23:36 -040054{
55 svmdbtool_main_t *sm = &svmdbtool_main;
56 svmdb_map_args_t *ma = &sm->map_args;
57
58 memset (ma, 0, sizeof (*ma));
59 ma->root_path = chroot_path;
60 ma->size = sm->size;
61 ma->uid = sm->uid;
62 ma->gid = sm->gid;
63 return ma;
64}
65
Dave Barach8a7fb0c2016-07-08 14:44:23 -040066static void
67get_string (char *chroot_path, u8 * vbl)
Ed Warnickecb9cada2015-12-08 15:45:58 -070068{
Dave Barach8a7fb0c2016-07-08 14:44:23 -040069 svmdb_client_t *c;
70 char *rv;
Dave Barach98cfc1a2016-07-18 14:23:36 -040071 svmdb_map_args_t *ma;
Ed Warnickecb9cada2015-12-08 15:45:58 -070072
Dave Barach98cfc1a2016-07-18 14:23:36 -040073 ma = map_arg_setup (chroot_path);
74
75 c = svmdb_map (ma);
Ed Warnickecb9cada2015-12-08 15:45:58 -070076
Dave Barach8a7fb0c2016-07-08 14:44:23 -040077 rv = svmdb_local_get_string_variable (c, (char *) vbl);
78
79 fformat (stdout, "%s\n", rv ? rv : "UNSET");
80 vec_free (rv);
81 svmdb_unmap (c);
Ed Warnickecb9cada2015-12-08 15:45:58 -070082}
83
Dave Barach8a7fb0c2016-07-08 14:44:23 -040084static void
85set_string (char *chroot_path, u8 * vbl, u8 * value)
Ed Warnickecb9cada2015-12-08 15:45:58 -070086{
Dave Barach8a7fb0c2016-07-08 14:44:23 -040087 svmdb_client_t *c;
Dave Barach98cfc1a2016-07-18 14:23:36 -040088 svmdb_map_args_t *ma;
Ed Warnickecb9cada2015-12-08 15:45:58 -070089
Dave Barach98cfc1a2016-07-18 14:23:36 -040090 ma = map_arg_setup (chroot_path);
91
92 c = svmdb_map (ma);
Dave Barach8a7fb0c2016-07-08 14:44:23 -040093 svmdb_local_set_string_variable (c, (char *) vbl, (char *) value);
94 svmdb_unmap (c);
Ed Warnickecb9cada2015-12-08 15:45:58 -070095}
96
Dave Barach8a7fb0c2016-07-08 14:44:23 -040097static void
98unset_string (char *chroot_path, u8 * vbl)
Ed Warnickecb9cada2015-12-08 15:45:58 -070099{
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400100 svmdb_client_t *c;
Dave Barach98cfc1a2016-07-18 14:23:36 -0400101 svmdb_map_args_t *ma;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700102
Dave Barach98cfc1a2016-07-18 14:23:36 -0400103 ma = map_arg_setup (chroot_path);
104
105 c = svmdb_map (ma);
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400106 svmdb_local_unset_string_variable (c, (char *) vbl);
107 svmdb_unmap (c);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700108}
109
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400110static void
111dump_strings (char *chroot_path)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700112{
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400113 svmdb_client_t *c;
Dave Barach98cfc1a2016-07-18 14:23:36 -0400114 svmdb_map_args_t *ma;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700115
Dave Barach98cfc1a2016-07-18 14:23:36 -0400116 ma = map_arg_setup (chroot_path);
117
118 c = svmdb_map (ma);
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400119 svmdb_local_dump_strings (c);
120 svmdb_unmap (c);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700121}
122
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400123static void
124test_vlib_vec_rate (char *chroot_path, f64 vr)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700125{
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400126 svmdb_client_t *c;
127 f64 *tv = 0;
Dave Barach98cfc1a2016-07-18 14:23:36 -0400128 svmdb_map_args_t *ma;
129
130 ma = map_arg_setup (chroot_path);
131
132 c = svmdb_map (ma);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700133
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400134 vec_add1 (tv, vr);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700135
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400136 svmdb_local_set_vec_variable (c, "vlib_vector_rate", (char *) tv,
137 sizeof (*tv));
138 svmdb_unmap (c);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700139
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400140 vec_free (tv);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700141}
142
143
144
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400145static void
146test_vec (char *chroot_path, u8 * vbl)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700147{
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400148 svmdb_client_t *c;
149 u64 *tv = 0;
150 int i;
Dave Barach98cfc1a2016-07-18 14:23:36 -0400151 svmdb_map_args_t *ma;
152
153 ma = map_arg_setup (chroot_path);
154
155 c = svmdb_map (ma);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700156
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400157 /* my amp goes to 11 */
158 for (i = 0; i < 11; i++)
159 {
160 vec_add1 (tv, i);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700161 }
162
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400163 svmdb_local_set_vec_variable (c, (char *) vbl, (char *) tv, sizeof (tv[0]));
164 svmdb_unmap (c);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700165
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400166 vec_free (tv);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700167}
168
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400169static void
170fake_install (char *chroot_path, u8 * add_value)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700171{
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400172 svmdb_client_t *c;
173 u8 *v = 0;
174 u8 **values = 0;
175 u8 *oldvalue;
176 u8 *value;
177 int nitems = 0, i;
178 serialize_main_t m;
Dave Barach98cfc1a2016-07-18 14:23:36 -0400179 svmdb_map_args_t *ma;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700180
Dave Barach98cfc1a2016-07-18 14:23:36 -0400181 ma = map_arg_setup (chroot_path);
182
183 c = svmdb_map (ma);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700184
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400185 oldvalue = svmdb_local_get_vec_variable (c, "installed_sw", 1);
186 if (oldvalue)
187 {
188 unserialize_open_data (&m, oldvalue, vec_len (oldvalue));
189 nitems = unserialize_likely_small_unsigned_integer (&m);
190 for (i = 0; i < nitems; i++)
191 {
192 unserialize_cstring (&m, (char **) &value);
193 vec_add1 (values, value);
194 }
195 vec_free (v);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700196 }
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400197 nitems++;
198 value = format (0, "%s%c", add_value, 0);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700199
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400200 vec_add1 (values, value);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700201
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400202 fformat (stdout, "Resulting installed_sw vector:\n");
Ed Warnickecb9cada2015-12-08 15:45:58 -0700203
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400204 serialize_open_vector (&m, v);
205 serialize_likely_small_unsigned_integer (&m, vec_len (values));
206 for (i = 0; i < vec_len (values); i++)
207 {
208 fformat (stdout, "%s\n", values[i]);
209 serialize_cstring (&m, (char *) values[i]);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700210 }
211
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400212 v = serialize_close_vector (&m);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700213
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400214 svmdb_local_set_vec_variable (c, "installed_sw", v, sizeof (v[0]));
215 svmdb_unmap (c);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700216
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400217 for (i = 0; i < vec_len (values); i++)
218 vec_free (values[i]);
219 vec_free (values);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700220}
221
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400222static void
223sigaction_handler (int signum, siginfo_t * i, void *notused)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700224{
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400225 u32 action, opaque;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700226
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400227 action = (u32) (uword) i->si_ptr;
228 action >>= 28;
229 opaque = (u32) (uword) i->si_ptr;
230 opaque &= ~(0xF0000000);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700231
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400232 clib_warning ("signal %d, action %d, opaque %x", signum, action, opaque);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700233}
234
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400235static void
236test_reg (char *chroot_path, u8 * vbl)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700237{
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400238 svmdb_client_t *c;
239 svmdb_notification_args_t args;
240 svmdb_notification_args_t *a = &args;
241 struct sigaction sa;
Dave Barach98cfc1a2016-07-18 14:23:36 -0400242 svmdb_map_args_t *ma;
243
244 ma = map_arg_setup (chroot_path);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700245
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400246 memset (&sa, 0, sizeof (sa));
247 sa.sa_sigaction = sigaction_handler;
248 sa.sa_flags = SA_SIGINFO;
249 if (sigaction (SIGUSR2, &sa, 0) < 0)
250 {
251 clib_unix_warning ("sigaction");
252 return;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700253 }
254
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400255 memset (a, 0, sizeof (*a));
Ed Warnickecb9cada2015-12-08 15:45:58 -0700256
Dave Barach98cfc1a2016-07-18 14:23:36 -0400257 c = svmdb_map (ma);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700258
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400259 a->add_del = 1 /* add */ ;
260 a->nspace = SVMDB_NAMESPACE_STRING;
261 a->var = (char *) vbl;
262 a->elsize = 1;
263 a->signum = SIGUSR2;
264 a->action = SVMDB_ACTION_GET;
265 a->opaque = 0x0eadbeef;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700266
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400267 svmdb_local_add_del_notification (c, a);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700268
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400269 (void) svmdb_local_get_string_variable (c, (char *) vbl);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700270
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400271 a->add_del = 0; /* del */
272 svmdb_local_add_del_notification (c, a);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700273
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400274
275
276 svmdb_unmap (c);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700277}
278
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400279static void
280unset_vec (char *chroot_path, u8 * vbl)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700281{
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400282 svmdb_client_t *c;
Dave Barach98cfc1a2016-07-18 14:23:36 -0400283 svmdb_map_args_t *ma;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700284
Dave Barach98cfc1a2016-07-18 14:23:36 -0400285 ma = map_arg_setup (chroot_path);
286
287 c = svmdb_map (ma);
288
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400289 svmdb_local_unset_vec_variable (c, (char *) vbl);
290 svmdb_unmap (c);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700291}
292
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400293static void
294dump_vecs (char *chroot_path)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700295{
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400296 svmdb_client_t *c;
Dave Barach98cfc1a2016-07-18 14:23:36 -0400297 svmdb_map_args_t *ma;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700298
Dave Barach98cfc1a2016-07-18 14:23:36 -0400299 ma = map_arg_setup (chroot_path);
300
301 c = svmdb_map (ma);
302
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400303 svmdb_local_dump_vecs (c);
304 svmdb_unmap (c);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700305}
306
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400307static void
308crash_test (char *chroot_path)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700309{
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400310 svmdb_client_t *c;
Dave Barach98cfc1a2016-07-18 14:23:36 -0400311 svmdb_map_args_t *ma;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700312
Dave Barach98cfc1a2016-07-18 14:23:36 -0400313 ma = map_arg_setup (chroot_path);
314
315 c = svmdb_map (ma);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700316
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400317 clib_warning ("Grab region mutex and crash deliberately!");
318 c->db_rp->mutex_owner_pid = getpid ();
319 c->db_rp->mutex_owner_tag = -13;
320 pthread_mutex_lock (&c->db_rp->mutex);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700321
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400322 abort ();
Ed Warnickecb9cada2015-12-08 15:45:58 -0700323}
324
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400325static void
326map_with_size (char *chroot_path, uword size)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700327{
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400328 svmdb_client_t *c;
Dave Barach98cfc1a2016-07-18 14:23:36 -0400329 svmdb_map_args_t *ma;
330
331 svmdbtool_main.size = size;
332 ma = map_arg_setup (chroot_path);
333
334 c = svmdb_map (ma);
335
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400336 svmdb_unmap (c);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700337}
338
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400339int
340main (int argc, char **argv)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700341{
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400342 unformat_input_t input;
343 int parsed = 0;
344 u8 *vbl = 0, *value = 0;
345 char *chroot_path = 0;
346 u8 *chroot_path_u8;
347 uword size;
348 f64 vr;
Dave Barach98cfc1a2016-07-18 14:23:36 -0400349 int uid, gid, rv;
350 struct passwd _pw, *pw;
351 struct group _grp, *grp;
352 char *s, buf[128];
353
Ed Warnicke853e7202016-08-12 11:42:26 -0700354 svmdbtool_main.uid = geteuid ();
355 svmdbtool_main.gid = getegid ();
Ed Warnickecb9cada2015-12-08 15:45:58 -0700356
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400357 unformat_init_command_line (&input, argv);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700358
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400359 while (unformat_check_input (&input) != UNFORMAT_END_OF_INPUT)
360 {
361 if (unformat (&input, "get-string %s", &vbl))
362 {
363 get_string (chroot_path, vbl);
364 vec_free (vbl);
365 parsed++;
366 }
367 else if (unformat (&input, "set-string %s %s", &vbl, &value))
368 {
369 set_string (chroot_path, vbl, value);
370 vec_free (vbl);
371 vec_free (value);
372 parsed++;
373 }
374 else if (unformat (&input, "unset-string %s", &vbl))
375 {
376 unset_string (chroot_path, vbl);
377 vec_free (vbl);
378 parsed++;
379 }
380 else if (unformat (&input, "dump-strings"))
381 {
382 dump_strings (chroot_path);
383 parsed++;
384 }
385 else if (unformat (&input, "unset-vec %s", &vbl))
386 {
387 unset_vec (chroot_path, vbl);
388 vec_free (vbl);
389 parsed++;
390 }
391 else if (unformat (&input, "dump-vecs"))
392 {
393 dump_vecs (chroot_path);
394 parsed++;
395 }
396 else if (unformat (&input, "test-vec %s", &vbl))
397 {
398 test_vec (chroot_path, vbl);
399 // vec_free(vbl);
400 parsed++;
401 }
402 else if (unformat (&input, "vlib-vec-rate %f", &vr))
403 {
404 test_vlib_vec_rate (chroot_path, vr);
405 parsed++;
406 }
407 else if (unformat (&input, "test-reg %s", &vbl))
408 {
409 test_reg (chroot_path, vbl);
410 parsed++;
411 }
412 else if (unformat (&input, "crash-test"))
413 {
414 crash_test (chroot_path);
415 }
416 else if (unformat (&input, "chroot %s", &chroot_path_u8))
417 {
418 chroot_path = (char *) chroot_path_u8;
419 }
420 else if (unformat (&input, "fake-install %s", &value))
421 {
422 fake_install (chroot_path, value);
423 parsed++;
424 }
425 else if (unformat (&input, "size %d", &size))
426 {
427 map_with_size (chroot_path, size);
428 parsed++;
429 }
Dave Barach98cfc1a2016-07-18 14:23:36 -0400430 else if (unformat (&input, "uid %d", &uid))
Ed Warnicke853e7202016-08-12 11:42:26 -0700431 svmdbtool_main.uid = uid;
Dave Barach98cfc1a2016-07-18 14:23:36 -0400432 else if (unformat (&input, "gid %d", &gid))
Ed Warnicke853e7202016-08-12 11:42:26 -0700433 svmdbtool_main.gid = gid;
Dave Barach98cfc1a2016-07-18 14:23:36 -0400434 else if (unformat (&input, "uid %s", &s))
Ed Warnicke853e7202016-08-12 11:42:26 -0700435 {
436 /* lookup the username */
437 pw = NULL;
438 rv = getpwnam_r (s, &_pw, buf, sizeof (buf), &pw);
439 if (rv < 0)
440 {
441 fformat (stderr, "cannot fetch username %s", s);
442 exit (1);
443 }
444 if (pw == NULL)
445 {
446 fformat (stderr, "username %s does not exist", s);
447 exit (1);
448 }
449 vec_free (s);
450 svmdbtool_main.uid = pw->pw_uid;
451 }
Dave Barach98cfc1a2016-07-18 14:23:36 -0400452 else if (unformat (&input, "gid %s", &s))
Ed Warnicke853e7202016-08-12 11:42:26 -0700453 {
454 /* lookup the group name */
455 grp = NULL;
456 rv = getgrnam_r (s, &_grp, buf, sizeof (buf), &grp);
457 if (rv != 0)
458 {
459 fformat (stderr, "cannot fetch group %s", s);
460 exit (1);
461 }
462 if (grp == NULL)
463 {
464 fformat (stderr, "group %s does not exist", s);
465 exit (1);
466 }
467 vec_free (s);
468 svmdbtool_main.gid = grp->gr_gid;
469 }
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400470 else
471 {
472 break;
473 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700474 }
475
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400476 unformat_free (&input);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700477
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400478 if (!parsed)
479 {
480 fformat (stdout, "%s: get-string <name> | set-string <name> <value>\n",
481 argv[0]);
482 fformat (stdout, " unset-string <name> | dump-strings\n");
483 fformat (stdout, " test-vec <name> |\n");
484 fformat (stdout, " unset-vec <name> | dump-vecs\n");
Dave Barach98cfc1a2016-07-18 14:23:36 -0400485 fformat (stdout, " chroot <prefix> [uid <nnn-or-userid>]\n");
486 fformat (stdout, " [gid <nnn-or-group-name>]\n");
Ed Warnickecb9cada2015-12-08 15:45:58 -0700487 }
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400488
489 exit (0);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700490}
Dave Barach8a7fb0c2016-07-08 14:44:23 -0400491
492/*
493 * fd.io coding-style-patch-verification: ON
494 *
495 * Local Variables:
496 * eval: (c-set-style "gnu")
497 * End:
498 */