Set HOME variable
authorAndy Bavier <acb@cs.princeton.edu>
Thu, 10 Dec 2009 19:42:27 +0000 (19:42 +0000)
committerAndy Bavier <acb@cs.princeton.edu>
Thu, 10 Dec 2009 19:42:27 +0000 (19:42 +0000)
src/vsh.c

index 9c61664..55231c7 100644 (file)
--- a/src/vsh.c
+++ b/src/vsh.c
@@ -54,7 +54,9 @@ int main(int argc, char **argv)
     int argc2;
     char slice_id_str[256];
     unsigned int slice_xid;
-    
+    char *envp[] = { NULL, NULL };
+    char home_env_str[256];
+
     slice_xid = getuid();
     slice_name = get_current_username(slice_xid);
     if (!slice_name) {
@@ -72,11 +74,14 @@ int main(int argc, char **argv)
     argv2[1] = strdup(slice_name);
     argv2[2] = strdup("suexec");
     argv2[3] = strdup(slice_id_str);
-    argv2[4] = strdup("/bin/sh"); 
+    argv2[4] = strdup("/bin/bash"); 
+
+    snprintf(home_env_str, 255, "HOME=/home/%s", slice_name);
+    envp[0] = home_env_str;
 
     if (setuid(geteuid())) goto out_exception;
 
-    execve(VSERVER_PATH, argv2, NULL);
+    execve(VSERVER_PATH, argv2, envp);
 
 out_exception:
     printf("%s\n", strerror(errno));