ngompa / rpms / sudo

Forked from rpms/sudo 2 years ago
Clone
6a836e9
diff -up sudo-1.7.1/auth/pam.c.login sudo-1.7.1/auth/pam.c
6a836e9
--- sudo-1.7.1/auth/pam.c.login	2009-05-02 21:01:17.000000000 +0200
6a836e9
+++ sudo-1.7.1/auth/pam.c	2009-05-02 21:07:42.000000000 +0200
6a836e9
@@ -100,7 +100,13 @@ pam_init(pw, promptp, auth)
6a836e9
     if (auth != NULL)
6a836e9
 	auth->data = (void *) &pam_status;
6a836e9
     pam_conv.conv = sudo_conv;
6a836e9
-    pam_status = pam_start("sudo", pw->pw_name, &pam_conv, &pamh);
6a836e9
+#ifdef HAVE_PAM_LOGIN
6a836e9
+    if (ISSET(sudo_mode, MODE_LOGIN_SHELL))
6a836e9
+	    pam_status = pam_start("sudo-i", pw->pw_name, &pam_conv, &pamh);
6a836e9
+    else
6a836e9
+#endif
6a836e9
+	    pam_status = pam_start("sudo", pw->pw_name, &pam_conv, &pamh);
6a836e9
+
6a836e9
     if (pam_status != PAM_SUCCESS) {
6a836e9
 	log_error(USE_ERRNO|NO_EXIT|NO_MAIL, "unable to initialize PAM");
6a836e9
 	return(AUTH_FATAL);
6a836e9
diff -up sudo-1.7.1/configure.in.login sudo-1.7.1/configure.in
6a836e9
--- sudo-1.7.1/configure.in.login	2009-05-02 21:01:33.000000000 +0200
6a836e9
+++ sudo-1.7.1/configure.in	2009-05-02 21:13:59.000000000 +0200
6a836e9
@@ -393,6 +393,17 @@ AC_ARG_WITH(pam, [  --with-pam          
6a836e9
 		;;
6a836e9
 esac])
6a836e9
 
6a836e9
+AC_ARG_WITH(pam-login, [  --with-pam-login              enable specific PAM session for sudo -i],
6a836e9
+[case $with_pam_login in
6a836e9
+    yes)	AC_DEFINE([HAVE_PAM_LOGIN], [], ["Define to 1 if you use specific PAM session for sodo -i."])	
6a836e9
+		AC_MSG_CHECKING(whether to use PAM login)
6a836e9
+		AC_MSG_RESULT(yes)
6a836e9
+		;;
6a836e9
+    no)		;;
6a836e9
+    *)		AC_MSG_ERROR(["--with-pam-login does not take an argument."])
6a836e9
+		;;
6a836e9
+esac])
6a836e9
+
6a836e9
 AC_ARG_WITH(AFS, [  --with-AFS              enable AFS support],
6a836e9
 [case $with_AFS in
6a836e9
     yes)	AC_DEFINE(HAVE_AFS)
6a836e9
diff -up sudo-1.7.1/env.c.login sudo-1.7.1/env.c
6a836e9
--- sudo-1.7.1/env.c.login	2009-05-02 21:01:24.000000000 +0200
6a836e9
+++ sudo-1.7.1/env.c	2009-05-02 21:12:28.000000000 +0200
6a836e9
@@ -101,7 +101,7 @@ struct environment {
6a836e9
 /*
6a836e9
  * Prototypes
6a836e9
  */
6a836e9
-void rebuild_env		__P((int, int));
6a836e9
+void rebuild_env		__P((int));
6a836e9
 static void sudo_setenv		__P((const char *, const char *, int));
6a836e9
 static void sudo_putenv		__P((char *, int, int));
6a836e9
 
6a836e9
@@ -550,8 +550,7 @@ matches_env_keep(var)
6a836e9
  * Also adds sudo-specific variables (SUDO_*).
6a836e9
  */
6a836e9
 void
6a836e9
-rebuild_env(sudo_mode, noexec)
6a836e9
-    int sudo_mode;
6a836e9
+rebuild_env(noexec)
6a836e9
     int noexec;
6a836e9
 {
6a836e9
     char **old_envp, **ep, *cp, *ps1;
6a836e9
diff -up sudo-1.7.1/sudo.c.login sudo-1.7.1/sudo.c
6a836e9
--- sudo-1.7.1/sudo.c.login	2009-05-02 21:01:49.000000000 +0200
6a836e9
+++ sudo-1.7.1/sudo.c	2009-05-02 21:18:18.000000000 +0200
6a836e9
@@ -123,7 +123,7 @@ static void usage_excl			__P((int))
6a836e9
 					    __attribute__((__noreturn__));
6a836e9
 static struct passwd *get_authpw	__P((void));
6a836e9
 extern int sudo_edit			__P((int, char **, char **));
6a836e9
-extern void rebuild_env			__P((int, int));
6a836e9
+extern void rebuild_env			__P((int));
6a836e9
 void validate_env_vars			__P((struct list_member *));
6a836e9
 void insert_env_vars			__P((struct list_member *));
6a836e9
 
6a836e9
@@ -154,6 +154,8 @@ login_cap_t *lc;
6a836e9
 char *login_style;
6a836e9
 #endif /* HAVE_BSD_AUTH_H */
6a836e9
 sigaction_t saved_sa_int, saved_sa_quit, saved_sa_tstp;
6a836e9
+
6a836e9
+int sudo_mode;
6a836e9
 static char *runas_user;
6a836e9
 static char *runas_group;
6a836e9
 static struct sudo_nss_list *snl;
6a836e9
@@ -169,7 +171,7 @@ main(argc, argv, envp)
6a836e9
     char **envp;
6a836e9
 {
6a836e9
     int sources = 0, validated;
6a836e9
-    int fd, cmnd_status, sudo_mode, pwflag, rc = 0;
6a836e9
+    int fd, cmnd_status, pwflag, rc = 0;
6a836e9
     sigaction_t sa;
6a836e9
     struct sudo_nss *nss;
6a836e9
 #if defined(SUDO_DEVEL) && defined(__OpenBSD__)
6a836e9
@@ -408,7 +410,7 @@ main(argc, argv, envp)
6a836e9
 	def_env_reset = FALSE;
6a836e9
 
6a836e9
     /* Build a new environment that avoids any nasty bits. */
6a836e9
-    rebuild_env(sudo_mode, def_noexec);
6a836e9
+    rebuild_env(def_noexec);
6a836e9
 
6a836e9
     /* Fill in passwd struct based on user we are authenticating as.  */
6a836e9
     auth_pw = get_authpw();
6a836e9
diff -up sudo-1.7.1/sudo.h.login sudo-1.7.1/sudo.h
6a836e9
--- sudo-1.7.1/sudo.h.login	2009-05-02 21:01:42.000000000 +0200
6a836e9
+++ sudo-1.7.1/sudo.h	2009-05-02 21:14:58.000000000 +0200
6a836e9
@@ -332,6 +332,7 @@ extern struct passwd *auth_pw, *list_pw;
6a836e9
 extern int tgetpass_flags;
6a836e9
 extern int long_list;
6a836e9
 extern uid_t timestamp_uid;
6a836e9
+extern int sudo_mode;
6a836e9
 #endif
6a836e9
 #ifndef errno
6a836e9
 extern int errno;