File: cvm-chain.c

package info (click to toggle)
cvm 0.97-0.1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,036 kB
  • sloc: ansic: 4,065; sh: 2,758; makefile: 235; sql: 15
file content (94 lines) | stat: -rw-r--r-- 1,837 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <sys/types.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

#include <bglibs/sysdeps.h>

#include "module.h"
#include "v2client.h"

const char program[] = "cvm-chain";

const char* chains[10];
int chain_count;

static void cvm_chain_init()
{
  cvm_fact_username = 0;
  cvm_fact_userid = -1;
  cvm_fact_groupid = -1;
  cvm_fact_directory = 0;
  cvm_fact_shell = 0;
  cvm_fact_realname = 0;
  cvm_fact_groupname = 0;
  cvm_fact_sys_username = 0;
  cvm_fact_sys_directory = 0;
  cvm_fact_domain = 0;
  cvm_fact_mailbox = 0;
}

int cvm_module_init(void)
{
  int i;
  char varname[] = "CVM_CHAIN#";

  chain_count = 0;
  for (i = 0; i <= 9; ++i) {
    varname[9] = i + '0';
    if ((chains[chain_count] = getenv(varname)) != 0)
      ++chain_count;
  }
  if (chain_count == 0)
    return CVME_CONFIG | CVME_FATAL;

  cvm_chain_init();
  return 0;
}

int cvm_module_lookup(void)
{
  int i;
  int credcount;
  int code;
  unsigned long outofscope = 1;
  int saw_outofscope = 0;
  struct cvm_credential creds[CVM_CRED_MAX+1];

  for (i = credcount = 0; i <= CVM_CRED_MAX; ++i) {
    if (cvm_module_credentials[i].len > 0) {
      creds[credcount].type = i;
      creds[credcount].value = cvm_module_credentials[i];
      ++credcount;
    }
  }

  for (code = i = 0; i < chain_count && ((code & CVME_FATAL) == 0); i++) {
    cvm_chain_init();
    code = cvm_client_authenticate(chains[i], credcount, creds);
    if (code != CVME_PERMFAIL)
      return code;
    if (outofscope
	&& cvm_client_fact_uint(CVM_FACT_OUTOFSCOPE, &outofscope) == 0)
      saw_outofscope = 1;
  }
  if (saw_outofscope)
    cvm_module_fact_uint(CVM_FACT_OUTOFSCOPE, outofscope);
  return code;
}

int cvm_module_authenticate(void)
{
  return 0;
}

int cvm_module_results(void)
{
  cvm_client_setenv();
  return 0;
}


void cvm_module_stop(void)
{
}