aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2012-08-20 14:39:57 -0500
committerTed Gould <ted@gould.cx>2012-08-20 14:39:57 -0500
commit06a9bad53744e3a7cfe5984087d3330046c35d64 (patch)
tree780314c34ae7ca33a0c382d0399132ad75b99dab
parent804affb662da866b504c2b35d771aa3a14d43716 (diff)
downloadlibpam-freerdp2-06a9bad53744e3a7cfe5984087d3330046c35d64.tar.gz
libpam-freerdp2-06a9bad53744e3a7cfe5984087d3330046c35d64.tar.bz2
libpam-freerdp2-06a9bad53744e3a7cfe5984087d3330046c35d64.zip
Setting the home directory to the user's directory
-rw-r--r--src/pam-freerdp.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/pam-freerdp.c b/src/pam-freerdp.c
index d8c6703..7bd2657 100644
--- a/src/pam-freerdp.c
+++ b/src/pam-freerdp.c
@@ -3,6 +3,8 @@
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
+#include <sys/types.h>
+#include <pwd.h>
#include <security/pam_modules.h>
#include <security/pam_modutil.h>
@@ -108,20 +110,24 @@ pam_sm_authenticate (pam_handle_t *pamh, int flags, int argc, const char **argv)
case 0: { /* child */
dup2(stdinpipe[0], 0);
- char * args[8];
+ char * args[7];
args[0] = XFREERDP;
args[1] = "--plugin";
args[2] = "rdpsnd.so";
args[3] = "--no-nla";
args[4] = "-f";
- args[5] = "--ignore-certificate"; /* TODO: Change when we set the home directory properly */
- args[6] = "--from-stdin";
-
- args[7] = NULL;
+ args[5] = "--from-stdin";
+ args[6] = NULL;
+
+ struct passwd * pwdent = getpwnam(username);
+ if (pwdent == NULL) {
+ _exit(-1);
+ }
+
+ setenv("HOME", pwdent->pw_dir, 1);
/* TODO: Drop privs */
- /* TODO: Home directory environment to user's home */
execvp(args[0], args);
_exit(EXIT_FAILURE);
break;