source: libabac/options.c @ 4423f47

abac0-leakabac0-meimei-idtvf-new-xml
Last change on this file since 4423f47 was 461541a, checked in by Mei <mei@…>, 11 years ago

1) updated original rt0 to remove libstrongswan dependency

a) identity credential being made/accessed with openssl api calls

(X509/EVP_PKEY pem)

b) attribute credential being made/access via xmlsec1 (custom XML

structure)

2) refactored libcreddy into libabac and now one ABAC namespace for

libabac

3) added attribute_rule suboption to creddy's attribute as another way

to insert access rule

4) added some regression tests into example directory
5) updated some docs.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1
2/* options.c */
3
4#include <stdio.h>
5#include <getopt.h>
6#include <stdlib.h>
7#include <string.h>
8
9#include "options.h"
10
11static void _usage(char *name) {
12    printf(
13        "Usage: %s \\\n"
14        "        --keystore <keystore> \\\n"
15        "        --role <keyid.role> --principal <keyid>\n"
16        "        --dump <file>\n"
17        "    loads the keystore and runs the query role <-?- principal\n",
18        name
19    );
20    exit(1);
21}
22
23void get_options(int argc, char **argv, options_t *opts) {
24#define OPT_KEYSTORE    1
25#define OPT_ROLE        2
26#define OPT_PRINCIPAL   3
27#define OPT_DUMP        4
28    struct option options[] = {
29        { "keystore",   1, 0, OPT_KEYSTORE  },
30        { "role",       1, 0, OPT_ROLE      },
31        { "principal",  1, 0, OPT_PRINCIPAL },
32        { "dump",       1, 0, OPT_DUMP },
33        { 0 },
34    };
35
36    for ( ; ; ) {
37        int c = getopt_long(argc, argv, "", options, NULL);
38        if (c < 0)
39            break;
40
41        switch (c) {
42            case OPT_KEYSTORE:
43                opts->keystore = strdup(optarg);
44                break;
45            case OPT_ROLE:
46                opts->role = strdup(optarg);
47                break;
48            case OPT_PRINCIPAL:
49                opts->principal = strdup(optarg);
50                break;
51            case OPT_DUMP:
52                opts->rulefile = strdup(optarg);
53                break;
54
55
56            default:
57                _usage(argv[0]);
58        }
59    }
60
61    if (!(opts->keystore && opts->role && opts->principal) && !(opts->rulefile) )
62        _usage(argv[0]);
63}
Note: See TracBrowser for help on using the repository browser.