@@ -210,8 +210,11 @@ int main(int argc, char **argv)
if (!fedfsd_drop_privileges(uid, gid))
exit(EXIT_FAILURE);
- if (!nsdb_init_database())
+ if (!nsdb_init_database()) {
+ xlog(L_ERROR, "Failed to initialize "
+ "NSDB connection parameters database");
exit(EXIT_FAILURE);
+ }
if (!fedfsd_read_access_config(FEDFSD_ACCESS_CONFIG))
exit(EXIT_FAILURE);
@@ -250,8 +250,8 @@ nsdb_create_fsn_add_entry(nsdb_t host, const char *nce,
attrs, NULL, NULL);
ber_memfree(dn);
if (host->fn_ldaperr != LDAP_SUCCESS) {
- xlog(L_ERROR, "Failed to add new FSN entry: %s",
- ldap_err2string(host->fn_ldaperr));
+ xlog(D_GENERAL, "%s: Failed to add new FSN entry: %s",
+ __func__, ldap_err2string(host->fn_ldaperr));
return FEDFS_ERR_NSDB_LDAP_VAL;
}
@@ -464,9 +464,7 @@ again:
&host->fn_ldaperr);
break;
default:
- xlog(L_ERROR, "%s: Unrecognized LDAP message type",
- __func__);
- retval = FEDFS_ERR_NSDB_RESPONSE;
+ retval = FEDFS_ERR_NSDB_FAULT;
}
}
@@ -885,7 +883,7 @@ nsdb_create_fsls_s(nsdb_t host, const char *nce, struct fedfs_fsl *fsls)
break;
default:
xlog(D_GENERAL, "%s: Unrecognized FSL type", __func__);
- retval = FEDFS_ERR_INVAL;
+ retval = FEDFS_ERR_NSDB_RESPONSE;
}
if (retval != FEDFS_OK)
goto out_delete;
@@ -1635,9 +1633,7 @@ again:
&host->fn_ldaperr);
break;
default:
- xlog(L_ERROR, "%s: Unrecognized LDAP message type",
- __func__);
- retval = FEDFS_ERR_NSDB_RESPONSE;
+ retval = FEDFS_ERR_NSDB_FAULT;
}
}
@@ -173,7 +173,7 @@ nsdb_free_fedfs_fsl(struct fedfs_fsl *fsl)
nsdb_free_string_array(fsl->fl_u.fl_nfsfsl.fn_nfspath);
break;
default:
- xlog(L_ERROR, "%s: Unrecognized FSL type", __func__);
+ xlog(D_GENERAL, "%s: Unrecognized FSL type", __func__);
return;
}
@@ -267,7 +267,7 @@ nsdb_new_fedfs_fsl(FedFsFslType type)
nsdb_init_fedfs_nfs_fsl(new);
break;
default:
- xlog(L_ERROR, "%s: Unrecognized FSL type", __func__);
+ xlog(D_GENERAL, "%s: Unrecognized FSL type", __func__);
free(new);
return NULL;
}
@@ -306,7 +306,7 @@ nsdb_parse_ncedn_attribute(LDAP *ld, LDAPMessage *entry, char *attr,
return FEDFS_ERR_NSDB_RESPONSE;
}
if (values[1] != NULL) {
- xlog(L_ERROR, "%s: Expecting only one value for attribute %s",
+ xlog(D_GENERAL, "%s: Expecting only one value for attribute %s",
__func__, attr);
retval = FEDFS_ERR_NSDB_RESPONSE;
goto out_free;
@@ -429,8 +429,6 @@ nsdb_old_get_ncedn_s(nsdb_t host, const char *naming_context, char **dn)
&host->fn_ldaperr);
break;
default:
- xlog(L_ERROR, "%s: Unrecognized LDAP message type",
- __func__);
retval = FEDFS_ERR_NSDB_FAULT;
}
}
@@ -571,8 +569,6 @@ nsdb_new_get_ncedn_s(nsdb_t host, const char *naming_context, char **dn)
&host->fn_ldaperr);
break;
default:
- xlog(L_ERROR, "%s: Unrecognized LDAP message type",
- __func__);
retval = FEDFS_ERR_NSDB_FAULT;
}
}
@@ -642,7 +638,7 @@ nsdb_parse_naming_contexts_attribute(LDAP *ld, LDAPMessage *entry, char *attr,
retval = nsdb_parse_multivalue_str(attr, values,
contexts);
else {
- xlog(L_ERROR, "%s: Unrecognized attribute: %s",
+ xlog(D_GENERAL, "%s: Unrecognized attribute: %s",
__func__, attr);
retval = FEDFS_ERR_NSDB_RESPONSE;
}
@@ -730,7 +726,7 @@ nsdb_get_naming_contexts_s(nsdb_t host, char ***contexts)
case LDAP_SUCCESS:
break;
case LDAP_NO_SUCH_OBJECT:
- xlog(L_ERROR, "No root DSE entry found");
+ xlog(D_GENERAL, "No root DSE entry found");
return FEDFS_ERR_NSDB_FAULT;
default:
xlog(D_GENERAL, "%s: LDAP search failed: %s",
@@ -749,7 +745,7 @@ nsdb_get_naming_contexts_s(nsdb_t host, char ***contexts)
retval = FEDFS_ERR_NSDB_FAULT;
goto out;
case 1:
- xlog(L_ERROR, "Root DSE entry is inaccessible");
+ xlog(D_GENERAL, "Root DSE entry is inaccessible");
retval = FEDFS_ERR_NSDB_FAULT;
goto out;
default:
@@ -772,8 +768,6 @@ nsdb_get_naming_contexts_s(nsdb_t host, char ***contexts)
&host->fn_ldaperr);
break;
default:
- xlog(L_ERROR, "%s: Unrecognized LDAP message type",
- __func__);
retval = FEDFS_ERR_NSDB_FAULT;
}
}
@@ -877,20 +871,20 @@ nsdb_parse_nfs_uri_fsl(const char *attr, UriUriA *uri,
if ((uri->scheme.first == NULL) ||
(uri->scheme.afterLast != uri->scheme.first + 3) ||
(strncmp(uri->scheme.first, "nfs", 3) != 0)) {
- xlog(L_ERROR, "%s: Attribute %s does not contain an NFS URI",
+ xlog(D_GENERAL, "%s: Attribute %s does not contain an NFS URI",
__func__, attr);
goto out;
}
if ((uri->hostText.first == NULL) ||
(uri->hostText.afterLast <= uri->hostText.first)) {
- xlog(L_ERROR, "%s: NFS URI has no hostname",
+ xlog(D_GENERAL, "%s: NFS URI has no hostname",
__func__);
goto out;
}
len = uri->hostText.afterLast - uri->hostText.first;
if (len > sizeof(nfsl->fn_fslhost)) {
- xlog(L_ERROR, "%s: NFS URI hostname too large",
+ xlog(D_GENERAL, "%s: NFS URI hostname too large",
__func__);
goto out;
}
@@ -903,14 +897,14 @@ nsdb_parse_nfs_uri_fsl(const char *attr, UriUriA *uri,
portlen = uri->portText.afterLast - uri->portText.first;
if (portlen > sizeof(string)) {
- xlog(L_ERROR, "%s: NFS URI has invalid port",
+ xlog(D_GENERAL, "%s: NFS URI has invalid port",
__func__, attr);
goto out;
}
string[0] = '\0';
strncat(string, uri->portText.first, portlen);
if (!nsdb_parse_port_string(string, &port)) {
- xlog(L_ERROR, "%s: NFS URI has invalid port",
+ xlog(D_GENERAL, "%s: NFS URI has invalid port",
__func__, attr);
goto out;
}
@@ -952,18 +946,18 @@ nsdb_parse_nfs_uri(const char *attr, struct berval **values,
retval = FEDFS_ERR_NSDB_RESPONSE;
if (values[0] == NULL) {
- xlog(L_ERROR, "%s: NULL value for attribute %s",
+ xlog(D_GENERAL, "%s: NULL value for attribute %s",
__func__, attr);
return retval;
}
if (values[1] != NULL) {
- xlog(L_ERROR, "%s: Expecting only one value for attribute %s",
+ xlog(D_GENERAL, "%s: Expecting only one value for attribute %s",
__func__, attr);
return retval;
}
if (uriParseUriA(&state, (char *)values[0]->bv_val) != URI_SUCCESS) {
- xlog(L_ERROR, "%s: Failed to parse NFS URI", __func__);
+ xlog(D_GENERAL, "%s: Failed to parse NFS URI", __func__);
goto out;
}
@@ -1220,8 +1214,6 @@ nsdb_resolve_fsn_find_entry_s(nsdb_t host, const char *nce, const char *fsn_uuid
&host->fn_ldaperr);
break;
default:
- xlog(L_ERROR, "%s: Unrecognized LDAP message type",
- __func__);
retval = FEDFS_ERR_NSDB_FAULT;
}
}
@@ -1528,8 +1520,6 @@ nsdb_get_fsn_find_entry_s(nsdb_t host, const char *nce, const char *fsn_uuid,
&host->fn_ldaperr);
break;
default:
- xlog(L_ERROR, "%s: Unrecognized LDAP message type",
- __func__);
retval = FEDFS_ERR_NSDB_FAULT;
}
}
@@ -1645,7 +1635,7 @@ nsdb_parse_fsn_attribute(LDAP *ld, LDAPMessage *entry, char *attr, char ***fsns)
return FEDFS_ERR_NSDB_RESPONSE;
}
if (values[1] != NULL) {
- xlog(L_ERROR, "%s: Expecting only one value for attribute %s",
+ xlog(D_GENERAL, "%s: Expecting only one value for attribute %s",
__func__, attr);
retval = FEDFS_ERR_NSDB_RESPONSE;
goto out_free;
@@ -1771,8 +1761,6 @@ nsdb_list_find_entries_s(nsdb_t host, const char *nce, char ***fsns)
&host->fn_ldaperr);
break;
default:
- xlog(L_ERROR, "%s: Unrecognized LDAP message type",
- __func__);
retval = FEDFS_ERR_NSDB_FAULT;
}
}
@@ -140,12 +140,12 @@ nsdb_enable_ldap_debugging(void)
#if 0
rc = ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, &debug);
if (rc != LBER_OPT_SUCCESS)
- xlog(L_ERROR, "Failed to set LBER_OPT_DEBUG_LEVEL");
+ xlog(D_GENERAL, "Failed to set LBER_OPT_DEBUG_LEVEL");
#endif
rc = ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &debug);
if (rc != LDAP_OPT_SUCCESS )
- xlog(L_ERROR, "Failed to set LDAP_OPT_DEBUG_LEVEL");
+ xlog(D_GENERAL, "Failed to set LDAP_OPT_DEBUG_LEVEL");
}
/**
@@ -287,7 +287,7 @@ nsdb_parse_singlevalue_bool(char *attr, struct berval **values, _Bool *result)
struct berval *value;
if (values[1] != NULL) {
- xlog(L_ERROR, "%s: Expecting only one value for attribute %s",
+ xlog(D_CALL, "%s: Expecting only one value for attribute %s",
__func__, attr);
return FEDFS_ERR_NSDB_RESPONSE;
}
@@ -326,7 +326,7 @@ nsdb_parse_singlevalue_uchar(char *attr, struct berval **values,
long tmp;
if (values[1] != NULL) {
- xlog(L_ERROR, "%s: Expecting only one value for attribute %s",
+ xlog(D_CALL, "%s: Expecting only one value for attribute %s",
__func__, attr);
return FEDFS_ERR_NSDB_RESPONSE;
}
@@ -360,7 +360,7 @@ nsdb_parse_singlevalue_int(char *attr, struct berval **values, int *result)
long tmp;
if (values[1] != NULL) {
- xlog(L_ERROR, "%s: Expecting only one value for attribute %s",
+ xlog(D_CALL, "%s: Expecting only one value for attribute %s",
__func__, attr);
return FEDFS_ERR_NSDB_RESPONSE;
}
@@ -393,12 +393,12 @@ nsdb_parse_singlevalue_str(char *attr, struct berval **values,
char *result, const size_t len)
{
if (len < strlen(values[0]->bv_val)) {
- xlog(L_ERROR, "%s: Value of attribute %s is too large",
+ xlog(D_CALL, "%s: Value of attribute %s is too large",
__func__, attr);
return FEDFS_ERR_NSDB_RESPONSE;
}
if (values[1] != NULL) {
- xlog(L_ERROR, "%s: Expecting only one value for attribute %s",
+ xlog(D_CALL, "%s: Expecting only one value for attribute %s",
__func__, attr);
return FEDFS_ERR_NSDB_RESPONSE;
}
@@ -120,11 +120,13 @@ nsdb_set_parentdir(const char *parentdir)
/* First: test length of name and whether it exists */
if (lstat(parentdir, &st) == -1) {
- xlog(L_ERROR, "Failed to stat %s: %m", parentdir);
+ xlog(D_GENERAL, "%s: Failed to stat %s: %m",
+ __func__, parentdir);
return false;
}
if (!S_ISDIR(st.st_mode)) {
- xlog(L_ERROR, "%s is not a directory", parentdir);
+ xlog(D_GENERAL, "%s: %s is not a directory",
+ __func__, parentdir);
return false;
}
@@ -132,21 +134,23 @@ nsdb_set_parentdir(const char *parentdir)
strncpy(buf, parentdir, sizeof(buf));
path = dirname(buf);
if (*path == '.') {
- xlog(L_ERROR, "Unusable pathname %s",
- parentdir);
+ xlog(D_GENERAL, "%s: Unusable pathname %s",
+ __func__, parentdir);
return false;
}
len = snprintf(buf, sizeof(buf), "%s/%s", parentdir, FEDFS_DATABASE_FILE);
if (len > PATH_MAX) {
- xlog(L_ERROR, "FedFS database pathname is too long");
+ xlog(D_GENERAL, "%s: FedFS database pathname is too long",
+ __func__);
return false;
}
strcpy(fedfs_db_filename, buf);
len = snprintf(buf, sizeof(buf), "%s/%s", parentdir, FEDFS_NSDBCERT_DIR);
if (len > PATH_MAX) {
- xlog(L_ERROR, "FedFS cert directory pathname is too long");
+ xlog(D_GENERAL, "%s: FedFS cert directory pathname is too long",
+ __func__);
return false;
}
strcpy(fedfs_nsdbcerts_dirname, buf);
@@ -191,7 +195,9 @@ nsdb_create_private_certfile(char **pathbuf)
retval = FEDFS_ERR_SVRFAULT;
if (mkdir(fedfs_nsdbcerts_dirname, FEDFS_BASE_DIRMODE) == -1) {
if (errno != EEXIST) {
- xlog(L_ERROR, "Failed to create certfile directory: %m");
+ xlog(D_GENERAL,
+ "%s: Failed to create certfile directory: %m",
+ __func__);
goto out;
}
}
@@ -274,7 +280,8 @@ nsdb_init_database(void)
if (mkdir(fedfs_base_dirname, FEDFS_BASE_DIRMODE) == -1) {
if (errno != EEXIST) {
- xlog(L_ERROR, "Failed to create base dir: %m");
+ xlog(D_GENERAL, "%s: Failed to create base dir: %m",
+ __func__);
goto out;
}
xlog(D_GENERAL, "%s: Base dir %s exists",
@@ -294,8 +301,9 @@ nsdb_init_database(void)
rc = sqlite3_exec(db, "PRAGMA journal_mode=TRUNCATE;",
NULL, NULL, &err_msg);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to enable persistent journaling: %s",
- err_msg);
+ xlog(D_GENERAL,
+ "%s: Failed to enable persistent journaling: %s",
+ __func__, err_msg);
sqlite3_free(err_msg);
goto out_close;
}
@@ -702,15 +710,15 @@ nsdb_new_nsdbname(sqlite3 *db, const nsdb_t host)
rc = sqlite3_bind_text(stmt, 1, domainname, -1, SQLITE_STATIC);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to bind NSDB hostname %s: %s",
- domainname, sqlite3_errmsg(db));
+ xlog(D_GENERAL, "%s: Failed to bind NSDB hostname %s: %s",
+ __func__, domainname, sqlite3_errmsg(db));
goto out_finalize;
}
rc = sqlite3_bind_int(stmt, 2, port);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to bind port number: %s",
- sqlite3_errmsg(db));
+ xlog(D_GENERAL, "%s: Failed to bind port number: %s",
+ __func__, sqlite3_errmsg(db));
goto out_finalize;
}
@@ -727,8 +735,9 @@ nsdb_new_nsdbname(sqlite3 *db, const nsdb_t host)
retval = FEDFS_OK;
break;
default:
- xlog(L_ERROR, "Failed to create NSDB info record for '%s:%u': %s",
- domainname, port, sqlite3_errmsg(db));
+ xlog(D_GENERAL,
+ "%s: Failed to create NSDB info record for '%s:%u': %s",
+ __func__, domainname, port, sqlite3_errmsg(db));
}
out_finalize:
@@ -766,29 +775,29 @@ nsdb_update_security_nsdbname(sqlite3 *db, const nsdb_t host,
rc = sqlite3_bind_int(stmt, 1, sectype);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to bind connection security value: %s",
- sqlite3_errmsg(db));
+ xlog(D_GENERAL, "%s: Failed to bind connection security value: %s",
+ __func__, sqlite3_errmsg(db));
goto out_finalize;
}
rc = sqlite3_bind_text(stmt, 2, certfile, -1, SQLITE_STATIC);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to bind security data value: %s",
- sqlite3_errmsg(db));
+ xlog(D_GENERAL, "%s: Failed to bind security data value: %s",
+ __func__, sqlite3_errmsg(db));
goto out_finalize;
}
rc = sqlite3_bind_text(stmt, 3, domainname, -1, SQLITE_STATIC);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to bind NSDB hostname %s: %s",
- domainname, sqlite3_errmsg(db));
+ xlog(D_GENERAL, "%s: Failed to bind NSDB hostname %s: %s",
+ __func__, domainname, sqlite3_errmsg(db));
goto out_finalize;
}
rc = sqlite3_bind_int(stmt, 4, port);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to bind port number: %s",
- sqlite3_errmsg(db));
+ xlog(D_GENERAL, "%s: Failed to bind port number: %s",
+ __func__, sqlite3_errmsg(db));
goto out_finalize;
}
@@ -800,8 +809,9 @@ nsdb_update_security_nsdbname(sqlite3 *db, const nsdb_t host,
retval = FEDFS_OK;
break;
default:
- xlog(L_ERROR, "Failed to update NSDB info record for '%s:%u': %s",
- domainname, port, sqlite3_errmsg(db));
+ xlog(D_GENERAL,
+ "%s: Failed to update NSDB info record for '%s:%u': %s",
+ __func__, domainname, port, sqlite3_errmsg(db));
}
out_finalize:
@@ -835,22 +845,22 @@ nsdb_update_nsdb_default_binddn(sqlite3 *db, const nsdb_t host,
rc = sqlite3_bind_text(stmt, 1, binddn, -1, SQLITE_STATIC);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to bind default bind DN%s: %s",
- binddn, sqlite3_errmsg(db));
+ xlog(D_GENERAL, "%s: Failed to bind default bind DN%s: %s",
+ __func__, binddn, sqlite3_errmsg(db));
goto out_finalize;
}
rc = sqlite3_bind_text(stmt, 2, domainname, -1, SQLITE_STATIC);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to bind NSDB hostname %s: %s",
- domainname, sqlite3_errmsg(db));
+ xlog(D_GENERAL, "%s: Failed to bind NSDB hostname %s: %s",
+ __func__, domainname, sqlite3_errmsg(db));
goto out_finalize;
}
rc = sqlite3_bind_int(stmt, 3, port);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to bind port number: %s",
- sqlite3_errmsg(db));
+ xlog(D_GENERAL, "%s: Failed to bind port number: %s",
+ __func__, sqlite3_errmsg(db));
goto out_finalize;
}
@@ -862,8 +872,9 @@ nsdb_update_nsdb_default_binddn(sqlite3 *db, const nsdb_t host,
retval = FEDFS_OK;
break;
default:
- xlog(L_ERROR, "Failed to update default bind DN for '%s:%u': %s",
- domainname, port, sqlite3_errmsg(db));
+ xlog(D_GENERAL,
+ "%s: Failed to update default bind DN for '%s:%u': %s",
+ __func__, domainname, port, sqlite3_errmsg(db));
}
out_finalize:
@@ -897,22 +908,22 @@ nsdb_update_nsdb_default_nce(sqlite3 *db, const nsdb_t host,
rc = sqlite3_bind_text(stmt, 1, nce, -1, SQLITE_STATIC);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to bind default NCE DN%s: %s",
- nce, sqlite3_errmsg(db));
+ xlog(D_GENERAL, "%s: Failed to bind default NCE DN%s: %s",
+ __func__, nce, sqlite3_errmsg(db));
goto out_finalize;
}
rc = sqlite3_bind_text(stmt, 2, domainname, -1, SQLITE_STATIC);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to bind NSDB hostname %s: %s",
- domainname, sqlite3_errmsg(db));
+ xlog(D_GENERAL, "%s: Failed to bind NSDB hostname %s: %s",
+ __func__, domainname, sqlite3_errmsg(db));
goto out_finalize;
}
rc = sqlite3_bind_int(stmt, 3, port);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to bind port number: %s",
- sqlite3_errmsg(db));
+ xlog(D_GENERAL, "%s: Failed to bind port number: %s",
+ __func__, sqlite3_errmsg(db));
goto out_finalize;
}
@@ -924,8 +935,9 @@ nsdb_update_nsdb_default_nce(sqlite3 *db, const nsdb_t host,
retval = FEDFS_OK;
break;
default:
- xlog(L_ERROR, "Failed to update default NCE DN for '%s:%u': %s",
- domainname, port, sqlite3_errmsg(db));
+ xlog(D_GENERAL,
+ "%s: Failed to update default NCE DN for '%s:%u': %s",
+ __func__, domainname, port, sqlite3_errmsg(db));
}
out_finalize:
@@ -959,22 +971,22 @@ nsdb_update_nsdb_follow_referrals(sqlite3 *db, const nsdb_t host,
rc = sqlite3_bind_int(stmt, 1, follow_referrals ? 1 : 0);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to bind follow referrals flag: %s",
- sqlite3_errmsg(db));
+ xlog(D_GENERAL, "%s: Failed to bind follow referrals flag: %s",
+ __func__, sqlite3_errmsg(db));
goto out_finalize;
}
rc = sqlite3_bind_text(stmt, 2, domainname, -1, SQLITE_STATIC);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to bind NSDB hostname %s: %s",
- domainname, sqlite3_errmsg(db));
+ xlog(D_GENERAL, "%s: Failed to bind NSDB hostname %s: %s",
+ __func__, domainname, sqlite3_errmsg(db));
goto out_finalize;
}
rc = sqlite3_bind_int(stmt, 3, port);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to bind port number: %s",
- sqlite3_errmsg(db));
+ xlog(D_GENERAL, "%s: Failed to bind port number: %s",
+ D_GENERAL, sqlite3_errmsg(db));
goto out_finalize;
}
@@ -986,8 +998,9 @@ nsdb_update_nsdb_follow_referrals(sqlite3 *db, const nsdb_t host,
retval = FEDFS_OK;
break;
default:
- xlog(L_ERROR, "Failed to update referrals flag for '%s:%u': %s",
- domainname, port, sqlite3_errmsg(db));
+ xlog(D_GENERAL,
+ "%s: Failed to update referrals flag for '%s:%u': %s",
+ __func__, domainname, port, sqlite3_errmsg(db));
}
out_finalize:
@@ -1024,15 +1037,15 @@ nsdb_delete_nsdbname(sqlite3 *db, const nsdb_t host)
rc = sqlite3_bind_text(stmt, 1, hostname, -1, SQLITE_STATIC);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to bind NSDB hostname %s: %s",
- hostname, sqlite3_errmsg(db));
+ xlog(D_GENERAL, "%s: Failed to bind NSDB hostname %s: %s",
+ __func__, hostname, sqlite3_errmsg(db));
goto out_finalize;
}
rc = sqlite3_bind_int(stmt, 2, port);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to bind port number: %s",
- sqlite3_errmsg(db));
+ xlog(D_GENERAL, "%s: Failed to bind port number: %s",
+ __func__, sqlite3_errmsg(db));
goto out_finalize;
}
@@ -1044,8 +1057,9 @@ nsdb_delete_nsdbname(sqlite3 *db, const nsdb_t host)
retval = FEDFS_OK;
break;
default:
- xlog(L_ERROR, "Failed to delete NSDB info record for '%s:%u': %s",
- hostname, port, sqlite3_errmsg(db));
+ xlog(D_GENERAL,
+ "%s: Failed to delete NSDB info record for '%s:%u': %s",
+ __func__, hostname, port, sqlite3_errmsg(db));
}
out_finalize:
@@ -1409,7 +1423,7 @@ nsdb_enumerate_nsdbs(char ***nsdblist)
rc = sqlite3_get_table(db, "SELECT nsdbName,nsdbPort from nsdbs;",
&resultp, &nrows, &ncols, &err_msg);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "%s: Failed to read table nsdbs: %s",
+ xlog(D_GENERAL, "%s: Failed to read table nsdbs: %s",
__func__, err_msg);
sqlite3_free(err_msg);
goto out_close;
@@ -1426,7 +1440,7 @@ nsdb_enumerate_nsdbs(char ***nsdblist)
}
if (nrows < 1 || ncols != 2) {
- xlog(L_ERROR, "%s: Returned table had "
+ xlog(D_GENERAL, "%s: Returned table had "
"incorrect table dimensions: (%d, %d)",
__func__, nrows, ncols);
goto out_free;
@@ -57,16 +57,15 @@ nsdb_open_db(const char *db_filename, int flags)
rc = sqlite3_initialize();
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to initialize sqlite3: %d", rc);
+ xlog(D_GENERAL, "%s: Failed to initialize sqlite3: %d",
+ __func__, rc);
return NULL;
}
rc = sqlite3_open_v2(db_filename, &db, flags, NULL);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to open sqlite3 database in %s: %s",
- db_filename, sqlite3_errmsg(db));
- xlog(L_ERROR, "Check that the full database pathname is correct, and that");
- xlog(L_ERROR, "the database file exists and has proper permissions");
+ xlog(D_GENERAL, "%s: Failed to open sqlite3 database in %s: %s",
+ __func__, db_filename, sqlite3_errmsg(db));
(void)sqlite3_close(db);
return NULL;
}
@@ -91,12 +90,13 @@ nsdb_close_db(sqlite3 *db)
rc = sqlite3_close(db);
if (rc != SQLITE_OK)
- xlog(L_ERROR, "Failed to close sqlite3 database: %s",
- sqlite3_errmsg(db));
+ xlog(D_GENERAL, "%s: Failed to close sqlite3 database: %s",
+ __func__, sqlite3_errmsg(db));
rc = sqlite3_shutdown();
if (rc != SQLITE_OK)
- xlog(L_ERROR, "Failed to shut sqlite3 down: %d", rc);
+ xlog(D_GENERAL, "%s: Failed to shut sqlite3 down: %d",
+ __func__, rc);
}
/**
@@ -114,9 +114,9 @@ nsdb_prepare_stmt(sqlite3 *db, sqlite3_stmt **stmt, const char *sql)
rc = sqlite3_prepare_v2(db, sql, -1, stmt, NULL);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to compile SQL: %s",
- sqlite3_errmsg(db));
- xlog(L_ERROR, "SQL: %s", sql);
+ xlog(D_GENERAL, "%s: Failed to compile SQL: %s",
+ __func__, sqlite3_errmsg(db));
+ xlog(D_GENERAL, "%s: SQL: %s", __func__, sql);
return false;
}
return true;
@@ -140,8 +140,8 @@ nsdb_finalize_stmt(sqlite3_stmt *stmt)
case SQLITE_CONSTRAINT:
break;
default:
- xlog(L_ERROR, "Failed to finalize SQL statement: %s",
- sqlite3_errmsg(db));
+ xlog(D_GENERAL, "%s: Failed to finalize SQL statement: %s",
+ __func__, sqlite3_errmsg(db));
}
}
@@ -161,7 +161,8 @@ nsdb_begin_transaction(sqlite3 *db)
rc = sqlite3_exec(db, "BEGIN IMMEDIATE TRANSACTION;",
NULL, NULL, &err_msg);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to start transaction: %s", err_msg);
+ xlog(D_GENERAL, "%s: Failed to start transaction: %s",
+ __func__, err_msg);
sqlite3_free(err_msg);
return false;
}
@@ -184,7 +185,8 @@ nsdb_end_transaction(sqlite3 *db)
err_msg = NULL;
rc = sqlite3_exec(db, "COMMIT TRANSACTION;", NULL, NULL, &err_msg);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to commit transaction: %s", err_msg);
+ xlog(D_GENERAL, "%s: Failed to commit transaction: %s",
+ __func__, err_msg);
sqlite3_free(err_msg);
return;
}
@@ -206,7 +208,8 @@ nsdb_rollback_transaction(sqlite3 *db)
err_msg = NULL;
rc = sqlite3_exec(db, "ROLLBACK TRANSACTION;", NULL, NULL, &err_msg);
if (rc != SQLITE_OK) {
- xlog(L_ERROR, "Failed to roll back transaction: %s", err_msg);
+ xlog(D_GENERAL, "%s: Failed to roll back transaction: %s",
+ __func__, err_msg);
sqlite3_free(err_msg);
return;
}
@@ -233,8 +236,8 @@ nsdb_create_table(sqlite3 *db, const char *table_name, const char *table_def)
sql = sqlite3_mprintf("CREATE TABLE %q (%q);", table_name, table_def);
if (sql == NULL) {
- xlog(L_ERROR, "Failed to construct SQL command while "
- "creating table %s", table_name);
+ xlog(D_GENERAL, "%s: Failed to construct SQL command while "
+ "creating table %s", __func__, table_name);
return false;
}
@@ -247,16 +250,17 @@ nsdb_create_table(sqlite3 *db, const char *table_name, const char *table_def)
xlog(D_CALL, "Table %s already exists", table_name);
return true;
default:
- xlog(L_ERROR, "Failed to compile SQL while creating table %s: %s",
- table_name, sqlite3_errmsg(db));
- xlog(L_ERROR, "SQL: %s");
+ xlog(D_GENERAL,
+ "%s: Failed to compile SQL while creating table %s: %s",
+ __func__, table_name, sqlite3_errmsg(db));
+ xlog(D_GENERAL, "%s: SQL: %s", __func__, sql);
return false;
}
rc = sqlite3_step(stmt);
if (rc != SQLITE_DONE) {
- xlog(L_ERROR, "Failed to create %s table: %s",
- table_name, sqlite3_errmsg(db));
+ xlog(D_GENERAL, "%s: Failed to create %s table: %s",
+ __func__, table_name, sqlite3_errmsg(db));
nsdb_finalize_stmt(stmt);
return false;
}
@@ -202,8 +202,11 @@ nsdbparams_delete(const char *progname, int argc, char **argv)
if (!nsdbparams_drop_privileges(uid, gid))
return EXIT_FAILURE;
- if (!nsdb_init_database())
+ if (!nsdb_init_database()) {
+ xlog(L_ERROR, "Failed to initialize "
+ "NSDB connection parameters database");
return EXIT_FAILURE;
+ }
status = nsdb_lookup_nsdb(nsdbname, nsdbport, &host);
switch (status) {
@@ -180,8 +180,11 @@ nsdbparams_list(const char *progname, int argc, char **argv)
if (!nsdbparams_drop_privileges(uid, gid))
return EXIT_FAILURE;
- if (!nsdb_init_database())
+ if (!nsdb_init_database()) {
+ xlog(L_ERROR, "Failed to initialize "
+ "NSDB connection parameters database");
return EXIT_FAILURE;
+ }
status = nsdb_enumerate_nsdbs(&list);
switch (status) {
@@ -221,8 +221,11 @@ nsdbparams_show(const char *progname, int argc, char **argv)
if (!nsdbparams_drop_privileges(uid, gid))
return EXIT_FAILURE;
- if (!nsdb_init_database())
+ if (!nsdb_init_database()) {
+ xlog(L_ERROR, "Failed to initialize "
+ "NSDB connection parameters database");
return EXIT_FAILURE;
+ }
if (argc == optind + 1)
nsdbname = argv[optind];
@@ -391,8 +391,11 @@ nsdbparams_update(const char *progname, int argc, char **argv)
if (!nsdbparams_drop_privileges(uid, gid))
goto out;
- if (!nsdb_init_database())
+ if (!nsdb_init_database()) {
+ xlog(L_ERROR, "Failed to initialize "
+ "NSDB connection parameters database");
goto out;
+ }
retval = nsdb_lookup_nsdb(nsdbname, nsdbport, &host);
switch (retval) {
As a general rule, libraries should not emit any error messages. A library should depend on its consumer to present errors to users. Convert the remaining uses of L_ERROR in libnsdb to D_GENERAL or D_CALL. Fixed a couple of spots in administrator.c that return NSDB_RESPONSE instead of NSDB_FAULT. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> --- src/fedfsd/main.c | 5 +- src/libnsdb/administrator.c | 14 ++--- src/libnsdb/fileserver.c | 42 +++++--------- src/libnsdb/ldap.c | 14 ++--- src/libnsdb/nsdb.c | 130 ++++++++++++++++++++++++------------------- src/libnsdb/sqlite.c | 50 +++++++++-------- src/nsdbparams/delete.c | 5 +- src/nsdbparams/list.c | 5 +- src/nsdbparams/show.c | 5 +- src/nsdbparams/update.c | 5 +- 10 files changed, 146 insertions(+), 129 deletions(-)