19 typedef struct json_value
JSON;
24 reinterpret_cast<char *>(alloca(strlen((s)) + 1)), (s))
34 if (getenv(
"CVMFS_AUTHZ_HELPER") == NULL) {
35 printf(
"This program is supposed to be called from the CernVM-FS client.");
43 block_allocator allocator(2048);
47 JSON *json = json_parse(
strdupa(msg.c_str()), &err_pos, &err_desc, &err_line,
49 assert((json != NULL) && (json->first_child != NULL));
50 json = json->first_child;
51 assert((
string(json->name) ==
"cvmfs_authz_v1"));
52 json = json->first_child;
54 const string name(json->name);
55 if (name ==
"debug_log") {
57 }
else if (name ==
"fqrn") {
60 }
else if (name ==
"syslog_level") {
62 }
else if (name ==
"syslog_facility") {
65 json = json->next_sibling;
71 block_allocator allocator(2048);
75 JSON *json = json_parse(
strdupa(msg.c_str()), &err_pos, &err_desc, &err_line,
77 assert((json != NULL) && (json->first_child != NULL));
78 json = json->first_child;
79 assert((
string(json->name) ==
"cvmfs_authz_v1"));
80 json = json->first_child;
82 const string name(json->name);
83 if (name ==
"msgid") {
84 if (json->int_value == 4) {
89 json = json->next_sibling;
97 static void Read(
void *buf,
size_t nbyte) {
100 num_bytes = read(fileno(stdin), buf, nbyte);
101 }
while ((num_bytes < 0) && (errno == EINTR));
102 assert((num_bytes >= 0) && (static_cast<size_t>(num_bytes) == nbyte));
112 Read(&version,
sizeof(version));
114 Read(&length,
sizeof(length));
117 char *buf =
reinterpret_cast<char *
>(alloca(length));
119 return string(buf, length);
126 static void Write(
const void *buf,
size_t nbyte) {
129 num_bytes = write(fileno(stdout), buf, nbyte);
130 }
while ((num_bytes < 0) && (errno == EINTR));
131 assert((num_bytes >= 0) && (static_cast<size_t>(num_bytes) == nbyte));
144 header.length = msg.length();
145 Write(&header,
sizeof(header));
146 Write(msg.data(), header.length);
void ParseHandshakeInit(const string &msg)
static void Read(void *buf, size_t nbyte)
const unsigned kLogAuthzDebug
assert((mem||(size==0))&&"Out Of Memory")
void SetLogAuthzSyslogPrefix(const string &prefix)
void SetLogAuthzSyslogFacility(const int local_facility)
void WriteMsg(const string &msg)
void SetLogAuthzDebug(const string &path)
static void Write(const void *buf, size_t nbyte)
void ParseRequest(const string &msg)
void LogAuthz(const int flags, const char *format,...)
const unsigned kProtocolVersion
void SetLogAuthzSyslogLevel(const int level)