Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Oct 2001 15:48:51 +0200
From:      "Jose M. Alcaide" <jose@we.lc.ehu.es>
To:        stable@FreeBSD.org
Subject:   login(1) now forks the shell instead of exec'ing it ?
Message-ID:  <20011026154851.B378@v-ger.we.lc.ehu.es>

index | next in thread | raw e-mail

Hello,

After upgrading my laptop to -STABLE, I noticed that now, when any user
logs in through the console, there is a "login -p <user>" process which is
the parent of the shell. The old login(1) behavior was to execlp() the
shell, but now it forks a new process. I suppose that this new behavior is
related to PAM, especially after reading this code in login.c:

	/*
	 * We must fork() before setuid() because we need to call
	 * pam_close_session() as root.
	 */
	pid = fork();
	if (pid < 0) {
		err(1, "fork");
		PAM_END;
		exit(0);
	} else if (pid) {
		/* parent - wait for child to finish, then cleanup
		   session */
		wait(NULL);
		PAM_END;
		exit(0);
	} else {
		if ((e = pam_end(pamh, PAM_DATA_SILENT)) != PAM_SUCCESS)
			syslog(LOG_ERR, "pam_end: %s",
			    pam_strerror(pamh, e));
	}

Why is that fork() needed? I cannot see why pam_end() is not being called
from the login process context, instead of forking a child process for
exec'ing the shell while the parent is left waiting for it and exits
inmediately when its child finishes. Just wondering.

  Cheers,
  JMA
-- 
****** Jose M. Alcaide  //  jose@we.lc.ehu.es  //  jmas@FreeBSD.org ******
** "Beware of Programmers who carry screwdrivers" --  Leonard Brandwein **

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message



home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011026154851.B378>