- Added upstream rc3 patch

- gssd: initialize fakeseed in prepare_krb5_rfc1964_buffer
- gssd: NULL-terminate buffer after read in read_service_info (try #2)
- gssd: free buffer allocated by gssd_k5_err_msg
- gssd: fix potential double-frees in gssd
- Removed a number of warn_unused_result warnings
This commit is contained in:
Steve Dickson 2009-03-23 21:19:53 +00:00
parent 49b331105f
commit 27d9ad3f5a
2 changed files with 762 additions and 1 deletions

751
nfs-utils-1-1-6-rc3.patch Normal file
View File

@ -0,0 +1,751 @@
diff --git a/support/nfs/cacheio.c b/support/nfs/cacheio.c
index 48292f8..f303734 100644
--- a/support/nfs/cacheio.c
+++ b/support/nfs/cacheio.c
@@ -24,6 +24,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
+#include <errno.h>
void qword_add(char **bpp, int *lp, char *str)
{
@@ -125,7 +126,10 @@ void qword_print(FILE *f, char *str)
char *bp = qword_buf;
int len = sizeof(qword_buf);
qword_add(&bp, &len, str);
- fwrite(qword_buf, bp-qword_buf, 1, f);
+ if (fwrite(qword_buf, bp-qword_buf, 1, f) != 1) {
+ xlog_warn("qword_print: fwrite failed: errno %d (%s)",
+ errno, strerror(errno));
+ }
}
void qword_printhex(FILE *f, char *str, int slen)
@@ -133,7 +137,10 @@ void qword_printhex(FILE *f, char *str, int slen)
char *bp = qword_buf;
int len = sizeof(qword_buf);
qword_addhex(&bp, &len, str, slen);
- fwrite(qword_buf, bp-qword_buf, 1, f);
+ if (fwrite(qword_buf, bp-qword_buf, 1, f) != 1) {
+ xlog_warn("qword_printhex: fwrite failed: errno %d (%s)",
+ errno, strerror(errno));
+ }
}
void qword_printint(FILE *f, int num)
@@ -318,7 +325,10 @@ cache_flush(int force)
sprintf(path, "/proc/net/rpc/%s/flush", cachelist[c]);
fd = open(path, O_RDWR);
if (fd >= 0) {
- write(fd, stime, strlen(stime));
+ if (write(fd, stime, strlen(stime)) != strlen(stime)) {
+ xlog_warn("Writing to '%s' failed: errno %d (%s)",
+ path, errno, strerror(errno));
+ }
close(fd);
}
}
diff --git a/tools/locktest/testlk.c b/tools/locktest/testlk.c
index b392f71..82ed765 100644
--- a/tools/locktest/testlk.c
+++ b/tools/locktest/testlk.c
@@ -81,7 +81,7 @@ main(int argc, char **argv)
if (fl.l_type == F_UNLCK) {
printf("%s: no conflicting lock\n", fname);
} else {
- printf("%s: conflicting lock by %d on (%ld;%ld)\n",
+ printf("%s: conflicting lock by %d on (%lld;%lld)\n",
fname, fl.l_pid, fl.l_start, fl.l_len);
}
return 0;
diff --git a/utils/gssd/context_heimdal.c b/utils/gssd/context_heimdal.c
index ddf064d..6f3b8fd 100644
--- a/utils/gssd/context_heimdal.c
+++ b/utils/gssd/context_heimdal.c
@@ -69,19 +69,19 @@ int write_heimdal_enc_key(char **p, char *end, gss_ctx_id_t ctx)
krb5_context context;
krb5_error_code ret;
int i;
- char *skd, *dkd;
+ char *skd, *dkd, *k5err = NULL;
int code = -1;
if ((ret = krb5_init_context(&context))) {
- printerr(0, "ERROR: initializing krb5_context: %s\n",
- gssd_k5_err_msg(NULL, ret));
+ k5err = gssd_k5_err_msg(NULL, ret);
+ printerr(0, "ERROR: initializing krb5_context: %s\n", k5err);
goto out_err;
}
if ((ret = krb5_auth_con_getlocalsubkey(context,
ctx->auth_context, &key))){
- printerr(0, "ERROR: getting auth_context key: %s\n",
- gssd_k5_err_msg(context, ret));
+ k5err = gssd_k5_err_msg(context, ret);
+ printerr(0, "ERROR: getting auth_context key: %s\n", k5err);
goto out_err_free_context;
}
@@ -97,9 +97,9 @@ int write_heimdal_enc_key(char **p, char *end, gss_ctx_id_t ctx)
enc_key.keyvalue.length = key->keyvalue.length;
if ((enc_key.keyvalue.data =
calloc(1, enc_key.keyvalue.length)) == NULL) {
-
+ k5err = gssd_k5_err_msg(context, ENOMEM);
printerr(0, "ERROR: allocating memory for enc key: %s\n",
- gssd_k5_err_msg(context, ENOMEM));
+ k5err);
goto out_err_free_key;
}
skd = (char *) key->keyvalue.data;
@@ -119,6 +119,7 @@ int write_heimdal_enc_key(char **p, char *end, gss_ctx_id_t ctx)
out_err_free_context:
krb5_free_context(context);
out_err:
+ free(k5err);
printerr(2, "write_heimdal_enc_key: %s\n", code ? "FAILED" : "SUCCESS");
return(code);
}
@@ -128,18 +129,19 @@ int write_heimdal_seq_key(char **p, char *end, gss_ctx_id_t ctx)
krb5_keyblock *key;
krb5_context context;
krb5_error_code ret;
+ char *k5err = NULL;
int code = -1;
if ((ret = krb5_init_context(&context))) {
- printerr(0, "ERROR: initializing krb5_context: %s\n",
- gssd_k5_err_msg(NULL, ret));
+ k5err = gssd_k5_err_msg(NULL, ret);
+ printerr(0, "ERROR: initializing krb5_context: %s\n", k5err);
goto out_err;
}
if ((ret = krb5_auth_con_getlocalsubkey(context,
ctx->auth_context, &key))){
- printerr(0, "ERROR: getting auth_context key: %s\n",
- gssd_k5_err_msg(context, ret));
+ k5err = gssd_k5_err_msg(context, ret);
+ printerr(0, "ERROR: getting auth_context key: %s\n", k5err);
goto out_err_free_context;
}
@@ -162,6 +164,7 @@ int write_heimdal_seq_key(char **p, char *end, gss_ctx_id_t ctx)
out_err_free_context:
krb5_free_context(context);
out_err:
+ free(k5err);
printerr(2, "write_heimdal_seq_key: %s\n", code ? "FAILED" : "SUCCESS");
return(code);
}
diff --git a/utils/gssd/context_lucid.c b/utils/gssd/context_lucid.c
index af7de58..4a682ae 100644
--- a/utils/gssd/context_lucid.c
+++ b/utils/gssd/context_lucid.c
@@ -70,9 +70,10 @@ static int
prepare_krb5_rfc1964_buffer(gss_krb5_lucid_context_v1_t *lctx,
gss_buffer_desc *buf, int32_t *endtime)
{
+#define FAKESEED_SIZE 16
char *p, *end;
static int constant_zero = 0;
- unsigned char fakeseed[16];
+ unsigned char fakeseed[FAKESEED_SIZE];
uint32_t word_send_seq;
gss_krb5_lucid_key_t enc_key;
int i;
@@ -88,6 +89,7 @@ prepare_krb5_rfc1964_buffer(gss_krb5_lucid_context_v1_t *lctx,
*/
memset(&enc_key, 0, sizeof(enc_key));
memset(&fakeoid, 0, sizeof(fakeoid));
+ memset(fakeseed, 0, FAKESEED_SIZE);
if (!(buf->value = calloc(1, MAX_CTX_LEN)))
goto out_err;
@@ -98,7 +100,7 @@ prepare_krb5_rfc1964_buffer(gss_krb5_lucid_context_v1_t *lctx,
/* seed_init and seed not used by kernel anyway */
if (WRITE_BYTES(&p, end, constant_zero)) goto out_err;
- if (write_bytes(&p, end, &fakeseed, 16)) goto out_err;
+ if (write_bytes(&p, end, &fakeseed, FAKESEED_SIZE)) goto out_err;
if (WRITE_BYTES(&p, end, lctx->rfc1964_kd.sign_alg)) goto out_err;
if (WRITE_BYTES(&p, end, lctx->rfc1964_kd.seal_alg)) goto out_err;
diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c
index 295c37d..509946e 100644
--- a/utils/gssd/gssd_proc.c
+++ b/utils/gssd/gssd_proc.c
@@ -107,7 +107,7 @@ static int
read_service_info(char *info_file_name, char **servicename, char **servername,
int *prog, int *vers, char **protocol, int *port) {
#define INFOBUFLEN 256
- char buf[INFOBUFLEN];
+ char buf[INFOBUFLEN + 1];
static char dummy[128];
int nbytes;
static char service[128];
@@ -132,6 +132,7 @@ read_service_info(char *info_file_name, char **servicename, char **servername,
if ((nbytes = read(fd, buf, INFOBUFLEN)) == -1)
goto fail;
close(fd);
+ buf[nbytes] = '\0';
numfields = sscanf(buf,"RPC server: %127s\n"
"service: %127s %15s version %15s\n"
@@ -181,9 +182,10 @@ read_service_info(char *info_file_name, char **servicename, char **servername,
fail:
printerr(0, "ERROR: failed to read service info\n");
if (fd != -1) close(fd);
- if (*servername) free(*servername);
- if (*servicename) free(*servicename);
- if (*protocol) free(*protocol);
+ free(*servername);
+ free(*servicename);
+ free(*protocol);
+ *servicename = *servername = *protocol = NULL;
return -1;
}
@@ -199,10 +201,10 @@ destroy_client(struct clnt_info *clp)
if (clp->dir_fd != -1) close(clp->dir_fd);
if (clp->krb5_fd != -1) close(clp->krb5_fd);
if (clp->spkm3_fd != -1) close(clp->spkm3_fd);
- if (clp->dirname) free(clp->dirname);
- if (clp->servicename) free(clp->servicename);
- if (clp->servername) free(clp->servername);
- if (clp->protocol) free(clp->protocol);
+ free(clp->dirname);
+ free(clp->servicename);
+ free(clp->servername);
+ free(clp->protocol);
free(clp);
}
diff --git a/utils/gssd/krb5_util.c b/utils/gssd/krb5_util.c
index e3c6f5e..3009cc5 100644
--- a/utils/gssd/krb5_util.c
+++ b/utils/gssd/krb5_util.c
@@ -375,6 +375,7 @@ gssd_get_single_krb5_cred(krb5_context context,
time_t now = time(0);
char *cache_type;
char *pname = NULL;
+ char *k5err = NULL;
memset(&my_creds, 0, sizeof(my_creds));
@@ -397,8 +398,8 @@ gssd_get_single_krb5_cred(krb5_context context,
#if HAVE_KRB5_GET_INIT_CREDS_OPT_SET_ADDRESSLESS
code = krb5_get_init_creds_opt_alloc(context, &init_opts);
if (code) {
- printerr(0, "ERROR: %s allocating gic options\n",
- gssd_k5_err_msg(context, code));
+ k5err = gssd_k5_err_msg(context, code);
+ printerr(0, "ERROR: %s allocating gic options\n", k5err);
goto out;
}
if (krb5_get_init_creds_opt_set_addressless(context, init_opts, 1))
@@ -425,9 +426,9 @@ gssd_get_single_krb5_cred(krb5_context context,
if ((code = krb5_get_init_creds_keytab(context, &my_creds, ple->princ,
kt, 0, NULL, opts))) {
+ k5err = gssd_k5_err_msg(context, code);
printerr(1, "WARNING: %s while getting initial ticket for "
- "principal '%s' using keytab '%s'\n",
- gssd_k5_err_msg(context, code),
+ "principal '%s' using keytab '%s'\n", k5err,
pname ? pname : "<unparsable>", kt_name);
goto out;
}
@@ -455,19 +456,21 @@ gssd_get_single_krb5_cred(krb5_context context,
goto out;
}
if ((code = krb5_cc_resolve(context, cc_name, &ccache))) {
+ k5err = gssd_k5_err_msg(context, code);
printerr(0, "ERROR: %s while opening credential cache '%s'\n",
- gssd_k5_err_msg(context, code), cc_name);
+ k5err, cc_name);
goto out;
}
if ((code = krb5_cc_initialize(context, ccache, ple->princ))) {
+ k5err = gssd_k5_err_msg(context, code);
printerr(0, "ERROR: %s while initializing credential "
- "cache '%s'\n", gssd_k5_err_msg(context, code),
- cc_name);
+ "cache '%s'\n", k5err, cc_name);
goto out;
}
if ((code = krb5_cc_store_cred(context, ccache, &my_creds))) {
+ k5err = gssd_k5_err_msg(context, code);
printerr(0, "ERROR: %s while storing credentials in '%s'\n",
- gssd_k5_err_msg(context, code), cc_name);
+ k5err, cc_name);
goto out;
}
@@ -484,6 +487,7 @@ gssd_get_single_krb5_cred(krb5_context context,
if (ccache)
krb5_cc_close(context, ccache);
krb5_free_cred_contents(context, &my_creds);
+ free(k5err);
return (code);
}
@@ -707,6 +711,7 @@ gssd_search_krb5_keytab(krb5_context context, krb5_keytab kt,
int retval = -1;
char kt_name[BUFSIZ];
char *pname;
+ char *k5err = NULL;
if (found == NULL) {
retval = EINVAL;
@@ -720,15 +725,15 @@ gssd_search_krb5_keytab(krb5_context context, krb5_keytab kt,
* save info in the global principal list (gssd_k5_kt_princ_list).
*/
if ((code = krb5_kt_get_name(context, kt, kt_name, BUFSIZ))) {
- printerr(0, "ERROR: %s attempting to get keytab name\n",
- gssd_k5_err_msg(context, code));
+ k5err = gssd_k5_err_msg(context, code);
+ printerr(0, "ERROR: %s attempting to get keytab name\n", k5err);
retval = code;
goto out;
}
if ((code = krb5_kt_start_seq_get(context, kt, &cursor))) {
+ k5err = gssd_k5_err_msg(context, code);
printerr(0, "ERROR: %s while beginning keytab scan "
- "for keytab '%s'\n",
- gssd_k5_err_msg(context, code), kt_name);
+ "for keytab '%s'\n", k5err, kt_name);
retval = code;
goto out;
}
@@ -736,9 +741,10 @@ gssd_search_krb5_keytab(krb5_context context, krb5_keytab kt,
while ((code = krb5_kt_next_entry(context, kt, kte, &cursor)) == 0) {
if ((code = krb5_unparse_name(context, kte->principal,
&pname))) {
+ k5err = gssd_k5_err_msg(context, code);
printerr(0, "WARNING: Skipping keytab entry because "
"we failed to unparse principal name: %s\n",
- gssd_k5_err_msg(context, code));
+ k5err);
k5_free_kt_entry(context, kte);
continue;
}
@@ -772,13 +778,14 @@ gssd_search_krb5_keytab(krb5_context context, krb5_keytab kt,
}
if ((code = krb5_kt_end_seq_get(context, kt, &cursor))) {
+ k5err = gssd_k5_err_msg(context, code);
printerr(0, "WARNING: %s while ending keytab scan for "
- "keytab '%s'\n",
- gssd_k5_err_msg(context, code), kt_name);
+ "keytab '%s'\n", k5err, kt_name);
}
retval = 0;
out:
+ free(k5err);
return retval;
}
@@ -798,6 +805,7 @@ find_keytab_entry(krb5_context context, krb5_keytab kt, const char *hostname,
int i, j, retval;
char *default_realm = NULL;
char *realm;
+ char *k5err = NULL;
int tried_all = 0, tried_default = 0;
krb5_principal princ;
@@ -811,8 +819,8 @@ find_keytab_entry(krb5_context context, krb5_keytab kt, const char *hostname,
/* Get full local hostname */
retval = gethostname(myhostname, sizeof(myhostname));
if (retval) {
- printerr(1, "%s while getting local hostname\n",
- gssd_k5_err_msg(context, retval));
+ k5err = gssd_k5_err_msg(context, retval);
+ printerr(1, "%s while getting local hostname\n", k5err);
goto out;
}
retval = get_full_hostname(myhostname, myhostname, sizeof(myhostname));
@@ -822,8 +830,8 @@ find_keytab_entry(krb5_context context, krb5_keytab kt, const char *hostname,
code = krb5_get_default_realm(context, &default_realm);
if (code) {
retval = code;
- printerr(1, "%s while getting default realm name\n",
- gssd_k5_err_msg(context, code));
+ k5err = gssd_k5_err_msg(context, code);
+ printerr(1, "%s while getting default realm name\n", k5err);
goto out;
}
@@ -835,8 +843,9 @@ find_keytab_entry(krb5_context context, krb5_keytab kt, const char *hostname,
*/
code = krb5_get_host_realm(context, targethostname, &realmnames);
if (code) {
+ k5err = gssd_k5_err_msg(context, code);
printerr(0, "ERROR: %s while getting realm(s) for host '%s'\n",
- gssd_k5_err_msg(context, code), targethostname);
+ k5err, targethostname);
retval = code;
goto out;
}
@@ -867,19 +876,19 @@ find_keytab_entry(krb5_context context, krb5_keytab kt, const char *hostname,
myhostname,
NULL);
if (code) {
+ k5err = gssd_k5_err_msg(context, code);
printerr(1, "%s while building principal for "
- "'%s/%s@%s'\n",
- gssd_k5_err_msg(context, code),
- svcnames[j], myhostname, realm);
+ "'%s/%s@%s'\n", k5err, svcnames[j],
+ myhostname, realm);
continue;
}
code = krb5_kt_get_entry(context, kt, princ, 0, 0, kte);
krb5_free_principal(context, princ);
if (code) {
+ k5err = gssd_k5_err_msg(context, code);
printerr(3, "%s while getting keytab entry for "
- "'%s/%s@%s'\n",
- gssd_k5_err_msg(context, code),
- svcnames[j], myhostname, realm);
+ "'%s/%s@%s'\n", k5err, svcnames[j],
+ myhostname, realm);
} else {
printerr(3, "Success getting keytab entry for "
"'%s/%s@%s'\n",
@@ -914,6 +923,7 @@ out:
k5_free_default_realm(context, default_realm);
if (realmnames)
krb5_free_host_realm(context, realmnames);
+ free(k5err);
return retval;
}
@@ -1139,11 +1149,12 @@ gssd_destroy_krb5_machine_creds(void)
krb5_error_code code = 0;
krb5_ccache ccache;
struct gssd_k5_kt_princ *ple;
+ char *k5err = NULL;
code = krb5_init_context(&context);
if (code) {
- printerr(0, "ERROR: %s while initializing krb5\n",
- gssd_k5_err_msg(NULL, code));
+ k5err = gssd_k5_err_msg(NULL, code);
+ printerr(0, "ERROR: %s while initializing krb5\n", k5err);
goto out;
}
@@ -1151,19 +1162,21 @@ gssd_destroy_krb5_machine_creds(void)
if (!ple->ccname)
continue;
if ((code = krb5_cc_resolve(context, ple->ccname, &ccache))) {
+ k5err = gssd_k5_err_msg(context, code);
printerr(0, "WARNING: %s while resolving credential "
- "cache '%s' for destruction\n",
- gssd_k5_err_msg(context, code), ple->ccname);
+ "cache '%s' for destruction\n", k5err,
+ ple->ccname);
continue;
}
if ((code = krb5_cc_destroy(context, ccache))) {
+ k5err = gssd_k5_err_msg(context, code);
printerr(0, "WARNING: %s while destroying credential "
- "cache '%s'\n",
- gssd_k5_err_msg(context, code), ple->ccname);
+ "cache '%s'\n", k5err, ple->ccname);
}
}
out:
+ free(k5err);
krb5_free_context(context);
}
@@ -1178,22 +1191,24 @@ gssd_refresh_krb5_machine_credential(char *hostname,
krb5_context context;
krb5_keytab kt = NULL;;
int retval = 0;
+ char *k5err = NULL;
if (hostname == NULL && ple == NULL)
return EINVAL;
code = krb5_init_context(&context);
if (code) {
+ k5err = gssd_k5_err_msg(NULL, code);
printerr(0, "ERROR: %s: %s while initializing krb5 context\n",
- __FUNCTION__, gssd_k5_err_msg(NULL, code));
+ __func__, k5err);
retval = code;
goto out;
}
if ((code = krb5_kt_resolve(context, keytabfile, &kt))) {
+ k5err = gssd_k5_err_msg(context, code);
printerr(0, "ERROR: %s: %s while resolving keytab '%s'\n",
- __FUNCTION__, gssd_k5_err_msg(context, code),
- keytabfile);
+ __func__, k5err, keytabfile);
goto out;
}
@@ -1230,29 +1245,35 @@ out:
if (kt)
krb5_kt_close(context, kt);
krb5_free_context(context);
+ free(k5err);
return retval;
}
/*
* A common routine for getting the Kerberos error message
*/
-const char *
+char *
gssd_k5_err_msg(krb5_context context, krb5_error_code code)
{
- const char *msg = NULL;
+ const char *origmsg;
+ char *msg = NULL;
+
#if HAVE_KRB5_GET_ERROR_MESSAGE
- if (context != NULL)
- msg = krb5_get_error_message(context, code);
+ if (context != NULL) {
+ origmsg = krb5_get_error_message(context, code);
+ msg = strdup(origmsg);
+ krb5_free_error_message(context, origmsg);
+ }
#endif
if (msg != NULL)
return msg;
#if HAVE_KRB5
- return error_message(code);
+ return strdup(error_message(code));
#else
if (context != NULL)
- return krb5_get_err_text(context, code);
+ return strdup(krb5_get_err_text(context, code));
else
- return error_message(code);
+ return strdup(error_message(code));
#endif
}
diff --git a/utils/gssd/krb5_util.h b/utils/gssd/krb5_util.h
index 7d808f5..3d39300 100644
--- a/utils/gssd/krb5_util.h
+++ b/utils/gssd/krb5_util.h
@@ -31,8 +31,7 @@ void gssd_setup_krb5_machine_gss_ccache(char *servername);
void gssd_destroy_krb5_machine_creds(void);
int gssd_refresh_krb5_machine_credential(char *hostname,
struct gssd_k5_kt_princ *ple);
-const char *
-gssd_k5_err_msg(krb5_context context, krb5_error_code code);
+char *gssd_k5_err_msg(krb5_context context, krb5_error_code code);
void gssd_k5_get_default_realm(char **def_realm);
#ifdef HAVE_SET_ALLOWABLE_ENCTYPES
diff --git a/utils/gssd/svcgssd.c b/utils/gssd/svcgssd.c
index f97dcd3..6ca0e8d 100644
--- a/utils/gssd/svcgssd.c
+++ b/utils/gssd/svcgssd.c
@@ -132,7 +132,11 @@ release_parent(void)
int status;
if (pipefds[1] > 0) {
- write(pipefds[1], &status, 1);
+ if (write(pipefds[1], &status, 1) != 1) {
+ printerr(1,
+ "WARN: writing to parent pipe failed: errno %d (%s)\n",
+ errno, strerror(errno));
+ }
close(pipefds[1]);
pipefds[1] = -1;
}
diff --git a/utils/idmapd/idmapd.c b/utils/idmapd/idmapd.c
index c1cf4eb..b690e21 100644
--- a/utils/idmapd/idmapd.c
+++ b/utils/idmapd/idmapd.c
@@ -169,7 +169,10 @@ flush_nfsd_cache(char *path, time_t now)
fd = open(path, O_RDWR);
if (fd == -1)
return -1;
- write(fd, stime, strlen(stime));
+ if (write(fd, stime, strlen(stime)) != strlen(stime)) {
+ errx(1, "Flushing nfsd cache failed: errno %d (%s)",
+ errno, strerror(errno));
+ }
close(fd);
return 0;
}
@@ -988,7 +991,10 @@ release_parent(void)
int status;
if (pipefds[1] > 0) {
- write(pipefds[1], &status, 1);
+ if (write(pipefds[1], &status, 1) != 1) {
+ err(1, "Writing to parent pipe failed: errno %d (%s)\n",
+ errno, strerror(errno));
+ }
close(pipefds[1]);
pipefds[1] = -1;
}
diff --git a/utils/mount/fstab.c b/utils/mount/fstab.c
index e19e58b..7668167 100644
--- a/utils/mount/fstab.c
+++ b/utils/mount/fstab.c
@@ -546,8 +546,12 @@ update_mtab (const char *dir, struct mntent *instead)
* from the present mtab before renaming.
*/
struct stat sbuf;
- if (stat (MOUNTED, &sbuf) == 0)
- chown (MOUNTED_TEMP, sbuf.st_uid, sbuf.st_gid);
+ if (stat (MOUNTED, &sbuf) == 0) {
+ if (chown (MOUNTED_TEMP, sbuf.st_uid, sbuf.st_gid) < 0) {
+ nfs_error(_("%s: error changing owner of %s: %s"),
+ progname, MOUNTED_TEMP, strerror (errno));
+ }
+ }
}
/* rename mtemp to mtab */
diff --git a/utils/statd/monitor.c b/utils/statd/monitor.c
index 169cd78..a2c9e2b 100644
--- a/utils/statd/monitor.c
+++ b/utils/statd/monitor.c
@@ -204,7 +204,10 @@ sm_mon_1_svc(struct mon *argp, struct svc_req *rqstp)
e += sprintf(e, "%02x", 0xff & (argp->priv[i]));
if (e+1-buf != LINELEN) abort();
e += sprintf(e, " %s %s\n", mon_name, my_name);
- write(fd, buf, e-buf);
+ if (write(fd, buf, e-buf) != (e-buf)) {
+ note(N_WARNING, "writing to %s failed: errno %d (%s)",
+ path, errno, strerror(errno));
+ }
}
free(path);
diff --git a/utils/statd/sm-notify.c b/utils/statd/sm-notify.c
index d58e0be..f1fc619 100644
--- a/utils/statd/sm-notify.c
+++ b/utils/statd/sm-notify.c
@@ -782,7 +782,10 @@ static int record_pid(void)
fd = open("/var/run/sm-notify.pid", O_CREAT|O_EXCL|O_WRONLY, 0600);
if (fd < 0)
return 0;
- write(fd, pid, strlen(pid));
+ if (write(fd, pid, strlen(pid)) != strlen(pid)) {
+ nsm_log(LOG_WARNING, "Writing to pid file failed: errno %d(%s)",
+ errno, strerror(errno));
+ }
close(fd);
return 1;
}
@@ -818,12 +821,16 @@ static void drop_privs(void)
static void set_kernel_nsm_state(int state)
{
int fd;
+ const char *file = "/proc/sys/fs/nfs/nsm_local_state";
- fd = open("/proc/sys/fs/nfs/nsm_local_state",O_WRONLY);
+ fd = open(file ,O_WRONLY);
if (fd >= 0) {
char buf[20];
snprintf(buf, sizeof(buf), "%d", state);
- write(fd, buf, strlen(buf));
+ if (write(fd, buf, strlen(buf)) != strlen(buf)) {
+ nsm_log(LOG_WARNING, "Writing to '%s' failed: errno %d (%s)",
+ file, errno, strerror(errno));
+ }
close(fd);
}
}
diff --git a/utils/statd/statd.c b/utils/statd/statd.c
index 6da2ab2..1c5247e 100644
--- a/utils/statd/statd.c
+++ b/utils/statd/statd.c
@@ -179,14 +179,20 @@ static void create_pidfile(void)
pidfile, strerror(errno));
fprintf(fp, "%d\n", getpid());
pidfd = dup(fileno(fp));
- if (fclose(fp) < 0)
- note(N_WARNING, "Flushing pid file failed.\n");
+ if (fclose(fp) < 0) {
+ note(N_WARNING, "Flushing pid file failed: errno %d (%s)\n",
+ errno, strerror(errno));
+ }
}
static void truncate_pidfile(void)
{
- if (pidfd >= 0)
- ftruncate(pidfd, 0);
+ if (pidfd >= 0) {
+ if (ftruncate(pidfd, 0) < 0) {
+ note(N_WARNING, "truncating pid file failed: errno %d (%s)\n",
+ errno, strerror(errno));
+ }
+ }
}
static void drop_privs(void)
@@ -207,9 +213,12 @@ static void drop_privs(void)
/* better chown the pid file before dropping, as if it
* if over nfs we might loose access
*/
- if (pidfd >= 0)
- fchown(pidfd, st.st_uid, st.st_gid);
-
+ if (pidfd >= 0) {
+ if (fchown(pidfd, st.st_uid, st.st_gid) < 0) {
+ note(N_ERROR, "Unable to change owner of %s: %d (%s)",
+ SM_DIR, strerror (errno));
+ }
+ }
setgroups(0, NULL);
if (setgid(st.st_gid) == -1
|| setuid(st.st_uid) == -1) {
@@ -495,7 +504,10 @@ int main (int argc, char **argv)
/* If we got this far, we have successfully started, so notify parent */
if (pipefds[1] > 0) {
status = 0;
- write(pipefds[1], &status, 1);
+ if (write(pipefds[1], &status, 1) != 1) {
+ note(N_WARNING, "writing to parent pipe failed: errno %d (%s)\n",
+ errno, strerror(errno));
+ }
close(pipefds[1]);
pipefds[1] = -1;
}
@@ -534,17 +546,23 @@ static void
load_state_number(void)
{
int fd;
+ const char *file = "/proc/sys/fs/nfs/nsm_local_state";
if ((fd = open(SM_STAT_PATH, O_RDONLY)) == -1)
return;
- read(fd, &MY_STATE, sizeof(MY_STATE));
+ if (read(fd, &MY_STATE, sizeof(MY_STATE)) != sizeof(MY_STATE)) {
+ note(N_WARNING, "Unable to read state from '%s': errno %d (%s)",
+ SM_STAT_PATH, errno, strerror(errno));
+ }
close(fd);
- fd = open("/proc/sys/fs/nfs/nsm_local_state",O_WRONLY);
+ fd = open(file, O_WRONLY);
if (fd >= 0) {
char buf[20];
snprintf(buf, sizeof(buf), "%d", MY_STATE);
- write(fd, buf, strlen(buf));
+ if (write(fd, buf, strlen(buf)) != strlen(buf))
+ note(N_WARNING, "Writing to '%s' failed: errno %d (%s)",
+ file, errno, strerror(errno));
close(fd);
}

View File

@ -2,7 +2,7 @@ Summary: NFS utilities and supporting clients and daemons for the kernel NFS ser
Name: nfs-utils
URL: http://sourceforge.net/projects/nfs
Version: 1.1.5
Release: 3%{?dist}
Release: 4%{?dist}
Epoch: 1
# group all 32bit related archs
@ -28,6 +28,7 @@ Patch02: nfs-utils-1.1.0-exp-subtree-warn-off.patch
Patch100: nfs-utils-1.1.5-tcpwrap-externs.patch
Patch101: nfs-utils-1-1-6-rc2.patch
Patch102: nfs-utils-1-1-6-rc3.patch
%if %{enablefscache}
Patch90: nfs-utils-1.1.0-mount-fsc.patch
@ -84,6 +85,7 @@ This package also contains the mount.nfs and umount.nfs program.
%patch100 -p1
%patch101 -p1
%patch102 -p1
%if %{enablefscache}
%patch90 -p1
@ -247,6 +249,14 @@ fi
%attr(4755,root,root) /sbin/umount.nfs4
%changelog
* Mon Mar 23 2009 Steve Dickson <steved@redhat.com> 1.1.5-4
- Added upstream rc3 patch
- gssd: initialize fakeseed in prepare_krb5_rfc1964_buffer
- gssd: NULL-terminate buffer after read in read_service_info (try #2)
- gssd: free buffer allocated by gssd_k5_err_msg
- gssd: fix potential double-frees in gssd
- Removed a number of warn_unused_result warnings
* Mon Mar 16 2009 Steve Dickson <steved@redhat.com> 1.1.5-3
- Added upstream rc2 patch