Use strerror_r

This commit is contained in:
Love Hornquist Astrand
2009-10-12 09:34:37 -07:00
parent fd042b7656
commit f5e2873be2

View File

@@ -95,13 +95,15 @@ _krb5_xlock(krb5_context context, int fd, krb5_boolean exclusive,
N_("timed out locking cache file %s", "file"), N_("timed out locking cache file %s", "file"),
filename); filename);
break; break;
default: default: {
char buf[128];
strerror_r(ret, buf, sizeof(buf));
krb5_set_error_message(context, ret, krb5_set_error_message(context, ret,
N_("error locking cache file %s: %s", N_("error locking cache file %s: %s",
"file, error"), "file, error"), filename, buf);
filename, strerror(ret));
break; break;
} }
}
return ret; return ret;
} }
@@ -127,12 +129,14 @@ _krb5_xunlock(krb5_context context, int fd)
case EINVAL: /* filesystem doesn't support locking, let the user have it */ case EINVAL: /* filesystem doesn't support locking, let the user have it */
ret = 0; ret = 0;
break; break;
default: default: {
char buf[128];
strerror_r(ret, buf, sizeof(buf));
krb5_set_error_message(context, ret, krb5_set_error_message(context, ret,
N_("Failed to unlock file: %s", ""), N_("Failed to unlock file: %s", ""), buf);
strerror(ret));
break; break;
} }
}
return ret; return ret;
} }
@@ -369,9 +373,11 @@ fcc_open(krb5_context context,
int fd; int fd;
fd = open(filename, flags, mode); fd = open(filename, flags, mode);
if(fd < 0) { if(fd < 0) {
char buf[128];
ret = errno; ret = errno;
strerror_r(ret, buf, sizeof(buf));
krb5_set_error_message(context, ret, N_("open(%s): %s", "file, error"), krb5_set_error_message(context, ret, N_("open(%s): %s", "file, error"),
filename, strerror(ret)); filename, buf);
return ret; return ret;
} }
rk_cloexec(fd); rk_cloexec(fd);
@@ -431,9 +437,11 @@ fcc_initialize(krb5_context context,
fcc_unlock(context, fd); fcc_unlock(context, fd);
if (close(fd) < 0) if (close(fd) < 0)
if (ret == 0) { if (ret == 0) {
char buf[128];
ret = errno; ret = errno;
strerror_r(ret, buf, sizeof(buf));
krb5_set_error_message (context, ret, N_("close %s: %s", ""), krb5_set_error_message (context, ret, N_("close %s: %s", ""),
FILENAME(id), strerror(ret)); FILENAME(id), buf);
} }
return ret; return ret;
} }
@@ -485,9 +493,11 @@ fcc_store_cred(krb5_context context,
fcc_unlock(context, fd); fcc_unlock(context, fd);
if (close(fd) < 0) { if (close(fd) < 0) {
if (ret == 0) { if (ret == 0) {
char buf[128];
strerror_r(ret, buf, sizeof(buf));
ret = errno; ret = errno;
krb5_set_error_message (context, ret, N_("close %s: %s", ""), krb5_set_error_message (context, ret, N_("close %s: %s", ""),
FILENAME(id), strerror(ret)); FILENAME(id), buf);
} }
} }
return ret; return ret;
@@ -875,12 +885,13 @@ fcc_move(krb5_context context, krb5_ccache from, krb5_ccache to)
ret = rename(FILENAME(from), FILENAME(to)); ret = rename(FILENAME(from), FILENAME(to));
if (ret && errno != EXDEV) { if (ret && errno != EXDEV) {
char buf[128];
ret = errno; ret = errno;
strerror_r(ret, buf, sizeof(buf));
krb5_set_error_message(context, ret, krb5_set_error_message(context, ret,
N_("Rename of file from %s " N_("Rename of file from %s "
"to %s failed: %s", ""), "to %s failed: %s", ""),
FILENAME(from), FILENAME(to), FILENAME(from), FILENAME(to), buf);
strerror(ret));
return ret; return ret;
} else if (ret && errno == EXDEV) { } else if (ret && errno == EXDEV) {
/* make a copy and delete the orignal */ /* make a copy and delete the orignal */