From cf38e86e8181317639a55360ae3736a0497b4b5b Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 7 Jul 2010 15:04:33 -0700 Subject: [PATCH] class: make class tmp directory configurable, not /tmp /tmp usually gets mounted with 'noexec', making it a poor choice. Signed-off-by: Sage Weil --- debian/ceph.dirs | 1 + debian/ceph.postinst | 1 - src/common/ClassHandler.cc | 14 +++++--------- src/config.cc | 1 + src/config.h | 1 + 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/debian/ceph.dirs b/debian/ceph.dirs index 57ad5d6b738..eeb9b34696b 100644 --- a/debian/ceph.dirs +++ b/debian/ceph.dirs @@ -5,3 +5,4 @@ etc/ceph usr/share/doc/ceph var/log/ceph var/log/ceph/stat +var/lib/ceph/tmp \ No newline at end of file diff --git a/debian/ceph.postinst b/debian/ceph.postinst index d758b3b8183..b92a8ae7272 100644 --- a/debian/ceph.postinst +++ b/debian/ceph.postinst @@ -19,7 +19,6 @@ set -e case "$1" in configure) -# ldconfig ;; abort-upgrade|abort-remove|abort-deconfigure) diff --git a/src/common/ClassHandler.cc b/src/common/ClassHandler.cc index 692d7886fd2..7d94d535796 100644 --- a/src/common/ClassHandler.cc +++ b/src/common/ClassHandler.cc @@ -22,21 +22,19 @@ void ClassHandler::_load_class(ClassData &cls) { dout(10) << "load_class " << cls.name << dendl; - char *fname=strdup("/tmp/class-XXXXXX"); - int fd = mkstemp(fname); cls_deps_t *(*cls_deps)(); - for (list::const_iterator it = cls.impl.binary.buffers().begin(); - it != cls.impl.binary.buffers().end(); it++) - write(fd, it->c_str(), it->length()); + char fname[80]; + snprintf(fname, sizeof(fname), "%s/class-XXXXXX", g_conf.osd_class_tmp); + int fd = mkstemp(fname); + cls.impl.binary.write_fd(fd); close(fd); cls.handle = dlopen(fname, RTLD_NOW); if (!cls.handle) { - char buf[80]; - dout(0) << "could not open class (dlopen failed) " << strerror_r(errno, buf, sizeof(buf)) << dendl; + dout(0) << "could not open class (dlopen failed): " << dlerror() << dendl; goto done; } cls_deps = (cls_deps_t *(*)())dlsym(cls.handle, "class_deps"); @@ -52,8 +50,6 @@ void ClassHandler::_load_class(ClassData &cls) cls.load(); done: unlink(fname); - free(fname); - return; } diff --git a/src/config.cc b/src/config.cc index 281c35b7751..ccff1f3e181 100644 --- a/src/config.cc +++ b/src/config.cc @@ -478,6 +478,7 @@ static struct config_option config_optionsp[] = { OPTION(osd_recovery_max_active, 0, OPT_INT, 5), OPTION(osd_auto_weight, 0, OPT_BOOL, false), OPTION(osd_class_timeout, 0, OPT_FLOAT, 10.0), + OPTION(osd_class_tmp, 0, OPT_STR, "/var/lib/ceph/tmp"), OPTION(osd_check_for_log_corruption, 0, OPT_BOOL, false), OPTION(filestore, 0, OPT_BOOL, false), OPTION(filestore_max_sync_interval, 0, OPT_DOUBLE, 5), // seconds diff --git a/src/config.h b/src/config.h index 1b6f9ecab2e..3eb3a10ceb1 100644 --- a/src/config.h +++ b/src/config.h @@ -344,6 +344,7 @@ struct md_config_t { bool osd_auto_weight; bool osd_class_timeout; + const char *osd_class_tmp; bool osd_check_for_log_corruption; // bleh