The child process's environment should be manipulated the same way
by lxc-attach as it would be by lxc-start or lxc-execute.
Signed-off-by: David Ward <david.ward@ll.mit.edu>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
return 0;
}
+int lxc_attach_set_environment()
+{
+ if (clearenv()) {
+ SYSERROR("failed to clear environment");
+ /* don't error out though */
+ }
+
+ if (putenv("container=lxc")) {
+ SYSERROR("failed to set environment variable");
+ return -1;
+ }
+
+ return 0;
+}
+
char *lxc_attach_getpwshell(uid_t uid)
{
/* local variables */
extern int lxc_attach_to_ns(pid_t other_pid, int which);
extern int lxc_attach_remount_sys_proc();
extern int lxc_attach_drop_privs(struct lxc_proc_context_info *ctx);
+extern int lxc_attach_set_environment();
extern char *lxc_attach_getpwshell(uid_t uid);
return -1;
}
+ if (lxc_attach_set_environment()) {
+ ERROR("could not set environment");
+ return -1;
+ }
+
/* tell parent we are done setting up the container and wait
* until we have been put in the container's cgroup, if
* applicable */