aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2012-08-20 14:44:42 -0500
committerTed Gould <ted@gould.cx>2012-08-20 14:44:42 -0500
commit6caebbec178693c28431c9c99c2f5d51cfc5a090 (patch)
tree80b696b8887e9086a8e140e7717b9806e24ea587 /src
parent06a9bad53744e3a7cfe5984087d3330046c35d64 (diff)
downloadlibpam-freerdp2-6caebbec178693c28431c9c99c2f5d51cfc5a090.tar.gz
libpam-freerdp2-6caebbec178693c28431c9c99c2f5d51cfc5a090.tar.bz2
libpam-freerdp2-6caebbec178693c28431c9c99c2f5d51cfc5a090.zip
Make sure we're running as the guest user before we execute the freerdp utility
Diffstat (limited to 'src')
-rw-r--r--src/pam-freerdp.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/pam-freerdp.c b/src/pam-freerdp.c
index 7bd2657..189c82f 100644
--- a/src/pam-freerdp.c
+++ b/src/pam-freerdp.c
@@ -122,12 +122,16 @@ pam_sm_authenticate (pam_handle_t *pamh, int flags, int argc, const char **argv)
struct passwd * pwdent = getpwnam(username);
if (pwdent == NULL) {
- _exit(-1);
+ _exit(EXIT_FAILURE);
+ }
+
+ if (setgid(pwdent->pw_gid) < 0 || setuid(pwdent->pw_uid) < 0 ||
+ setegid(pwdent->pw_gid) < 0 || seteuid(pwdent->pw_uid) < 0) {
+ _exit(EXIT_FAILURE);
}
setenv("HOME", pwdent->pw_dir, 1);
- /* TODO: Drop privs */
execvp(args[0], args);
_exit(EXIT_FAILURE);
break;