aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 4013ee644..c2b9c43d1 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;