From fbc8330f5478a6921ee5aeb508a751f586f5db1d Mon Sep 17 00:00:00 2001 From: wbaumann Date: Sun, 7 Nov 2010 11:19:11 +0000 Subject: [PATCH] check return values of chown and chmod --- src/kernel_interface.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/kernel_interface.c b/src/kernel_interface.c index e75ef4d..4404f6b 100644 --- a/src/kernel_interface.c +++ b/src/kernel_interface.c @@ -177,9 +177,12 @@ init_coda(int *dev, dav_run_msgloop_fn *msg_loop, void **mdata) *dev = open(path, O_RDWR | O_NONBLOCK); if (*dev <= 0) { if (mknod(path, S_IFCHR, makedev(CODA_MAJOR, minor)) == 0) { - chown(path, 0, 0); - chmod(path, S_IRUSR | S_IWUSR); - *dev = open(path, O_RDWR | O_NONBLOCK); + if (chown(path, 0, 0) == 0 + && chmod(path, S_IRUSR | S_IWUSR) == 0) { + *dev = open(path, O_RDWR | O_NONBLOCK); + } else { + remove(path); + } } } free(path); @@ -227,9 +230,11 @@ init_fuse(int *dev, dav_run_msgloop_fn *msg_loop, void **mdata, } if (*dev <= 0) { if (mknod(path, S_IFCHR, makedev(FUSE_MAJOR, FUSE_MINOR)) == 0) { - chown(path, 0, 0); - chmod(path, S_IRUSR | S_IWUSR); - *dev = open(path, O_RDWR | O_NONBLOCK); + if (chown(path, 0, 0) == 0 && chmod(path, S_IRUSR | S_IWUSR) == 0) { + *dev = open(path, O_RDWR | O_NONBLOCK); + } else { + remove(path); + } } }