Lines 31-36
Link Here
|
31 |
#include <errno.h> |
31 |
#include <errno.h> |
32 |
#include <grp.h> |
32 |
#include <grp.h> |
33 |
#include <pwd.h> |
33 |
#include <pwd.h> |
|
|
34 |
#ifdef HAVE_LOGINCAP |
35 |
#include <login_cap.h> |
36 |
#endif |
34 |
|
37 |
|
35 |
#include <security/pam_appl.h> |
38 |
#include <security/pam_appl.h> |
36 |
|
39 |
|
Lines 1757-1767
Link Here
|
1757 |
char **environment; |
1760 |
char **environment; |
1758 |
char *home_dir; |
1761 |
char *home_dir; |
1759 |
int fd; |
1762 |
int fd; |
|
|
1763 |
#ifdef HAVE_LOGINCAP |
1764 |
char *login = worker->priv->username; |
1765 |
struct passwd *pwent = getpwnam (login); |
1766 |
#endif |
1760 |
|
1767 |
|
1761 |
if (setuid (worker->priv->uid) < 0) { |
1768 |
/* Call setsid() before setusercontext() */ |
1762 |
g_debug ("GdmSessionWorker: could not reset uid - %s", g_strerror (errno)); |
|
|
1763 |
_exit (1); |
1764 |
} |
1765 |
|
1769 |
|
1766 |
if (setsid () < 0) { |
1770 |
if (setsid () < 0) { |
1767 |
g_debug ("GdmSessionWorker: could not set pid '%u' as leader of new session and process group - %s", |
1771 |
g_debug ("GdmSessionWorker: could not set pid '%u' as leader of new session and process group - %s", |
Lines 1769-1774
Link Here
|
1769 |
_exit (2); |
1773 |
_exit (2); |
1770 |
} |
1774 |
} |
1771 |
|
1775 |
|
|
|
1776 |
#ifdef HAVE_LOGINCAP |
1777 |
if (setusercontext (NULL, pwent, pwent->pw_uid, |
1778 |
LOGIN_SETLOGIN | LOGIN_SETPATH | |
1779 |
LOGIN_SETPRIORITY | LOGIN_SETRESOURCES | |
1780 |
LOGIN_SETUMASK | LOGIN_SETUSER | |
1781 |
LOGIN_SETENV) < 0) { |
1782 |
g_debug ("%s: setusercontext () failed for %s. " |
1783 |
"Aborting.", "gdm_session_worker_start_user_session", |
1784 |
login ? login : "(null)"); |
1785 |
} |
1786 |
|
1787 |
/* Propagate PATH environment variable from user context to child processes */ |
1788 |
|
1789 |
gdm_session_worker_set_environment_variable (worker, "PATH", getenv ("PATH")); |
1790 |
|
1791 |
#else |
1792 |
if (setuid (worker->priv->uid) < 0) { |
1793 |
g_debug ("GdmSessionWorker: could not reset uid - %s", g_strerror (errno)); |
1794 |
_exit (1); |
1795 |
} |
1796 |
#endif |
1797 |
|
1772 |
environment = gdm_session_worker_get_environment (worker); |
1798 |
environment = gdm_session_worker_get_environment (worker); |
1773 |
|
1799 |
|
1774 |
g_assert (geteuid () == getuid ()); |
1800 |
g_assert (geteuid () == getuid ()); |