summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mad-server.conf1
-rw-r--r--src/modules/UserBackendHome/UserBackendHome.cpp23
-rw-r--r--src/modules/UserBackendHome/UserBackendHome.h3
3 files changed, 25 insertions, 2 deletions
diff --git a/src/mad-server.conf b/src/mad-server.conf
index 41aa298..b6fc8c7 100644
--- a/src/mad-server.conf
+++ b/src/mad-server.conf
@@ -36,6 +36,7 @@ UserBackendMysql {
UserBackendHome {
HomeDir "/tmp/home"
Skeleton "/tmp/skel"
+ DirMode 0700
}
Daemon test {
diff --git a/src/modules/UserBackendHome/UserBackendHome.cpp b/src/modules/UserBackendHome/UserBackendHome.cpp
index d524a52..f0714fe 100644
--- a/src/modules/UserBackendHome/UserBackendHome.cpp
+++ b/src/modules/UserBackendHome/UserBackendHome.cpp
@@ -44,6 +44,23 @@ bool UserBackendHome::handleConfigEntry(const Core::ConfigEntry &entry, bool han
if(entry[2].empty())
homeDir = entry[1][0];
}
+ else if(entry[1].getKey().matches("DirMode")) {
+ if(entry[2].empty()) {
+ if(entry[1][0].empty()) {
+ dirMode = 0755;
+ }
+ else {
+ char *endptr;
+ unsigned long val = std::strtoul(entry[1][0].c_str(), &endptr, 8);
+ if(*endptr || val > 07777) {
+ application->logf(Core::LoggerBase::WARNING, "UserBackendHome: Invalid configuration: DirMode '%s'", entry[1][0].c_str());
+ }
+ else {
+ dirMode = val;
+ }
+ }
+ }
+ }
else if(!entry[1].empty())
return false;
@@ -66,7 +83,7 @@ void UserBackendHome::setOwnerAndCopyMode(const std::string &source, const std::
}
}
-void migrateOwner(const std::string &path, const Common::UserInfo &oldUserInfo, const Common::UserInfo &userInfo, bool isSymlink) {
+void UserBackendHome::migrateOwner(const std::string &path, const Common::UserInfo &oldUserInfo, const Common::UserInfo &userInfo, bool isSymlink) {
struct stat st;
if((isSymlink ? lstat : stat)(path.c_str(), &st) != 0) {
// TODO Error
@@ -100,6 +117,10 @@ void UserBackendHome::addUser(const Common::UserInfo &userInfo) throw(Core::Exce
// TODO Error
}
+ if(chmod(nativePath.c_str(), (mode_t)dirMode)) {
+ // TODO Error
+ }
+
boost::filesystem::path skeletonPath(skeleton);
if(!boost::filesystem::is_directory(skeletonPath))
return;
diff --git a/src/modules/UserBackendHome/UserBackendHome.h b/src/modules/UserBackendHome/UserBackendHome.h
index 1e2b0a3..74fa2cb 100644
--- a/src/modules/UserBackendHome/UserBackendHome.h
+++ b/src/modules/UserBackendHome/UserBackendHome.h
@@ -38,6 +38,7 @@ class UserBackendHome : public Common::UserConfigBackend, private Core::Configur
std::string skeleton;
std::string homeDir;
+ unsigned long dirMode;
boost::mutex mutex;
@@ -53,7 +54,7 @@ class UserBackendHome : public Common::UserConfigBackend, private Core::Configur
virtual void deleteUser(const Common::UserInfo &userInfo) throw(Core::Exception);
public:
- UserBackendHome(Common::Application *application0) : application(application0), homeDir("/home") {
+ UserBackendHome(Common::Application *application0) : application(application0), homeDir("/home"), dirMode(0755) {
application->getConfigManager()->registerConfigurable(this);
}