If a user has no home directory or getpwuid returns an error, I would think we'd just not try to set $HOME. (and optionally log an error/warning) Or, if we can't set $HOME to a user's actual $HOME, set it to $MESOS_SANDBOX?
My current use case involves migrating a cluster from Mesos 0.22, where we're not depending on containers (because part of the cluster is OS X), mesos is run as a user and not as root, and the executors are actually installed in $HOME. Data is written to $MESOS_SANDBOX though, but loading of the executor comes in relative to $HOME. The new cluster is on 0.28, Mesos starts as root, and a mixed containers/no-containers environ is on the roadmap. But backward compatibility is broken by this environment variable thing. Some of the python functions used in the executors crash if $HOME is not accessible. I think the last error I encountered of this sort was from "ctypes". Thanks, -Hansel On Jun 17, 2016, at 10:12 AM, Jie Yu <[email protected]> wrote: Another note is that Mesos task should only write to its sandbox ($MESOS_SANDBOX). Not sure what's the use case for getting $HOME. On Fri, Jun 17, 2016 at 10:10 AM, Jie Yu <[email protected]> wrote: Hansel, I think it was definitely not intentional. I am wondering what happens if the user does not have a home directory, what should $HOME be? - Jie On Fri, Jun 17, 2016 at 9:08 AM, <[email protected]> wrote: Hi Haosdent, Yes, I had confirmed that setuid does get called correctly, and the shell environment is not set up. My question is more along the lines of "is this expected? is it a bug? is it intentional?" If it wasn't intentional, I was thinking maybe I'll try a making a small patch to see if it works out. I couldn't find the JIRA ticket. Happen to know what it was or anything it might be referring to? Thanks, -Hansel On Jun 16, 2016, at 8:00 PM, haosdent <[email protected]> wrote: Hi, @Hansel Chung As I checked, if --swithc_user=true (default variable is true) when you launch Mesos agent, executor would call os::setuid and os::setgroups before launch your tasks. But the shell environment may not set. (I remember we have a ticket for this.) You could use `id` as your task command to verify if user set correctly. On Fri, Jun 17, 2016 at 9:17 AM, Hansel Chung <[email protected]> wrote: Hi, I had a question, I noticed that if mesos frameworks request that executors use a certain user, the env variables aren't set up for that user, but what the agent daemon was run as. As an example: Run mesos-slave as root: HOME=/root USER=root If I have an executor to be launched as testuser, the env looks like: HOME=/root USER=root instead of: HOME=/home/testuser USER=testuser This is normally set by login or sudo when running as a user, but I can't seem to find a way to use these to set up a proper environment as the target user. Is there a reason we don't call getpwuid() to set a $HOME during setup of execlp() from executor.cpp? (Oh, and might as well populate $USER while we're at it) Thanks, -Hansel -- Best Regards, Haosdent Huang

