Quoting Stéphane Graber (stgra...@ubuntu.com):
> On Mon, Jul 22, 2013 at 02:09:19PM -0500, Serge Hallyn wrote:
> > If we are euid==0 or XDG_RUNTIME_DIR is not set, then use
> > /run/lock/lxc/$lxcpath/$lxcname as before.  Otherwise,
> > use $XDG_RUNTIME_DIR/lock/lxc/$lxcpath/$lxcname.
> > 
> > Signed-off-by: Serge Hallyn <serge.hal...@ubuntu.com>
> > Cc: Stéphane Graber <stephane.gra...@canonical.com>
> 
> Acked-by: Stéphane Graber <stgra...@ubuntu.com>
> 
> > ---
> >  src/lxc/lxclock.c | 29 +++++++++++++++++++++++------
> >  1 file changed, 23 insertions(+), 6 deletions(-)
> > 
> > diff --git a/src/lxc/lxclock.c b/src/lxc/lxclock.c
> > index 31bedd8..43e76fa 100644
> > --- a/src/lxc/lxclock.c
> > +++ b/src/lxc/lxclock.c
> > @@ -24,6 +24,8 @@
> >  #include <errno.h>
> >  #include <unistd.h>
> >  #include <fcntl.h>
> > +#define _GNU_SOURCE
> > +#include <stdlib.h>
> >  #include <lxc/utils.h>
> >  #include <lxc/log.h>
> >  #include <lxc/lxccontainer.h>
> > @@ -40,14 +42,29 @@ pthread_mutex_t thread_mutex = 
> > PTHREAD_MUTEX_INITIALIZER;
> >  static char *lxclock_name(const char *p, const char *n)
> >  {
> >     int ret;
> > -   // /run/lock/lxc/$lxcpath/$lxcname + '\0'
> > -   int len = strlen(p) + strlen(n) + strlen("/run/lock/lxc/") + 2;
> > -   char *dest = malloc(len);
> > +   int len;
> > +   char *dest;
> > +   const char *rundir;
> >     struct stat sb;
> >  
> > -   if (!dest)
> > +   /* lockfile will be:
> > +    * "/run" + "/lock/lxc/$lxcpath/$lxcname + '\0' if root
> > +    * or
> > +    * $XDG_RUNTIME_DIR + "/lock/lxc/$lxcpath/$lxcname + '\0' if non-root
> > +    */
> > +
> > +   /* length of "/lock/lxc/" + $lxcpath + "/" + $lxcname + '\0' */
> > +   len = strlen("/lock/lxc/") + strlen(n) + strlen(p) + 2;
> > +   rundir = getenv("XDG_RUNTIME_DIR");
> > +   if (geteuid() == 0 || rundir == NULL)
> > +           rundir = "/run";
> > +
> > +   len += strlen(rundir);
> > +
> > +   if ((dest = malloc(len)) == NULL)
> >             return NULL;
> > -   ret = snprintf(dest, len, "/run/lock/lxc/%s", p);
> > +
> > +   ret = snprintf(dest, len, "%s/lock/lxc/%s", rundir, p);
> 
> The standard path appears to be /run/user/<uid>/<software>/<whatever> so
> in our case, /run/user/<uid>/lxc/... but there's no clear spec on that,
> so I guess /run/user/<uid>/lock/lxc/... works too.

I do prefer to keep the code for euid == 0 and !=0 as much the same as
possible, but a trivial patch to switch the order of "lxc" and "lock"
would be fine with me.  I'll apply this patch as is may silently update
it (or accept a patch to do so).

thanks,
-serge

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel

Reply via email to