PERFORCE change 227753 for review
Brooks Davis
brooks at FreeBSD.org
Mon Apr 15 23:18:09 UTC 2013
http://p4web.freebsd.org/@@227753?ac=10
Change 227753 by brooks at brooks_zenith on 2013/04/15 23:17:28
Use setusercontext() to more throughly set up the terminal
context. The useful effect of this change is that PATH is
set to a useful value.
Reported by: rwatson
Affected files ...
.. //depot/projects/ctsrd/cheribsd/src/ctsrd/pictview/pictview.c#10 edit
Differences ...
==== //depot/projects/ctsrd/cheribsd/src/ctsrd/pictview/pictview.c#10 (text+ko) ====
@@ -43,7 +43,9 @@
#include <fcntl.h>
#include <fnmatch.h>
#include <libutil.h>
+#include <login_cap.h>
#include <poll.h>
+#include <pwd.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
@@ -193,6 +195,8 @@
start_keyboard_shell(void)
{
int pmaster, pslave;
+ login_cap_t *lcap = NULL;
+ struct passwd *pwd = NULL;
if (openpty(&pmaster, &pslave, NULL, NULL, NULL) == -1)
err(1, "openpty");
@@ -208,6 +212,15 @@
syslog(LOG_ALERT, "login_tty failed in child: %s", strerror(errno));
err(1, "tty_login");
}
+
+ if ((pwd = getpwuid(getuid())) == NULL)
+ err(1, "getpwuid: %s", getuid());
+ if ((lcap = login_getpwclass(pwd)) == NULL)
+ err(1, "login_getpwclass");
+ if (setusercontext(lcap, pwd, pwd->pw_uid,
+ LOGIN_SETALL & ~LOGIN_SETGROUP & ~LOGIN_SETLOGIN) != 0)
+ err(1, "setusercontext");
+
execl("/bin/sh", "sh", NULL);
syslog(LOG_ALERT, "exec of /bin/sh failed: %s", strerror(errno));
err(1, "execl()");
More information about the p4-projects
mailing list