MCPcopy Create free account
hub / github.com/apache/httpd / get_dbm_grp

Function get_dbm_grp

modules/aaa/mod_authz_dbm.c:100–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98 */
99
100static apr_status_t get_dbm_grp(request_rec *r, char *key1, char *key2,
101 const char *dbmgrpfile, const char *dbtype,
102 const char ** out)
103{
104#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
105 const apr_dbm_driver_t *driver;
106 const apu_err_t *err;
107#endif
108 char *grp_colon, *val;
109 apr_status_t retval;
110 apr_dbm_t *f;
111
112#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
113 retval = apr_dbm_get_driver(&driver, dbtype, &err, r->pool);
114
115 if (retval != APR_SUCCESS) {
116 ap_log_rerror(APLOG_MARK, APLOG_ERR, retval, r, APLOGNO(10286)
117 "could not load '%s' dbm library: %s",
118 err->reason, err->msg);
119 return retval;
120 }
121
122 retval = apr_dbm_open2(&f, driver, dbmgrpfile, APR_DBM_READONLY,
123 APR_OS_DEFAULT, r->pool);
124#else
125 retval = apr_dbm_open_ex(&f, dbtype, dbmgrpfile, APR_DBM_READONLY,
126 APR_OS_DEFAULT, r->pool);
127#endif
128
129 if (retval != APR_SUCCESS) {
130 ap_log_rerror(APLOG_MARK, APLOG_ERR, retval, r, APLOGNO(01799)
131 "could not open dbm (type %s) group access "
132 "file: %s", dbtype, dbmgrpfile);
133 return retval;
134 }
135
136 /* Try key2 only if key1 failed */
137 if (!(val = get_dbm_entry_as_str(r->pool, f, key1))) {
138 val = get_dbm_entry_as_str(r->pool, f, key2);
139 }
140
141 apr_dbm_close(f);
142
143 if (val && (grp_colon = ap_strchr(val, ':')) != NULL) {
144 char *grp_colon2 = ap_strchr(++grp_colon, ':');
145
146 if (grp_colon2) {
147 *grp_colon2 = '\0';
148 }
149 *out = grp_colon;
150 }
151 else {
152 *out = val;
153 }
154
155 return retval;
156}
157

Callers 2

Calls 2

get_dbm_entry_as_strFunction · 0.85
ap_strchrFunction · 0.85

Tested by

no test coverage detected