aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-11-19 20:01:42 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-11-19 20:01:42 +0000
commit6ddff9636950ef3df345e415e4de14ef0bd82d4a (patch)
treee1e288e339b8c83d8866c3765c329e1a3a041c59
parent07f0d15a91bd5ebb9d64b69e0e14debd4d19cd0f (diff)
downloadpaludis-6ddff9636950ef3df345e415e4de14ef0bd82d4a.tar.gz
paludis-6ddff9636950ef3df345e415e4de14ef0bd82d4a.tar.xz
Moan if we're not in a tty group
-rw-r--r--paludis/environments/paludis/paludis_config.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/paludis/environments/paludis/paludis_config.cc b/paludis/environments/paludis/paludis_config.cc
index 4013ee6..c2b9c43 100644
--- a/paludis/environments/paludis/paludis_config.cc
+++ b/paludis/environments/paludis/paludis_config.cc
@@ -64,6 +64,7 @@
#include <ctype.h>
#include <sys/types.h>
+#include <grp.h>
#include <pwd.h>
#include "config.h"
@@ -503,6 +504,30 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
_imp->reduced_gid = std::make_shared<gid_t>(getgid());
}
+ FSPath tty_0("/dev/pts/0");
+ bool tty_ok(true);
+ if (tty_0.stat().exists())
+ {
+ FSStat tty_0_stat(tty_0);
+ ::gid_t gids[100];
+
+ int g(100);
+ if ((g = ::getgrouplist(reduced_username().c_str(), reduced_gid(), gids, &g)) != -1)
+ tty_ok = (gids + g != std::find(gids, gids + g, tty_0_stat.group()));
+ else
+ tty_ok = false;
+ }
+ else
+ tty_ok = false;
+
+ if (! tty_ok)
+ {
+ Log::get_instance()->message("paludis_environment.userpriv.tty", ll_warning, lc_context)
+ << "Cannot verify that we have sufficient permissions to use PTYs properly "
+ "using userpriv. Strange breakages may occur. You should ensure that the '"
+ << reduced_username() << "' user is in the group to which /dev/pts/0 belongs";
+ }
+
if (dist->mandatory_userpriv() && ((0 == *_imp->reduced_uid || 0 == *_imp->reduced_gid)))
{
std::string s;