19 typedef struct json_value
JSON;
22 #define strdupa(s) strcpy(\
23 reinterpret_cast<char *>(alloca(strlen((s)) + 1)), (s))
33 if (getenv(
"CVMFS_AUTHZ_HELPER") == NULL) {
34 printf(
"This program is supposed to be called from the CernVM-FS client.");
42 block_allocator allocator(2048);
43 char *err_pos;
char *err_desc;
int err_line;
45 &err_pos, &err_desc, &err_line,
47 assert((json != NULL) && (json->first_child != NULL));
48 json = json->first_child;
49 assert((
string(json->name) ==
"cvmfs_authz_v1"));
50 json = json->first_child;
52 string name(json->name);
53 if (name ==
"debug_log") {
55 }
else if (name ==
"fqrn") {
58 }
else if (name ==
"syslog_level") {
60 }
else if (name ==
"syslog_facility") {
63 json = json->next_sibling;
69 block_allocator allocator(2048);
70 char *err_pos;
char *err_desc;
int err_line;
72 &err_pos, &err_desc, &err_line,
74 assert((json != NULL) && (json->first_child != NULL));
75 json = json->first_child;
76 assert((
string(json->name) ==
"cvmfs_authz_v1"));
77 json = json->first_child;
79 string name(json->name);
80 if (name ==
"msgid") {
81 if (json->int_value == 4) {
86 json = json->next_sibling;
94 static void Read(
void *buf,
size_t nbyte) {
97 num_bytes = read(fileno(stdin), buf, nbyte);
98 }
while ((num_bytes < 0) && (errno == EINTR));
99 assert((num_bytes >= 0) && (static_cast<size_t>(num_bytes) == nbyte));
109 Read(&version,
sizeof(version));
111 Read(&length,
sizeof(length));
114 char *buf =
reinterpret_cast<char *
>(alloca(length));
116 return string(buf, length);
123 static void Write(
const void *buf,
size_t nbyte) {
126 num_bytes = write(fileno(stdout), buf, nbyte);
127 }
while ((num_bytes < 0) && (errno == EINTR));
128 assert((num_bytes >= 0) && (static_cast<size_t>(num_bytes) == nbyte));
141 header.length = msg.length();
142 Write(&header,
sizeof(header));
143 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)