use krb5_set_error_message
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23316 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -275,7 +275,7 @@ _hdb_store(krb5_context context, HDB *db, unsigned flags, hdb_entry_ex *entry)
|
||||
struct timeval t;
|
||||
entry->entry.generation = malloc(sizeof(*entry->entry.generation));
|
||||
if(entry->entry.generation == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
gettimeofday(&t, NULL);
|
||||
|
38
lib/hdb/db.c
38
lib/hdb/db.c
@@ -68,8 +68,8 @@ DB_lock(krb5_context context, HDB *db, int operation)
|
||||
DB *d = (DB*)db->hdb_db;
|
||||
int fd = (*d->fd)(d);
|
||||
if(fd < 0) {
|
||||
krb5_set_error_string(context,
|
||||
"Can't lock database: %s", db->hdb_name);
|
||||
krb5_set_error_message(context, HDB_ERR_CANT_LOCK_DB,
|
||||
"Can't lock database: %s", db->hdb_name);
|
||||
return HDB_ERR_CANT_LOCK_DB;
|
||||
}
|
||||
return hdb_lock(fd, operation);
|
||||
@@ -81,8 +81,8 @@ DB_unlock(krb5_context context, HDB *db)
|
||||
DB *d = (DB*)db->hdb_db;
|
||||
int fd = (*d->fd)(d);
|
||||
if(fd < 0) {
|
||||
krb5_set_error_string(context,
|
||||
"Can't unlock database: %s", db->hdb_name);
|
||||
krb5_set_error_message(context, HDB_ERR_CANT_LOCK_DB,
|
||||
"Can't unlock database: %s", db->hdb_name);
|
||||
return HDB_ERR_CANT_LOCK_DB;
|
||||
}
|
||||
return hdb_unlock(fd);
|
||||
@@ -100,15 +100,15 @@ DB_seq(krb5_context context, HDB *db,
|
||||
|
||||
code = db->hdb_lock(context, db, HDB_RLOCK);
|
||||
if(code == -1) {
|
||||
krb5_set_error_string(context, "Database %s in use", db->hdb_name);
|
||||
krb5_set_error_message(context, HDB_ERR_DB_INUSE, "Database %s in use", db->hdb_name);
|
||||
return HDB_ERR_DB_INUSE;
|
||||
}
|
||||
code = (*d->seq)(d, &key, &value, flag);
|
||||
db->hdb_unlock(context, db); /* XXX check value */
|
||||
if(code == -1) {
|
||||
code = errno;
|
||||
krb5_set_error_string(context, "Database %s seq error: %s",
|
||||
db->hdb_name, strerror(code));
|
||||
krb5_set_error_message(context, code, "Database %s seq error: %s",
|
||||
db->hdb_name, strerror(code));
|
||||
return code;
|
||||
}
|
||||
if(code == 1) {
|
||||
@@ -131,8 +131,8 @@ DB_seq(krb5_context context, HDB *db,
|
||||
if (code == 0 && entry->entry.principal == NULL) {
|
||||
entry->entry.principal = malloc(sizeof(*entry->entry.principal));
|
||||
if (entry->entry.principal == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
code = ENOMEM;
|
||||
krb5_set_error_message(context, code, "malloc: out of memory");
|
||||
hdb_free_entry (context, entry);
|
||||
} else {
|
||||
hdb_key2principal(context, &key_data, entry->entry.principal);
|
||||
@@ -190,8 +190,8 @@ DB__get(krb5_context context, HDB *db, krb5_data key, krb5_data *reply)
|
||||
db->hdb_unlock(context, db);
|
||||
if(code < 0) {
|
||||
code = errno;
|
||||
krb5_set_error_string(context, "Database %s get error: %s",
|
||||
db->hdb_name, strerror(code));
|
||||
krb5_set_error_message(context, code, "Database %s get error: %s",
|
||||
db->hdb_name, strerror(code));
|
||||
return code;
|
||||
}
|
||||
if(code == 1) {
|
||||
@@ -222,8 +222,8 @@ DB__put(krb5_context context, HDB *db, int replace,
|
||||
db->hdb_unlock(context, db);
|
||||
if(code < 0) {
|
||||
code = errno;
|
||||
krb5_set_error_string(context, "Database %s put error: %s",
|
||||
db->hdb_name, strerror(code));
|
||||
krb5_set_error_message(context, code, "Database %s put error: %s",
|
||||
db->hdb_name, strerror(code));
|
||||
return code;
|
||||
}
|
||||
if(code == 1) {
|
||||
@@ -248,8 +248,8 @@ DB__del(krb5_context context, HDB *db, krb5_data key)
|
||||
db->hdb_unlock(context, db);
|
||||
if(code == 1) {
|
||||
code = errno;
|
||||
krb5_set_error_string(context, "Database %s put error: %s",
|
||||
db->hdb_name, strerror(code));
|
||||
krb5_set_error_message(context, code, "Database %s put error: %s",
|
||||
db->hdb_name, strerror(code));
|
||||
return code;
|
||||
}
|
||||
if(code < 0)
|
||||
@@ -265,7 +265,7 @@ DB_open(krb5_context context, HDB *db, int flags, mode_t mode)
|
||||
|
||||
asprintf(&fn, "%s.db", db->hdb_name);
|
||||
if (fn == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
db->hdb_db = dbopen(fn, flags, mode, DB_BTREE, NULL);
|
||||
@@ -275,7 +275,7 @@ DB_open(krb5_context context, HDB *db, int flags, mode_t mode)
|
||||
db->hdb_db = dbopen(db->hdb_name, flags, mode, DB_BTREE, NULL);
|
||||
if(db->hdb_db == NULL) {
|
||||
ret = errno;
|
||||
krb5_set_error_string(context, "dbopen (%s): %s",
|
||||
krb5_set_error_message(context, ret, "dbopen (%s): %s",
|
||||
db->hdb_name, strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
@@ -289,7 +289,7 @@ DB_open(krb5_context context, HDB *db, int flags, mode_t mode)
|
||||
}
|
||||
if (ret) {
|
||||
DB_close(context, db);
|
||||
krb5_set_error_string(context, "hdb_open: failed %s database %s",
|
||||
krb5_set_error_message(context, ret, "hdb_open: failed %s database %s",
|
||||
(flags & O_ACCMODE) == O_RDONLY ?
|
||||
"checking format of" : "initialize",
|
||||
db->hdb_name);
|
||||
@@ -303,16 +303,16 @@ hdb_db_create(krb5_context context, HDB **db,
|
||||
{
|
||||
*db = calloc(1, sizeof(**db));
|
||||
if (*db == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
(*db)->hdb_db = NULL;
|
||||
(*db)->hdb_name = strdup(filename);
|
||||
if ((*db)->hdb_name == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
free(*db);
|
||||
*db = NULL;
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
(*db)->hdb_master_key_set = 0;
|
||||
|
@@ -125,7 +125,7 @@ DB_seq(krb5_context context, HDB *db,
|
||||
entry->entry.principal = malloc(sizeof(*entry->entry.principal));
|
||||
if (entry->entry.principal == NULL) {
|
||||
hdb_free_entry (context, entry);
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
} else {
|
||||
hdb_key2principal(context, &key_data, entry->entry.principal);
|
||||
@@ -264,7 +264,7 @@ DB_open(krb5_context context, HDB *db, int flags, mode_t mode)
|
||||
|
||||
asprintf(&fn, "%s.db", db->hdb_name);
|
||||
if (fn == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
db_create(&d, NULL, 0);
|
||||
@@ -289,7 +289,7 @@ DB_open(krb5_context context, HDB *db, int flags, mode_t mode)
|
||||
|
||||
if (ret) {
|
||||
free(fn);
|
||||
krb5_set_error_string(context, "opening %s: %s",
|
||||
krb5_set_error_message(context, ret, "opening %s: %s",
|
||||
db->hdb_name, strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
@@ -297,7 +297,7 @@ DB_open(krb5_context context, HDB *db, int flags, mode_t mode)
|
||||
|
||||
ret = (*d->cursor)(d, NULL, &dbc, 0);
|
||||
if (ret) {
|
||||
krb5_set_error_string(context, "d->cursor: %s", strerror(ret));
|
||||
krb5_set_error_message(context, ret, "d->cursor: %s", strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
db->hdb_dbc = dbc;
|
||||
@@ -310,10 +310,10 @@ DB_open(krb5_context context, HDB *db, int flags, mode_t mode)
|
||||
return 0;
|
||||
if (ret) {
|
||||
DB_close(context, db);
|
||||
krb5_set_error_string(context, "hdb_open: failed %s database %s",
|
||||
(flags & O_ACCMODE) == O_RDONLY ?
|
||||
"checking format of" : "initialize",
|
||||
db->hdb_name);
|
||||
krb5_set_error_message(context, ret, "hdb_open: failed %s database %s",
|
||||
(flags & O_ACCMODE) == O_RDONLY ?
|
||||
"checking format of" : "initialize",
|
||||
db->hdb_name);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -325,16 +325,16 @@ hdb_db_create(krb5_context context, HDB **db,
|
||||
{
|
||||
*db = calloc(1, sizeof(**db));
|
||||
if (*db == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
(*db)->hdb_db = NULL;
|
||||
(*db)->hdb_name = strdup(filename);
|
||||
if ((*db)->hdb_name == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
free(*db);
|
||||
*db = NULL;
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
(*db)->hdb_master_key_set = 0;
|
||||
|
@@ -63,7 +63,7 @@ get_dbinfo(krb5_context context,
|
||||
|
||||
di = calloc(1, sizeof(*di));
|
||||
if (di == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
di->label = strdup(label);
|
||||
|
@@ -53,8 +53,9 @@ hdb_entry_check_mandatory(krb5_context context, const hdb_entry *ent)
|
||||
choice_HDB_extension_data_asn1_ellipsis)
|
||||
continue;
|
||||
if (ent->extensions->val[i].mandatory) {
|
||||
krb5_set_error_string(context, "Principal have unknown "
|
||||
"mandatory extension");
|
||||
krb5_set_error_message(context, HDB_ERR_MANDATORY_OPTION,
|
||||
"Principal have unknown "
|
||||
"mandatory extension");
|
||||
return HDB_ERR_MANDATORY_OPTION;
|
||||
}
|
||||
}
|
||||
@@ -95,7 +96,7 @@ hdb_replace_extension(krb5_context context,
|
||||
if (entry->extensions == NULL) {
|
||||
entry->extensions = calloc(1, sizeof(*entry->extensions));
|
||||
if (entry->extensions == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
} else if (ext->data.element != choice_HDB_extension_data_asn1_ellipsis) {
|
||||
@@ -120,8 +121,8 @@ hdb_replace_extension(krb5_context context,
|
||||
&replace_class, &replace_type, &replace_tag,
|
||||
&size);
|
||||
if (ret) {
|
||||
krb5_set_error_string(context, "hdb: failed to decode "
|
||||
"replacement hdb extention");
|
||||
krb5_set_error_message(context, ret, "hdb: failed to decode "
|
||||
"replacement hdb extention");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -136,8 +137,8 @@ hdb_replace_extension(krb5_context context,
|
||||
&list_class, &list_type, &list_tag,
|
||||
&size);
|
||||
if (ret) {
|
||||
krb5_set_error_string(context, "hdb: failed to decode "
|
||||
"present hdb extention");
|
||||
krb5_set_error_message(context, ret, "hdb: failed to decode "
|
||||
"present hdb extention");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -153,15 +154,15 @@ hdb_replace_extension(krb5_context context,
|
||||
free_HDB_extension(ext2);
|
||||
ret = copy_HDB_extension(ext, ext2);
|
||||
if (ret)
|
||||
krb5_set_error_string(context, "hdb: failed to copy replacement "
|
||||
"hdb extention");
|
||||
krb5_set_error_message(context, ret, "hdb: failed to copy replacement "
|
||||
"hdb extention");
|
||||
return ret;
|
||||
}
|
||||
|
||||
es = realloc(entry->extensions->val,
|
||||
(entry->extensions->len+1)*sizeof(entry->extensions->val[0]));
|
||||
if (es == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
entry->extensions->val = es;
|
||||
@@ -171,7 +172,7 @@ hdb_replace_extension(krb5_context context,
|
||||
if (ret == 0)
|
||||
entry->extensions->len++;
|
||||
else
|
||||
krb5_set_error_string(context, "hdb: failed to copy new extension");
|
||||
krb5_set_error_message(context, ret, "hdb: failed to copy new extension");
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -283,8 +284,9 @@ hdb_entry_get_password(krb5_context context, HDB *db,
|
||||
db->hdb_master_key);
|
||||
|
||||
if (key == NULL) {
|
||||
krb5_set_error_string(context, "master key %d missing",
|
||||
*ext->data.u.password.mkvno);
|
||||
krb5_set_error_message(context, HDB_ERR_NO_MKEY,
|
||||
"master key %d missing",
|
||||
*ext->data.u.password.mkvno);
|
||||
return HDB_ERR_NO_MKEY;
|
||||
}
|
||||
|
||||
@@ -302,7 +304,7 @@ hdb_entry_get_password(krb5_context context, HDB *db,
|
||||
|
||||
str = pw.data;
|
||||
if (str[pw.length - 1] != '\0') {
|
||||
krb5_set_error_string(context, "password malformated");
|
||||
krb5_set_error_message(context, EINVAL, "password malformated");
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
@@ -310,7 +312,7 @@ hdb_entry_get_password(krb5_context context, HDB *db,
|
||||
|
||||
der_free_octet_string(&pw);
|
||||
if (*p == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
return 0;
|
||||
@@ -318,7 +320,7 @@ hdb_entry_get_password(krb5_context context, HDB *db,
|
||||
|
||||
ret = krb5_unparse_name(context, entry->principal, &str);
|
||||
if (ret == 0) {
|
||||
krb5_set_error_string(context, "no password attributefor %s", str);
|
||||
krb5_set_error_message(context, ENOENT, "no password attributefor %s", str);
|
||||
free(str);
|
||||
} else
|
||||
krb5_clear_error_string(context);
|
||||
@@ -341,8 +343,9 @@ hdb_entry_set_password(krb5_context context, HDB *db,
|
||||
|
||||
key = _hdb_find_master_key(NULL, db->hdb_master_key);
|
||||
if (key == NULL) {
|
||||
krb5_set_error_string(context, "hdb_entry_set_password: "
|
||||
"failed to find masterkey");
|
||||
krb5_set_error_message(context, HDB_ERR_NO_MKEY,
|
||||
"hdb_entry_set_password: "
|
||||
"failed to find masterkey");
|
||||
return HDB_ERR_NO_MKEY;
|
||||
}
|
||||
|
||||
@@ -356,7 +359,7 @@ hdb_entry_set_password(krb5_context context, HDB *db,
|
||||
malloc(sizeof(*ext.data.u.password.mkvno));
|
||||
if (ext.data.u.password.mkvno == NULL) {
|
||||
free_HDB_extension(&ext);
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
*ext.data.u.password.mkvno = _hdb_mkey_version(key);
|
||||
@@ -367,7 +370,7 @@ hdb_entry_set_password(krb5_context context, HDB *db,
|
||||
ret = krb5_data_copy(&ext.data.u.password.password,
|
||||
p, strlen(p) + 1);
|
||||
if (ret) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ret, "malloc: out of memory");
|
||||
free_HDB_extension(&ext);
|
||||
return ret;
|
||||
}
|
||||
|
@@ -121,8 +121,9 @@ LDAP_no_size_limit(krb5_context context, LDAP *lp)
|
||||
|
||||
ret = ldap_set_option(lp, LDAP_OPT_SIZELIMIT, (const void *)&limit);
|
||||
if (ret != LDAP_SUCCESS) {
|
||||
krb5_set_error_string(context, "ldap_set_option: %s",
|
||||
ldap_err2string(ret));
|
||||
krb5_set_error_message(context, HDB_ERR_BADVERSION,
|
||||
"ldap_set_option: %s",
|
||||
ldap_err2string(ret));
|
||||
return HDB_ERR_BADVERSION;
|
||||
}
|
||||
return 0;
|
||||
@@ -295,8 +296,9 @@ LDAP_addmod_integer(krb5_context context,
|
||||
|
||||
ret = asprintf(&buf, "%ld", l);
|
||||
if (ret < 0) {
|
||||
krb5_set_error_string(context, "asprintf: out of memory:");
|
||||
return ret;
|
||||
krb5_set_error_message(context, ENOMEM,
|
||||
"asprintf: out of memory:");
|
||||
return ENOMEM;
|
||||
}
|
||||
ret = LDAP_addmod(mods, modop, attribute, buf);
|
||||
free (buf);
|
||||
@@ -638,9 +640,9 @@ LDAP_entry2mods(krb5_context context, HDB * db, hdb_entry_ex * ent,
|
||||
/* store in ntPassword, not krb5key */
|
||||
ret = hex_encode(nt, 16, &ntHexPassword);
|
||||
if (ret < 0) {
|
||||
krb5_set_error_string(context, "hdb-ldap: failed to "
|
||||
"hex encode key");
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret, "hdb-ldap: failed to "
|
||||
"hex encode key");
|
||||
goto out;
|
||||
}
|
||||
ret = LDAP_addmod(&mods, LDAP_MOD_REPLACE, "sambaNTPassword",
|
||||
@@ -751,10 +753,10 @@ LDAP_dn2principal(krb5_context context, HDB * db, const char *dn,
|
||||
NULL, NULL, NULL,
|
||||
0, &res);
|
||||
if (check_ldap(context, db, rc)) {
|
||||
krb5_set_error_string(context, "ldap_search_ext_s: "
|
||||
"filter: %s error: %s",
|
||||
filter, ldap_err2string(rc));
|
||||
ret = HDB_ERR_NOENTRY;
|
||||
krb5_set_error_message(context, ret, "ldap_search_ext_s: "
|
||||
"filter: %s error: %s",
|
||||
filter, ldap_err2string(rc));
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -799,8 +801,8 @@ LDAP__lookup_princ(krb5_context context,
|
||||
"(&(objectClass=krb5Principal)(krb5PrincipalName=%s))",
|
||||
princname);
|
||||
if (rc < 0) {
|
||||
krb5_set_error_string(context, "asprintf: out of memory");
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret, "asprintf: out of memory");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -814,10 +816,10 @@ LDAP__lookup_princ(krb5_context context,
|
||||
NULL, NULL, NULL,
|
||||
0, msg);
|
||||
if (check_ldap(context, db, rc)) {
|
||||
krb5_set_error_string(context, "ldap_search_ext_s: "
|
||||
ret = HDB_ERR_NOENTRY;
|
||||
krb5_set_error_message(context, ret, "ldap_search_ext_s: "
|
||||
"filter: %s - error: %s",
|
||||
filter, ldap_err2string(rc));
|
||||
ret = HDB_ERR_NOENTRY;
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -831,8 +833,8 @@ LDAP__lookup_princ(krb5_context context,
|
||||
"(&(|(objectClass=sambaSamAccount)(objectClass=%s))(uid=%s))",
|
||||
structural_object, userid);
|
||||
if (rc < 0) {
|
||||
krb5_set_error_string(context, "asprintf: out of memory");
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret, "asprintf: out of memory");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -845,10 +847,10 @@ LDAP__lookup_princ(krb5_context context,
|
||||
NULL, NULL, NULL,
|
||||
0, msg);
|
||||
if (check_ldap(context, db, rc)) {
|
||||
krb5_set_error_string(context,
|
||||
"ldap_search_ext_s: filter: %s error: %s",
|
||||
filter, ldap_err2string(rc));
|
||||
ret = HDB_ERR_NOENTRY;
|
||||
krb5_set_error_message(context, ret,
|
||||
"ldap_search_ext_s: filter: %s error: %s",
|
||||
filter, ldap_err2string(rc));
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
@@ -930,7 +932,8 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
|
||||
if (ret)
|
||||
goto out;
|
||||
} else {
|
||||
krb5_set_error_string(context, "hdb-ldap: ldap entry missing"
|
||||
krb5_set_error_message(context, HDB_ERR_NOENTRY,
|
||||
"hdb-ldap: ldap entry missing"
|
||||
"principal name");
|
||||
return HDB_ERR_NOENTRY;
|
||||
}
|
||||
@@ -954,8 +957,8 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
|
||||
ent->entry.keys.len = ldap_count_values_len(keys);
|
||||
ent->entry.keys.val = (Key *) calloc(ent->entry.keys.len, sizeof(Key));
|
||||
if (ent->entry.keys.val == NULL) {
|
||||
krb5_set_error_string(context, "calloc: out of memory");
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret, "calloc: out of memory");
|
||||
goto out;
|
||||
}
|
||||
for (i = 0; i < ent->entry.keys.len; i++) {
|
||||
@@ -984,16 +987,16 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
|
||||
|
||||
ent->entry.etypes = malloc(sizeof(*(ent->entry.etypes)));
|
||||
if (ent->entry.etypes == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret,"malloc: out of memory");
|
||||
goto out;
|
||||
}
|
||||
ent->entry.etypes->len = ldap_count_values_len(vals);
|
||||
ent->entry.etypes->val = calloc(ent->entry.etypes->len, sizeof(int));
|
||||
if (ent->entry.etypes->val == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
ent->entry.etypes->len = 0;
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret, "malloc: out of memory");
|
||||
ent->entry.etypes->len = 0;
|
||||
goto out;
|
||||
}
|
||||
for (i = 0; i < ent->entry.etypes->len; i++) {
|
||||
@@ -1001,8 +1004,8 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
|
||||
|
||||
buf = malloc(vals[i]->bv_len + 1);
|
||||
if (buf == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret, "malloc: out of memory");
|
||||
goto out;
|
||||
}
|
||||
memcpy(buf, vals[i]->bv_val, vals[i]->bv_len);
|
||||
@@ -1031,8 +1034,8 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
|
||||
(ent->entry.keys.len + 1) * sizeof(ent->entry.keys.val[0]));
|
||||
if (keys == NULL) {
|
||||
free(ntPasswordIN);
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret, "malloc: out of memory");
|
||||
goto out;
|
||||
}
|
||||
ent->entry.keys.val = keys;
|
||||
@@ -1040,7 +1043,7 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
|
||||
ent->entry.keys.val[ent->entry.keys.len].key.keytype = ETYPE_ARCFOUR_HMAC_MD5;
|
||||
ret = krb5_data_alloc (&ent->entry.keys.val[ent->entry.keys.len].key.keyvalue, 16);
|
||||
if (ret) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ret, "malloc: out of memory");
|
||||
free(ntPasswordIN);
|
||||
ret = ENOMEM;
|
||||
goto out;
|
||||
@@ -1052,8 +1055,8 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
|
||||
if (ent->entry.etypes == NULL) {
|
||||
ent->entry.etypes = malloc(sizeof(*(ent->entry.etypes)));
|
||||
if (ent->entry.etypes == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret, "malloc: out of memory");
|
||||
goto out;
|
||||
}
|
||||
ent->entry.etypes->val = NULL;
|
||||
@@ -1069,8 +1072,8 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
|
||||
(ent->entry.etypes->len + 1) *
|
||||
sizeof(ent->entry.etypes->val[0]));
|
||||
if (etypes == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret, "malloc: out of memory");
|
||||
goto out;
|
||||
}
|
||||
ent->entry.etypes->val = etypes;
|
||||
@@ -1098,8 +1101,8 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
|
||||
|
||||
ent->entry.modified_by = (Event *) malloc(sizeof(Event));
|
||||
if (ent->entry.modified_by == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret, "malloc: out of memory");
|
||||
goto out;
|
||||
}
|
||||
ret = LDAP_get_generalized_time_value(db, msg, "modifyTimestamp",
|
||||
@@ -1116,8 +1119,8 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
|
||||
|
||||
ent->entry.valid_start = malloc(sizeof(*ent->entry.valid_start));
|
||||
if (ent->entry.valid_start == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret, "malloc: out of memory");
|
||||
goto out;
|
||||
}
|
||||
ret = LDAP_get_generalized_time_value(db, msg, "krb5ValidStart",
|
||||
@@ -1130,8 +1133,8 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
|
||||
|
||||
ent->entry.valid_end = malloc(sizeof(*ent->entry.valid_end));
|
||||
if (ent->entry.valid_end == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret, "malloc: out of memory");
|
||||
goto out;
|
||||
}
|
||||
ret = LDAP_get_generalized_time_value(db, msg, "krb5ValidEnd",
|
||||
@@ -1147,8 +1150,8 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
|
||||
if (ent->entry.valid_end == NULL) {
|
||||
ent->entry.valid_end = malloc(sizeof(*ent->entry.valid_end));
|
||||
if (ent->entry.valid_end == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret, "malloc: out of memory");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
@@ -1157,8 +1160,8 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
|
||||
|
||||
ent->entry.pw_end = malloc(sizeof(*ent->entry.pw_end));
|
||||
if (ent->entry.pw_end == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret, "malloc: out of memory");
|
||||
goto out;
|
||||
}
|
||||
ret = LDAP_get_generalized_time_value(db, msg, "krb5PasswordEnd",
|
||||
@@ -1174,8 +1177,8 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
|
||||
if (ent->entry.pw_end == NULL) {
|
||||
ent->entry.pw_end = malloc(sizeof(*ent->entry.pw_end));
|
||||
if (ent->entry.pw_end == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret, "malloc: out of memory");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
@@ -1192,8 +1195,8 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
|
||||
|
||||
ent->entry.max_life = malloc(sizeof(*ent->entry.max_life));
|
||||
if (ent->entry.max_life == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret, "malloc: out of memory");
|
||||
goto out;
|
||||
}
|
||||
ret = LDAP_get_integer_value(db, msg, "krb5MaxLife", &max_life);
|
||||
@@ -1209,8 +1212,8 @@ LDAP_message2entry(krb5_context context, HDB * db, LDAPMessage * msg,
|
||||
|
||||
ent->entry.max_renew = malloc(sizeof(*ent->entry.max_renew));
|
||||
if (ent->entry.max_renew == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret, "malloc: out of memory");
|
||||
goto out;
|
||||
}
|
||||
ret = LDAP_get_integer_value(db, msg, "krb5MaxRenew", &max_renew);
|
||||
@@ -1370,13 +1373,13 @@ LDAP_seq(krb5_context context, HDB * db, unsigned flags, hdb_entry_ex * entry)
|
||||
parserc =
|
||||
ldap_parse_result(HDB2LDAP(db), e, NULL, NULL, NULL,
|
||||
NULL, NULL, 1);
|
||||
ret = HDB_ERR_NOENTRY;
|
||||
if (parserc != LDAP_SUCCESS
|
||||
&& parserc != LDAP_MORE_RESULTS_TO_RETURN) {
|
||||
krb5_set_error_string(context, "ldap_parse_result: %s",
|
||||
ldap_err2string(parserc));
|
||||
krb5_set_error_message(context, ret, "ldap_parse_result: %s",
|
||||
ldap_err2string(parserc));
|
||||
ldap_abandon_ext(HDB2LDAP(db), msgid, NULL, NULL);
|
||||
}
|
||||
ret = HDB_ERR_NOENTRY;
|
||||
HDBSETMSGID(db, -1);
|
||||
break;
|
||||
case LDAP_SERVER_DOWN:
|
||||
@@ -1471,16 +1474,16 @@ LDAP__connect(krb5_context context, HDB * db)
|
||||
|
||||
rc = ldap_initialize(&((struct hdbldapdb *)db->hdb_db)->h_lp, HDB2URL(db));
|
||||
if (rc != LDAP_SUCCESS) {
|
||||
krb5_set_error_string(context, "ldap_initialize: %s",
|
||||
ldap_err2string(rc));
|
||||
krb5_set_error_message(context, HDB_ERR_NOENTRY, "ldap_initialize: %s",
|
||||
ldap_err2string(rc));
|
||||
return HDB_ERR_NOENTRY;
|
||||
}
|
||||
|
||||
rc = ldap_set_option(HDB2LDAP(db), LDAP_OPT_PROTOCOL_VERSION,
|
||||
(const void *)&version);
|
||||
if (rc != LDAP_SUCCESS) {
|
||||
krb5_set_error_string(context, "ldap_set_option: %s",
|
||||
ldap_err2string(rc));
|
||||
krb5_set_error_message(context, HDB_ERR_BADVERSION,
|
||||
"ldap_set_option: %s", ldap_err2string(rc));
|
||||
LDAP_close(context, db);
|
||||
return HDB_ERR_BADVERSION;
|
||||
}
|
||||
@@ -1488,8 +1491,8 @@ LDAP__connect(krb5_context context, HDB * db)
|
||||
rc = ldap_sasl_bind_s(HDB2LDAP(db), NULL, "EXTERNAL", &bv,
|
||||
NULL, NULL, NULL);
|
||||
if (rc != LDAP_SUCCESS) {
|
||||
krb5_set_error_string(context, "ldap_sasl_bind_s: %s",
|
||||
ldap_err2string(rc));
|
||||
krb5_set_error_message(context, HDB_ERR_BADVERSION,
|
||||
"ldap_sasl_bind_s: %s", ldap_err2string(rc));
|
||||
LDAP_close(context, db);
|
||||
return HDB_ERR_BADVERSION;
|
||||
}
|
||||
@@ -1581,8 +1584,8 @@ LDAP_store(krb5_context context, HDB * db, unsigned flags,
|
||||
if (e == NULL) {
|
||||
ret = asprintf(&dn, "krb5PrincipalName=%s,%s", name, HDB2CREATE(db));
|
||||
if (ret < 0) {
|
||||
krb5_set_error_string(context, "asprintf: out of memory");
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret, "asprintf: out of memory");
|
||||
goto out;
|
||||
}
|
||||
} else if (flags & HDB_F_REPLACE) {
|
||||
@@ -1609,9 +1612,9 @@ LDAP_store(krb5_context context, HDB * db, unsigned flags,
|
||||
char *ld_error = NULL;
|
||||
ldap_get_option(HDB2LDAP(db), LDAP_OPT_ERROR_STRING,
|
||||
&ld_error);
|
||||
krb5_set_error_string(context, "%s: %s (DN=%s) %s: %s",
|
||||
errfn, name, dn, ldap_err2string(rc), ld_error);
|
||||
ret = HDB_ERR_CANT_LOCK_DB;
|
||||
krb5_set_error_message(context, ret, "%s: %s (DN=%s) %s: %s",
|
||||
errfn, name, dn, ldap_err2string(rc), ld_error);
|
||||
} else
|
||||
ret = 0;
|
||||
|
||||
@@ -1655,17 +1658,17 @@ LDAP_remove(krb5_context context, HDB *db, krb5_const_principal principal)
|
||||
|
||||
rc = ldap_set_option(HDB2LDAP(db), LDAP_OPT_SIZELIMIT, (const void *)&limit);
|
||||
if (rc != LDAP_SUCCESS) {
|
||||
krb5_set_error_string(context, "ldap_set_option: %s",
|
||||
ldap_err2string(rc));
|
||||
ret = HDB_ERR_BADVERSION;
|
||||
krb5_set_error_message(context, ret, "ldap_set_option: %s",
|
||||
ldap_err2string(rc));
|
||||
goto out;
|
||||
}
|
||||
|
||||
rc = ldap_delete_ext_s(HDB2LDAP(db), dn, NULL, NULL );
|
||||
if (check_ldap(context, db, rc)) {
|
||||
krb5_set_error_string(context, "ldap_delete_ext_s: %s",
|
||||
ldap_err2string(rc));
|
||||
ret = HDB_ERR_CANT_LOCK_DB;
|
||||
krb5_set_error_message(context, ret, "ldap_delete_ext_s: %s",
|
||||
ldap_err2string(rc));
|
||||
} else
|
||||
ret = 0;
|
||||
|
||||
@@ -1710,7 +1713,7 @@ hdb_ldap_common(krb5_context context,
|
||||
const char *create_base = NULL;
|
||||
|
||||
if (search_base == NULL && search_base[0] == '\0') {
|
||||
krb5_set_error_string(context, "ldap search base not configured");
|
||||
krb5_set_error_message(context, ENOMEM, "ldap search base not configured");
|
||||
return ENOMEM; /* XXX */
|
||||
}
|
||||
|
||||
@@ -1723,7 +1726,7 @@ hdb_ldap_common(krb5_context context,
|
||||
p = default_structural_object;
|
||||
structural_object = strdup(p);
|
||||
if (structural_object == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
}
|
||||
@@ -1734,16 +1737,16 @@ hdb_ldap_common(krb5_context context,
|
||||
|
||||
*db = calloc(1, sizeof(**db));
|
||||
if (*db == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
memset(*db, 0, sizeof(**db));
|
||||
|
||||
h = calloc(1, sizeof(*h));
|
||||
if (h == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
free(*db);
|
||||
*db = NULL;
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
(*db)->hdb_db = h;
|
||||
@@ -1751,8 +1754,8 @@ hdb_ldap_common(krb5_context context,
|
||||
/* XXX */
|
||||
if (asprintf(&(*db)->hdb_name, "ldap:%s", search_base) == -1) {
|
||||
LDAP_destroy(context, *db);
|
||||
krb5_set_error_string(context, "strdup: out of memory");
|
||||
*db = NULL;
|
||||
krb5_set_error_message(context, ENOMEM, "strdup: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
@@ -1760,8 +1763,8 @@ hdb_ldap_common(krb5_context context,
|
||||
h->h_base = strdup(search_base);
|
||||
if (h->h_url == NULL || h->h_base == NULL) {
|
||||
LDAP_destroy(context, *db);
|
||||
krb5_set_error_string(context, "strdup: out of memory");
|
||||
*db = NULL;
|
||||
krb5_set_error_message(context, ENOMEM, "strdup: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
@@ -1773,8 +1776,8 @@ hdb_ldap_common(krb5_context context,
|
||||
h->h_createbase = strdup(create_base);
|
||||
if (h->h_createbase == NULL) {
|
||||
LDAP_destroy(context, *db);
|
||||
krb5_set_error_string(context, "strdup: out of memory");
|
||||
*db = NULL;
|
||||
krb5_set_error_message(context, ENOMEM, "strdup: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
@@ -1812,14 +1815,15 @@ hdb_ldapi_create(krb5_context context, HDB ** db, const char *arg)
|
||||
|
||||
asprintf(&p, "ldapi:%s", arg);
|
||||
if (p == NULL) {
|
||||
krb5_set_error_string(context, "out of memory");
|
||||
*db = NULL;
|
||||
krb5_set_error_message(context, ENOMEM, "out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
search_base = strchr(p + strlen("ldapi://"), ':');
|
||||
if (search_base == NULL) {
|
||||
krb5_set_error_string(context, "search base missing");
|
||||
*db = NULL;
|
||||
krb5_set_error_message(context, HDB_ERR_BADVERSION,
|
||||
"search base missing");
|
||||
return HDB_ERR_BADVERSION;
|
||||
}
|
||||
*search_base = '\0';
|
||||
|
@@ -85,7 +85,8 @@ hdb_next_enctype2key(krb5_context context,
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
krb5_set_error_string(context, "No next enctype %d for hdb-entry",
|
||||
krb5_set_error_message(context, KRB5_PROG_ETYPE_NOSUPP,
|
||||
"No next enctype %d for hdb-entry",
|
||||
(int)enctype);
|
||||
return KRB5_PROG_ETYPE_NOSUPP; /* XXX */
|
||||
}
|
||||
@@ -378,7 +379,7 @@ hdb_list_builtin(krb5_context context, char **list)
|
||||
len += 1;
|
||||
buf = malloc(len);
|
||||
if (buf == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
buf[0] = '\0';
|
||||
|
@@ -153,7 +153,7 @@ parse_key_set(krb5_context context, const char *key,
|
||||
v4 compat, and a cell name for afs compat */
|
||||
salt->saltvalue.data = strdup(buf[i]);
|
||||
if (salt->saltvalue.data == NULL) {
|
||||
krb5_set_error_string(context, "out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
salt->saltvalue.length = strlen(buf[i]);
|
||||
@@ -161,7 +161,7 @@ parse_key_set(krb5_context context, const char *key,
|
||||
}
|
||||
|
||||
if(enctypes == NULL || salt->salttype == 0) {
|
||||
krb5_set_error_string(context, "bad value for default_keys `%s'", key);
|
||||
krb5_set_error_message(context, EINVAL, "bad value for default_keys `%s'", key);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
@@ -173,8 +173,9 @@ parse_key_set(krb5_context context, const char *key,
|
||||
krb5_realm *realm = krb5_princ_realm(context, principal);
|
||||
salt->saltvalue.data = strdup(*realm);
|
||||
if(salt->saltvalue.data == NULL) {
|
||||
krb5_set_error_string(context, "out of memory while "
|
||||
"parsing salt specifiers");
|
||||
krb5_set_error_message(context, ENOMEM,
|
||||
"out of memory while "
|
||||
"parsing salt specifiers");
|
||||
return ENOMEM;
|
||||
}
|
||||
strlwr(salt->saltvalue.data);
|
||||
@@ -185,7 +186,7 @@ parse_key_set(krb5_context context, const char *key,
|
||||
*ret_enctypes = malloc(sizeof(enctypes[0]) * num_enctypes);
|
||||
if (*ret_enctypes == NULL) {
|
||||
krb5_free_salt(context, *salt);
|
||||
krb5_set_error_string(context, "out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
memcpy(*ret_enctypes, enctypes, sizeof(enctypes[0]) * num_enctypes);
|
||||
|
@@ -55,7 +55,7 @@ hdb_resolve(krb5_context context, const char *name, krb5_keytab id)
|
||||
|
||||
d = malloc(sizeof(*d));
|
||||
if(d == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
db = name;
|
||||
@@ -67,7 +67,7 @@ hdb_resolve(krb5_context context, const char *name, krb5_keytab id)
|
||||
d->dbname = strdup(name);
|
||||
if(d->dbname == NULL) {
|
||||
free(d);
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ hdb_resolve(krb5_context context, const char *name, krb5_keytab id)
|
||||
d->dbname = malloc(mkey - db + 1);
|
||||
if(d->dbname == NULL) {
|
||||
free(d);
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
memmove(d->dbname, db, mkey - db);
|
||||
@@ -89,7 +89,7 @@ hdb_resolve(krb5_context context, const char *name, krb5_keytab id)
|
||||
if(d->mkey == NULL) {
|
||||
free(d->dbname);
|
||||
free(d);
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
}
|
||||
|
@@ -67,7 +67,7 @@ hdb_process_master_key(krb5_context context,
|
||||
|
||||
*mkey = calloc(1, sizeof(**mkey));
|
||||
if(*mkey == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
(*mkey)->keytab.vno = kvno;
|
||||
@@ -159,8 +159,8 @@ read_master_mit(krb5_context context, const char *filename,
|
||||
fd = open(filename, O_RDONLY | O_BINARY);
|
||||
if(fd < 0) {
|
||||
int save_errno = errno;
|
||||
krb5_set_error_string(context, "failed to open %s: %s", filename,
|
||||
strerror(save_errno));
|
||||
krb5_set_error_message(context, save_errno, "failed to open %s: %s",
|
||||
filename, strerror(save_errno));
|
||||
return save_errno;
|
||||
}
|
||||
sp = krb5_storage_from_fd(fd);
|
||||
@@ -176,9 +176,9 @@ read_master_mit(krb5_context context, const char *filename,
|
||||
#else
|
||||
ret = krb5_ret_int16(sp, &enctype);
|
||||
if((htons(enctype) & 0xff00) == 0x3000) {
|
||||
krb5_set_error_string(context, "unknown keytype in %s: %#x, expected %#x",
|
||||
filename, htons(enctype), 0x3000);
|
||||
ret = HEIM_ERR_BAD_MKEY;
|
||||
krb5_set_error_message(context, ret, "unknown keytype in %s: %#x, expected %#x",
|
||||
filename, htons(enctype), 0x3000);
|
||||
goto out;
|
||||
}
|
||||
key.keytype = enctype;
|
||||
@@ -209,7 +209,7 @@ read_master_encryptionkey(krb5_context context, const char *filename,
|
||||
fd = open(filename, O_RDONLY | O_BINARY);
|
||||
if(fd < 0) {
|
||||
int save_errno = errno;
|
||||
krb5_set_error_string(context, "failed to open %s: %s",
|
||||
krb5_set_error_message(context, save_errno, "failed to open %s: %s",
|
||||
filename, strerror(save_errno));
|
||||
return save_errno;
|
||||
}
|
||||
@@ -218,7 +218,7 @@ read_master_encryptionkey(krb5_context context, const char *filename,
|
||||
close(fd);
|
||||
if(len < 0) {
|
||||
int save_errno = errno;
|
||||
krb5_set_error_string(context, "error reading %s: %s",
|
||||
krb5_set_error_message(context, save_errno, "error reading %s: %s",
|
||||
filename, strerror(save_errno));
|
||||
return save_errno;
|
||||
}
|
||||
@@ -255,8 +255,8 @@ read_master_krb4(krb5_context context, const char *filename,
|
||||
fd = open(filename, O_RDONLY | O_BINARY);
|
||||
if(fd < 0) {
|
||||
int save_errno = errno;
|
||||
krb5_set_error_string(context, "failed to open %s: %s",
|
||||
filename, strerror(save_errno));
|
||||
krb5_set_error_message(context, save_errno, "failed to open %s: %s",
|
||||
filename, strerror(save_errno));
|
||||
return save_errno;
|
||||
}
|
||||
|
||||
@@ -264,12 +264,13 @@ read_master_krb4(krb5_context context, const char *filename,
|
||||
close(fd);
|
||||
if(len < 0) {
|
||||
int save_errno = errno;
|
||||
krb5_set_error_string(context, "error reading %s: %s",
|
||||
filename, strerror(save_errno));
|
||||
krb5_set_error_message(context, save_errno, "error reading %s: %s",
|
||||
filename, strerror(save_errno));
|
||||
return save_errno;
|
||||
}
|
||||
if(len != 8) {
|
||||
krb5_set_error_string(context, "bad contents of %s", filename);
|
||||
krb5_set_error_message(context, HEIM_ERR_EOF,
|
||||
"bad contents of %s", filename);
|
||||
return HEIM_ERR_EOF; /* XXX file might be too large */
|
||||
}
|
||||
|
||||
@@ -303,14 +304,14 @@ hdb_read_master_key(krb5_context context, const char *filename,
|
||||
f = fopen(filename, "r");
|
||||
if(f == NULL) {
|
||||
int save_errno = errno;
|
||||
krb5_set_error_string(context, "failed to open %s: %s",
|
||||
filename, strerror(save_errno));
|
||||
krb5_set_error_message(context, save_errno, "failed to open %s: %s",
|
||||
filename, strerror(save_errno));
|
||||
return save_errno;
|
||||
}
|
||||
|
||||
if(fread(buf, 1, 2, f) != 2) {
|
||||
krb5_set_error_string(context, "end of file reading %s", filename);
|
||||
fclose(f);
|
||||
krb5_set_error_message(context, HEIM_ERR_EOF, "end of file reading %s", filename);
|
||||
return HEIM_ERR_EOF;
|
||||
}
|
||||
|
||||
|
@@ -110,9 +110,9 @@ NDBM_seq(krb5_context context, HDB *db,
|
||||
if (ret == 0 && entry->entry.principal == NULL) {
|
||||
entry->entry.principal = malloc (sizeof(*entry->entry.principal));
|
||||
if (entry->entry.principal == NULL) {
|
||||
ret = ENOMEM;
|
||||
hdb_free_entry (context, entry);
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret, "malloc: out of memory");
|
||||
} else {
|
||||
hdb_key2principal (context, &key_data, entry->entry.principal);
|
||||
}
|
||||
@@ -152,15 +152,15 @@ NDBM_rename(krb5_context context, HDB *db, const char *new_name)
|
||||
asprintf(&new_lock, "%s.lock", new_name);
|
||||
if(new_lock == NULL) {
|
||||
db->hdb_unlock(context, db);
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
lock_fd = open(new_lock, O_RDWR | O_CREAT, 0600);
|
||||
if(lock_fd < 0) {
|
||||
ret = errno;
|
||||
db->hdb_unlock(context, db);
|
||||
krb5_set_error_string(context, "open(%s): %s", new_lock,
|
||||
strerror(ret));
|
||||
krb5_set_error_message(context, ret, "open(%s): %s", new_lock,
|
||||
strerror(ret));
|
||||
free(new_lock);
|
||||
return ret;
|
||||
}
|
||||
@@ -188,7 +188,7 @@ NDBM_rename(krb5_context context, HDB *db, const char *new_name)
|
||||
if(ret) {
|
||||
ret = errno;
|
||||
close(lock_fd);
|
||||
krb5_set_error_string(context, "rename: %s", strerror(ret));
|
||||
krb5_set_error_message(context, ret, "rename: %s", strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -284,13 +284,13 @@ NDBM_open(krb5_context context, HDB *db, int flags, mode_t mode)
|
||||
char *lock_file;
|
||||
|
||||
if(d == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
asprintf(&lock_file, "%s.lock", (char*)db->hdb_name);
|
||||
if(lock_file == NULL) {
|
||||
free(d);
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
d->db = dbm_open((char*)db->hdb_name, flags, mode);
|
||||
@@ -298,8 +298,8 @@ NDBM_open(krb5_context context, HDB *db, int flags, mode_t mode)
|
||||
ret = errno;
|
||||
free(d);
|
||||
free(lock_file);
|
||||
krb5_set_error_string(context, "dbm_open(%s): %s", db->hdb_name,
|
||||
strerror(ret));
|
||||
krb5_set_error_message(context, ret, "dbm_open(%s): %s", db->hdb_name,
|
||||
strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
d->lock_fd = open(lock_file, O_RDWR | O_CREAT, 0600);
|
||||
@@ -307,8 +307,8 @@ NDBM_open(krb5_context context, HDB *db, int flags, mode_t mode)
|
||||
ret = errno;
|
||||
dbm_close(d->db);
|
||||
free(d);
|
||||
krb5_set_error_string(context, "open(%s): %s", lock_file,
|
||||
strerror(ret));
|
||||
krb5_set_error_message(context, ret, "open(%s): %s", lock_file,
|
||||
strerror(ret));
|
||||
free(lock_file);
|
||||
return ret;
|
||||
}
|
||||
@@ -322,10 +322,10 @@ NDBM_open(krb5_context context, HDB *db, int flags, mode_t mode)
|
||||
return 0;
|
||||
if (ret) {
|
||||
NDBM_close(context, db);
|
||||
krb5_set_error_string(context, "hdb_open: failed %s database %s",
|
||||
(flags & O_ACCMODE) == O_RDONLY ?
|
||||
"checking format of" : "initialize",
|
||||
db->hdb_name);
|
||||
krb5_set_error_message(context, ret, "hdb_open: failed %s database %s",
|
||||
(flags & O_ACCMODE) == O_RDONLY ?
|
||||
"checking format of" : "initialize",
|
||||
db->hdb_name);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -336,16 +336,16 @@ hdb_ndbm_create(krb5_context context, HDB **db,
|
||||
{
|
||||
*db = calloc(1, sizeof(**db));
|
||||
if (*db == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
(*db)->hdb_db = NULL;
|
||||
(*db)->hdb_name = strdup(filename);
|
||||
if ((*db)->hdb_name == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
free(*db);
|
||||
*db = NULL;
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
(*db)->hdb_master_key_set = 0;
|
||||
|
@@ -69,7 +69,7 @@ append_string(krb5_context context, krb5_storage *sp, const char *fmt, ...)
|
||||
vasprintf(&s, fmt, ap);
|
||||
va_end(ap);
|
||||
if(s == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
ret = krb5_storage_write(sp, s, strlen(s));
|
||||
@@ -223,7 +223,7 @@ entry2string_int (krb5_context context, krb5_storage *sp, hdb_entry *ent)
|
||||
|
||||
if (hex_encode(d, size, &p) < 0) {
|
||||
free(d);
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ hdb_entry2string (krb5_context context, hdb_entry *ent, char **str)
|
||||
|
||||
sp = krb5_storage_emem();
|
||||
if(sp == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ hdb_print_entry(krb5_context context, HDB *db, hdb_entry_ex *entry, void *data)
|
||||
fflush(f);
|
||||
sp = krb5_storage_from_fd(fileno(f));
|
||||
if(sp == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user