If a user doesn't have read/write permissions on the ecryptfs
device file, the logs show that the file or directory doesn't
exist and ecryptfsd eventually segfaults on its way to exiting.

This patch lets the user know why the device file open failed,
fixes the segfault, and removes an unnecessary mention of netlink.

Signed-off-by: Tyler Hicks <[EMAIL PROTECTED]>
---
 src/daemon/main.c         |    5 ++---
 src/libecryptfs/miscdev.c |   22 +++++++++++++---------
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/src/daemon/main.c b/src/daemon/main.c
index 5e44a53..f531bd3 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -171,8 +171,7 @@ static void ecryptfsd_exit(struct ecryptfs_messaging_ctx 
*mctx, int retval)
                syslog(LOG_ERR, "%s: Error attempting to shut down messaging; "
                       "rc = [%d]\n", __FUNCTION__, rc);
 out:
-       ecryptfs_syslog(LOG_INFO, "Closing eCryptfs userspace netlink "
-                       "daemon [%u]\n", getpid());
+       ecryptfs_syslog(LOG_INFO, "Closing eCryptfs userspace daemon\n");
        exit(retval);
 }
 
@@ -400,7 +399,7 @@ int main(int argc, char **argv)
        if (rc) {
                syslog(LOG_ERR, "%s: Error attempting to send message to "
                       "eCryptfs kernel module via transport of type "
-                      "[0x%.8x]; rc = [%d]\n", mctx.type, rc);
+                      "[0x%.8x]; rc = [%d]\n", __FUNCTION__, mctx.type, rc);
                pthread_mutex_unlock(&mctx_mux);
                goto daemon_out;
        }
diff --git a/src/libecryptfs/miscdev.c b/src/libecryptfs/miscdev.c
index ad2ae7c..c93db4c 100644
--- a/src/libecryptfs/miscdev.c
+++ b/src/libecryptfs/miscdev.c
@@ -180,15 +180,19 @@ int ecryptfs_init_miscdev(struct ecryptfs_miscdev_ctx 
*miscdev_ctx)
        miscdev_ctx->miscdev_fd = open(ECRYPTFS_DEFAULT_MISCDEV_FULLPATH_0,
                                       O_RDWR);
        if (miscdev_ctx->miscdev_fd == -1) {
-               miscdev_ctx->miscdev_fd =
-                       open(ECRYPTFS_DEFAULT_MISCDEV_FULLPATH_1, O_RDWR);
-               if (miscdev_ctx->miscdev_fd == -1) {
-                       rc = -EIO;
-                       syslog(LOG_ERR, "%s: Error whilst attempting to open "
-                              "[%s] or [%s]; errno msg = [%m]\n", __FUNCTION__,
-                              ECRYPTFS_DEFAULT_MISCDEV_FULLPATH_0,
-                              ECRYPTFS_DEFAULT_MISCDEV_FULLPATH_1, errno);
-               }
+               syslog(LOG_ERR, "%s: Error whilst attempting to open "
+                      "[%s]; errno msg = [%m]\n", __FUNCTION__,
+                      ECRYPTFS_DEFAULT_MISCDEV_FULLPATH_0, errno);
+       } else
+               goto out;
+
+       miscdev_ctx->miscdev_fd = open(ECRYPTFS_DEFAULT_MISCDEV_FULLPATH_1,
+                                      O_RDWR);
+       if (miscdev_ctx->miscdev_fd == -1) {
+               syslog(LOG_ERR, "%s: Error whilst attempting to open "
+                      "[%s]; errno msg = [%m]\n", __FUNCTION__,
+                      ECRYPTFS_DEFAULT_MISCDEV_FULLPATH_1, errno);
+               rc = -EIO;
        }
 out:
        return rc;
-- 
1.5.3.7


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
eCryptfs-devel mailing list
eCryptfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ecryptfs-devel

Reply via email to