summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@debian.org>2009-05-10 15:36:34 +0100
committerRoger Leigh <rleigh@debian.org>2009-05-10 17:41:28 +0100
commit255ddb53001c5c62a548fa48d852b68cc28f7874 (patch)
tree39579c7fb668ff0241645338061806add2747d3e /bin
parent7d2491c82040e318688926cd3976600225afab16 (diff)
downloadschroot-255ddb53001c5c62a548fa48d852b68cc28f7874.tar.gz
[sbuild::auth] Split into auth_pam and auth_null
PAM conversation handling classes are now all smart pointer-based only. Construction of base objects is not allowed. sbuild::session defaults to using auth_null, so dchroot and dchroot-dsa can't authenticate. schroot specifically adds auth_pam if available.
Diffstat (limited to 'bin')
-rw-r--r--bin/schroot/schroot-main-base.cc12
-rw-r--r--bin/schroot/schroot-main.cc23
2 files changed, 23 insertions, 12 deletions
diff --git a/bin/schroot/schroot-main-base.cc b/bin/schroot/schroot-main-base.cc
index c9e2a366..39328aa4 100644
--- a/bin/schroot/schroot-main-base.cc
+++ b/bin/schroot/schroot-main-base.cc
@@ -282,18 +282,6 @@ main_base::run_impl ()
verbosity = sbuild::auth::VERBOSITY_VERBOSE;
this->session->get_auth()->set_verbosity(verbosity);
-#ifdef SBUILD_FEATURE_PAM
- /* Set up authentication timeouts. */
- std::tr1::shared_ptr<sbuild::auth_conv>
- conv(new sbuild::auth_conv_tty
- (std::tr1::dynamic_pointer_cast<sbuild::auth>(this->session)));
- time_t curtime = 0;
- time(&curtime);
- conv->set_warning_timeout(curtime + 15);
- conv->set_fatal_timeout(curtime + 20);
- this->session->get_auth()->set_conv(conv);
-#endif // SBUILD_FEATURE_PAM
-
/* Run session. */
this->session->run();
}
diff --git a/bin/schroot/schroot-main.cc b/bin/schroot/schroot-main.cc
index 7dd32030..b1d158ae 100644
--- a/bin/schroot/schroot-main.cc
+++ b/bin/schroot/schroot-main.cc
@@ -18,6 +18,12 @@
#include <config.h>
+#include <sbuild/sbuild-config.h>
+#ifdef SBUILD_FEATURE_PAM
+#include <sbuild/sbuild-auth-pam.h>
+#include <sbuild/sbuild-auth-conv-tty.h>
+#endif
+
#include "schroot-main.h"
#include <cstdlib>
@@ -77,6 +83,23 @@ main::create_session(sbuild::session::operation sess_op)
this->session = sbuild::session::ptr
(new sbuild::session("schroot", this->config, sess_op, this->chroots));
+#ifdef SBUILD_FEATURE_PAM
+ sbuild::auth::ptr auth = sbuild::auth_pam::create("schroot");
+
+ sbuild::auth_conv_tty::auth_ptr auth_ptr =
+ std::tr1::dynamic_pointer_cast<sbuild::auth_pam>(auth);
+
+ sbuild::auth_conv::ptr conv = sbuild::auth_conv_tty::create(auth_ptr);
+
+ /* Set up authentication timeouts. */
+ time_t curtime = 0;
+ time(&curtime);
+ conv->set_warning_timeout(curtime + 15);
+ conv->set_fatal_timeout(curtime + 20);
+
+ this->session->set_auth(auth);
+#endif // SBUILD_FEATURE_PAM
+
if (!this->options->user.empty())
this->session->get_auth()->set_user(this->options->user);
}