Bug#670132: Happens when the session is closed

2013-08-05 Thread Nicolas François
Hello Yuri,

Could you try with the attached patch.

su is catching the TERM signals so that it can transfer them to its child.
At this point in time, su already decided that the child has to be
terminated.
So su can finish the child cleanup before closing the PAM session.

It still seems strange that systemd sends TERM signals.
This assumes that the tool has a TERM handler or has finished its cleanup
when it closes the PAM session.

Best Regards,
-- 
Nekral
diff --git a/src/su.c b/src/su.c
index 98ea6de..f119c3c 100644
--- a/src/su.c
+++ b/src/su.c
@@ -371,6 +371,12 @@ static void prepare_pam_close_session (void)
 		(void) fputs (_(Session terminated, terminating shell...),
 		  stderr);
 		(void) kill (-pid_child, caught);
+
+		(void) signal (SIGALRM, kill_child);
+		(void) alarm (2);
+
+		(void) wait (status);
+		(void) fputs (_( ...terminated.\n), stderr);
 	}
 
 	ret = pam_close_session (pamh, 0);
@@ -383,14 +389,6 @@ static void prepare_pam_close_session (void)
 	(void) pam_setcred (pamh, PAM_DELETE_CRED);
 	(void) pam_end (pamh, PAM_SUCCESS);
 
-	if (0 != caught) {
-		(void) signal (SIGALRM, kill_child);
-		(void) alarm (2);
-
-		(void) wait (status);
-		(void) fputs (_( ...terminated.\n), stderr);
-	}
-
 	exit ((0 != WIFEXITED (status)) ? WEXITSTATUS (status)
 	: WTERMSIG (status) + 128);
 	/* Only the child returns. See above. */


Bug#670132: Happens when the session is closed

2013-08-05 Thread Yuri D'Elia
On 08/05/2013 05:08 PM, Nicolas François wrote:
 Hello Yuri,
 
 Could you try with the attached patch.
 
 su is catching the TERM signals so that it can transfer them to its child.
 At this point in time, su already decided that the child has to be
 terminated.
 So su can finish the child cleanup before closing the PAM session.
 
 It still seems strange that systemd sends TERM signals.
 This assumes that the tool has a TERM handler or has finished its cleanup
 when it closes the PAM session.

I have systemd + libpam-systemd from sid (whereas I had upstart at the
time), but I cannot reproduce the problem anymore.

I switched back to sysvinit for a while (I had too many problems with
upstart in general), and when I went back to try systemd 2/3 months ago
I never noticed the message again.


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#670132: Happens when the session is closed

2013-08-05 Thread Tollef Fog Heen
]] Yuri D'Elia 

 On 08/05/2013 05:08 PM, Nicolas François wrote:
  Hello Yuri,
  
  Could you try with the attached patch.
  
  su is catching the TERM signals so that it can transfer them to its child.
  At this point in time, su already decided that the child has to be
  terminated.
  So su can finish the child cleanup before closing the PAM session.
  
  It still seems strange that systemd sends TERM signals.
  This assumes that the tool has a TERM handler or has finished its cleanup
  when it closes the PAM session.
 
 I have systemd + libpam-systemd from sid (whereas I had upstart at the
 time), but I cannot reproduce the problem anymore.

We made a change where (IIRC) we don't send SIGTERM to the session
leader, so this problem should have gone away, yes.

-- 
Tollef Fog Heen
UNIX is user friendly, it's just picky about who its friends are


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#670132: Happens when the session is closed

2012-06-30 Thread Tollef Fog Heen

Hiya,

so, what happens is that systemd (and upstart, I suspect) sends SIGTERM
to su when the pam session is closed.

src/su.c:prepare_pam_close_session ends with:

(void) pam_setcred (pamh, PAM_DELETE_CRED);
(void) pam_end (pamh, PAM_SUCCESS);

if (0 != caught) {
(void) signal (SIGALRM, kill_child);
(void) alarm (2);

(void) wait (status);
(void) fputs (_( ...terminated.\n), stderr);
}

exit ((0 != WIFEXITED (status)) ? WEXITSTATUS (status)
: WTERMSIG (status) + 128);
/* Only the child returns. See above. */
}

signal + alarm there is to ensure that any signals in the pam cleanup
phase causes the termination of the child, but this is already done by
systemd.

I think just dropping the fputs should be reasonable enough.
Alternatively, I can make systemd not send SIGTERM to the session
leader.  I'm not entirely sure why it does that in the first place, but
I've asked upstream to comment.

-- 
Tollef Fog Heen
UNIX is user friendly, it's just picky about who its friends are



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org