str sfsconst_etcfile_required (const char *name, const char *const *path, bool ftl) { str file = sfsconst_etcfile (name, path); if (!file) { strbuf msg ("Could not find '%s'. Searched:\n", name); for (const char *const *d = path; *d; d++) { msg << " " << *d << "/" << name << "\n"; } str m = msg; if (ftl) fatal ("%s", m.cstr ()); else warn ("%s", m.cstr ()); } return file; }
str okws_etcfile (const char *f, const char *env_var, const char **cfg_path) { vec<str> v1; vec<const char *> v2; if (cfg_path == NULL) cfg_path = ok_cfg_path; get_cfg_path (&v1, env_var, cfg_path); vec2vec (&v2, v1); return sfsconst_etcfile (f, v2.base ()); }
bool get_srp_params (ptr<aclnt> c, bigint *Np, bigint *gp) { bool valid = false; bigint N,g; str srpfile, parms; if ((srpfile = sfsconst_etcfile ("sfs_srp_parms")) && (parms = file2str (srpfile)) && import_srp_params (parms, &N, &g) ) { if (!srp_base::checkparam (N, g)) { warn << "Invalid SRP parameters read from file: " << srpfile << "\n"; } else valid = true; } if (!valid && c) { sfsauth2_query_arg aqa; sfsauth2_query_res aqr; aqa.type = SFSAUTH_SRPPARMS; aqa.key.set_type (SFSAUTH_DBKEY_NULL); clnt_stat err = c->scall (SFSAUTH2_QUERY, &aqa, &aqr); if (!err && aqr.type == SFSAUTH_SRPPARMS && import_srp_params (aqr.srpparms->parms, &N, &g)) { if (!srp_base::checkparam (N, g)) { warn << "Invalid SRP parameters read from sfsauthd.\n"; return false; } else { valid = true; } } } if (valid) { *Np = N; *gp = g; return true; } return false; }
str sfsconst_etcfile (const char *name) { const char *path[] = { etc1dir, etc2dir, etc3dir, NULL }; return sfsconst_etcfile (name, path); }
str flume_etcfile (const char *f) { return sfsconst_etcfile (f, flume_cfg_path); }