Package: vzctl
Version: 3.0.24-3
Severity: normal
Tags: patch upstream

"vzctl enter" and "vzctl exec" do some odd things to the process
environment:
 - HOME gets set to "/" (except for "enter")
 - HISTFILE gets set to /dev/null (for "enter")

I have reported this upstream [1], and got the feedback that my proposed
patch should use getpwuid(0)->pw_dir instead of forcing "/root" [2].

You might want to improve my patch in this direction (after fixing
anything else I might have broken - especially regarding the HISTFILE
handling I am not sure if this is correct).

The main reason for this patch is to get the home directory right, which
otherwise might confuse programs like Bazaar [3].

Not using HISTFILE=/dev/null is useful to get the history of your
commands stored after all.

The Launchpad bug tracking this is also at [3].


1: http://bugzilla.openvz.org/show_bug.cgi?id=942
2: http://bugzilla.openvz.org/show_bug.cgi?id=942#c1
3: https://bugs.launchpad.net/bzr/+bug/622898


-- System Information:
Debian Release: squeeze/sid
  APT prefers maverick
  APT policy: (500, 'maverick')
Architecture: i386 (i686)

Kernel: Linux 2.6.35-22-generic (SMP w/2 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
diff -u vzctl-3.0.24/src/lib/script.c vzctl-3.0.24/src/lib/script.c
--- vzctl-3.0.24/src/lib/script.c
+++ vzctl-3.0.24/src/lib/script.c
@@ -38,7 +38,7 @@
 #include "fs.h"
 
 volatile sig_atomic_t alarm_flag;
-static char *envp_bash[] = {"HOME=/", "TERM=linux", ENV_PATH, NULL};
+static char *envp_bash[] = {"HOME=/root", "TERM=linux", ENV_PATH, NULL};
 
 int read_script(const char *fname, char *include, char **buf)
 {
diff -u vzctl-3.0.24/src/lib/env.c vzctl-3.0.24/src/lib/env.c
--- vzctl-3.0.24/src/lib/env.c
+++ vzctl-3.0.24/src/lib/env.c
@@ -280,7 +280,7 @@
 	int fd, ret;
 	vps_res *res;
 	char *argv[] = {"init", "-z", "      ", NULL};
-	char *envp[] = {"HOME=/", "TERM=linux", NULL};
+	char *envp[] = {"HOME=/root", "TERM=linux", NULL};
 
 	res = (vps_res *) data;
 	memset(&create_param, 0, sizeof(create_param));
diff -u vzctl-3.0.24/debian/changelog vzctl-3.0.24/debian/changelog
--- vzctl-3.0.24/debian/changelog
+++ vzctl-3.0.24/debian/changelog
@@ -1,3 +1,11 @@
+vzctl (3.0.24-7+blueyed1) lucid; urgency=low
+
+  * Fix environment in "vzctl exec" and "vzctl enter" (at least):
+    - set HOME=/root
+    - do not set HISTFILE=/dev/null
+
+ -- Daniel Hahler <ubu...@thequod.de>  Mon, 20 Sep 2010 20:45:41 +0200
+
 vzctl (3.0.24-7) unstable; urgency=medium
 
   * No longer ignore errors on startup.
only in patch2:
unchanged:
--- vzctl-3.0.24.orig/src/enter.c
+++ vzctl-3.0.24/src/enter.c
@@ -297,7 +297,6 @@
 			char *term;
 			char *arg[] = {NULL, NULL};
 			char *env[] = {ENV_PATH,
-				"HISTFILE=/dev/null",
 				"USER=root", "HOME=/root", "LOGNAME=root",
 				NULL, /* for TERM */
 				NULL};
only in patch2:
unchanged:
--- vzctl-3.0.24.orig/src/lib/exec.c
+++ vzctl-3.0.24/src/lib/exec.c
@@ -37,7 +37,7 @@
 #include "script.h"
 
 static volatile sig_atomic_t alarm_flag, child_exited;
-static char *envp_bash[] = {"HOME=/", "TERM=linux", ENV_PATH, NULL};
+static char *envp_bash[] = {"HOME=/root", "TERM=linux", ENV_PATH, NULL};
 
 int vz_env_create_ioctl(vps_handler *h, envid_t veid, int flags);
 

Reply via email to