1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-28 01:06:17 +00:00

Respect user's settings in /etc/login.conf. Bump PORTREVISION.

Submitted by:	Volker Stolz <stolz@hyperion.informatik.rwth-aachen.de>
Reviewed by:	Joe Clarke <marcus@marcuscom.com>, sobomax
This commit is contained in:
Maxim Sobolev 2002-01-11 14:04:37 +00:00
parent fb66784fad
commit 5b8351b592
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=52920
8 changed files with 400 additions and 0 deletions

View File

@ -7,6 +7,7 @@
PORTNAME= gdm
PORTVERSION= 2.2.5.4
PORTREVISION= 1
CATEGORIES= x11 gnome
MASTER_SITES= ${MASTER_SITE_GNOME}
MASTER_SITE_SUBDIR= stable/sources/gdm

View File

@ -0,0 +1,10 @@
--- config.h.in.orig Thu Jan 10 11:06:01 2002
+++ config.h.in Thu Jan 10 11:06:18 2002
@@ -6,6 +6,7 @@
#undef HAVE_CATGETS
#undef HAVE_GETTEXT
#undef HAVE_LC_MESSAGES
+#undef HAVE_LOGINCAP
#undef HAVE_STPCPY
#undef HAVE_PAM
#undef HAVE_TCPWRAPPERS

View File

@ -0,0 +1,61 @@
--- configure.orig Thu Jan 10 10:45:20 2002
+++ configure Thu Jan 10 10:55:39 2002
@@ -11066,6 +11066,58 @@
fi
+for ac_header in sys/types.h login_cap.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:11072: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line 11078 "configure"
+#include "confdefs.h"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:11082: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ egrep -v '^ *\+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:11088: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ eval "$as_ac_Header=yes"
+else
+ echo "$as_me: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:11107: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
+
+ LIBS="$LIBS -lutil"
+ cat >>confdefs.h <<\EOF
+#define HAVE_LOGINCAP 1
+EOF
+fi
+done
+
if test x$enable_authentication_scheme = xpam -a x$have_pam = xno ; then
{ { echo "$as_me:11070: error: PAM support requested but not available" >&5
echo "$as_me: error: PAM support requested but not available" >&2;}

View File

@ -0,0 +1,128 @@
$FreeBSD$
--- daemon/slave.c.orig Tue Jan 1 04:48:07 2002
+++ daemon/slave.c Fri Jan 11 15:51:27 2002
@@ -45,6 +45,11 @@
#include <time.h>
#include <syslog.h>
+#ifdef HAVE_LOGINCAP
+#include <unistd.h>
+#include <login_cap.h>
+#endif
+
#include <vicious.h>
#include "gdm.h"
@@ -140,6 +145,8 @@
static gboolean x_error_occured = FALSE;
static gboolean gdm_got_usr2 = FALSE;
+static void changeUser(struct passwd *pwent, char *login);
+
/* ignore handlers */
static int
ignore_xerror_handler (Display *disp, XErrorEvent *evt)
@@ -1785,6 +1792,27 @@
}
+#ifdef HAVE_LOGINCAP
+void changeUser(struct passwd *pwent, char *login) {
+ if (setsid() == -1)
+ gdm_child_exit (DISPLAY_REMANAGE, _("gdm_slave_session_start: setsid() failed for %s. Aborting."), login);
+ if (setusercontext(NULL, pwent, pwent->pw_uid, LOGIN_SETALL) == -1)
+ gdm_child_exit (DISPLAY_REMANAGE, _("gdm_slave_session_start: setusercontext() failed for %s. Aborting."), login);
+}
+#else
+void changeUser(struct passwd *pwent, char *login) {
+ setpgid(0, 0);
+ umask(022);
+ /* setup the user's correct group */
+ if (setgid(pwent->pw_gid) < 0)
+ gdm_child_exit (DISPLAY_REMANAGE, _("gdm_slave_session_start: Could not setgid %d. Aborting."), pwent->pw_gid);
+ if (initgroups(login, pwent->pw_gid) < 0)
+ gdm_child_exit (DISPLAY_REMANAGE, _("gdm_slave_session_start: initgroups() failed for %s. Aborting."), login);
+ if (setuid(pwent->pw_uid) < 0)
+ gdm_child_exit (DISPLAY_REMANAGE, _("gdm_slave_session_start: Could not become %s. Aborting."), login);
+}
+#endif
+
static char *
dequote (const char *in)
{
@@ -1823,6 +1851,9 @@
char *sesspath, *sessexec;
gboolean need_config_sync = FALSE;
const char *shell = NULL;
+#ifdef HAVE_LOGINCAP
+ char *lang = NULL;
+#endif
ve_clearenv ();
@@ -1840,12 +1871,6 @@
if (gnome_session != NULL)
ve_setenv ("GDM_GNOME_SESSION", gnome_session, TRUE);
- /* Special PATH for root */
- if (pwent->pw_uid == 0)
- ve_setenv ("PATH", GdmRootPath, TRUE);
- else
- ve_setenv ("PATH", GdmDefaultPath, TRUE);
-
/* Eeeeek, this no lookie as a correct language code, let's
* try unaliasing it */
if (strlen (language) < 3 ||
@@ -1853,14 +1878,31 @@
language = unaliaslang (language);
}
- /* Set locale */
+ changeUser(pwent, login);
+
+ /*
+ * Set locale. XXX in the HAVE_LOGINCAP case we override user's
+ * default language, but there is no other way around, because there
+ * is no way to select "Use user's default language" in the GDM, so
+ * that we either have to give up ability to select language other
+ * one specified in the login.conf, or just ignore default setting.
+ * I selected the latter, which is suboptimal, but at least gives
+ * some freedom to the user.
+ */
ve_setenv ("LANG", language, TRUE);
ve_setenv ("GDM_LANG", language, TRUE);
+
+#ifndef HAVE_LOGINCAP
+
+ /* Special PATH for root */
+ if (pwent->pw_uid == 0)
+ ve_setenv("PATH", GdmRootPath, TRUE);
+ else
+ ve_setenv("PATH", GdmDefaultPath, TRUE);
+#else
+ /* Do not reset PATH */
+#endif
- setpgid (0, 0);
-
- umask (022);
-
/* setup the verify env vars */
if ( ! gdm_verify_setup_env (d))
gdm_child_exit (DISPLAY_REMANAGE,
@@ -1870,12 +1912,8 @@
/* setup egid to the correct group,
* not to leave the egid around */
- setegid (pwent->pw_gid);
+ /*setegid (pwent->pw_gid);*/
- if (setuid (pwent->pw_uid) < 0)
- gdm_child_exit (DISPLAY_REMANAGE,
- _("gdm_slave_session_start: Could not become %s. Aborting."), login);
-
chdir (home_dir);
/* anality, make sure nothing is in memory for gnome_config

View File

@ -7,6 +7,7 @@
PORTNAME= gdm
PORTVERSION= 2.2.5.4
PORTREVISION= 1
CATEGORIES= x11 gnome
MASTER_SITES= ${MASTER_SITE_GNOME}
MASTER_SITE_SUBDIR= stable/sources/gdm

View File

@ -0,0 +1,10 @@
--- config.h.in.orig Thu Jan 10 11:06:01 2002
+++ config.h.in Thu Jan 10 11:06:18 2002
@@ -6,6 +6,7 @@
#undef HAVE_CATGETS
#undef HAVE_GETTEXT
#undef HAVE_LC_MESSAGES
+#undef HAVE_LOGINCAP
#undef HAVE_STPCPY
#undef HAVE_PAM
#undef HAVE_TCPWRAPPERS

View File

@ -0,0 +1,61 @@
--- configure.orig Thu Jan 10 10:45:20 2002
+++ configure Thu Jan 10 10:55:39 2002
@@ -11066,6 +11066,58 @@
fi
+for ac_header in sys/types.h login_cap.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:11072: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line 11078 "configure"
+#include "confdefs.h"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:11082: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ egrep -v '^ *\+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:11088: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ eval "$as_ac_Header=yes"
+else
+ echo "$as_me: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:11107: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
+
+ LIBS="$LIBS -lutil"
+ cat >>confdefs.h <<\EOF
+#define HAVE_LOGINCAP 1
+EOF
+fi
+done
+
if test x$enable_authentication_scheme = xpam -a x$have_pam = xno ; then
{ { echo "$as_me:11070: error: PAM support requested but not available" >&5
echo "$as_me: error: PAM support requested but not available" >&2;}

View File

@ -0,0 +1,128 @@
$FreeBSD$
--- daemon/slave.c.orig Tue Jan 1 04:48:07 2002
+++ daemon/slave.c Fri Jan 11 15:51:27 2002
@@ -45,6 +45,11 @@
#include <time.h>
#include <syslog.h>
+#ifdef HAVE_LOGINCAP
+#include <unistd.h>
+#include <login_cap.h>
+#endif
+
#include <vicious.h>
#include "gdm.h"
@@ -140,6 +145,8 @@
static gboolean x_error_occured = FALSE;
static gboolean gdm_got_usr2 = FALSE;
+static void changeUser(struct passwd *pwent, char *login);
+
/* ignore handlers */
static int
ignore_xerror_handler (Display *disp, XErrorEvent *evt)
@@ -1785,6 +1792,27 @@
}
+#ifdef HAVE_LOGINCAP
+void changeUser(struct passwd *pwent, char *login) {
+ if (setsid() == -1)
+ gdm_child_exit (DISPLAY_REMANAGE, _("gdm_slave_session_start: setsid() failed for %s. Aborting."), login);
+ if (setusercontext(NULL, pwent, pwent->pw_uid, LOGIN_SETALL) == -1)
+ gdm_child_exit (DISPLAY_REMANAGE, _("gdm_slave_session_start: setusercontext() failed for %s. Aborting."), login);
+}
+#else
+void changeUser(struct passwd *pwent, char *login) {
+ setpgid(0, 0);
+ umask(022);
+ /* setup the user's correct group */
+ if (setgid(pwent->pw_gid) < 0)
+ gdm_child_exit (DISPLAY_REMANAGE, _("gdm_slave_session_start: Could not setgid %d. Aborting."), pwent->pw_gid);
+ if (initgroups(login, pwent->pw_gid) < 0)
+ gdm_child_exit (DISPLAY_REMANAGE, _("gdm_slave_session_start: initgroups() failed for %s. Aborting."), login);
+ if (setuid(pwent->pw_uid) < 0)
+ gdm_child_exit (DISPLAY_REMANAGE, _("gdm_slave_session_start: Could not become %s. Aborting."), login);
+}
+#endif
+
static char *
dequote (const char *in)
{
@@ -1823,6 +1851,9 @@
char *sesspath, *sessexec;
gboolean need_config_sync = FALSE;
const char *shell = NULL;
+#ifdef HAVE_LOGINCAP
+ char *lang = NULL;
+#endif
ve_clearenv ();
@@ -1840,12 +1871,6 @@
if (gnome_session != NULL)
ve_setenv ("GDM_GNOME_SESSION", gnome_session, TRUE);
- /* Special PATH for root */
- if (pwent->pw_uid == 0)
- ve_setenv ("PATH", GdmRootPath, TRUE);
- else
- ve_setenv ("PATH", GdmDefaultPath, TRUE);
-
/* Eeeeek, this no lookie as a correct language code, let's
* try unaliasing it */
if (strlen (language) < 3 ||
@@ -1853,14 +1878,31 @@
language = unaliaslang (language);
}
- /* Set locale */
+ changeUser(pwent, login);
+
+ /*
+ * Set locale. XXX in the HAVE_LOGINCAP case we override user's
+ * default language, but there is no other way around, because there
+ * is no way to select "Use user's default language" in the GDM, so
+ * that we either have to give up ability to select language other
+ * one specified in the login.conf, or just ignore default setting.
+ * I selected the latter, which is suboptimal, but at least gives
+ * some freedom to the user.
+ */
ve_setenv ("LANG", language, TRUE);
ve_setenv ("GDM_LANG", language, TRUE);
+
+#ifndef HAVE_LOGINCAP
+
+ /* Special PATH for root */
+ if (pwent->pw_uid == 0)
+ ve_setenv("PATH", GdmRootPath, TRUE);
+ else
+ ve_setenv("PATH", GdmDefaultPath, TRUE);
+#else
+ /* Do not reset PATH */
+#endif
- setpgid (0, 0);
-
- umask (022);
-
/* setup the verify env vars */
if ( ! gdm_verify_setup_env (d))
gdm_child_exit (DISPLAY_REMANAGE,
@@ -1870,12 +1912,8 @@
/* setup egid to the correct group,
* not to leave the egid around */
- setegid (pwent->pw_gid);
+ /*setegid (pwent->pw_gid);*/
- if (setuid (pwent->pw_uid) < 0)
- gdm_child_exit (DISPLAY_REMANAGE,
- _("gdm_slave_session_start: Could not become %s. Aborting."), login);
-
chdir (home_dir);
/* anality, make sure nothing is in memory for gnome_config