Hi ppl, A lot of universities (and corporations) use kerberos for authentication and OpenAFS to host the folders. However, it is not possible to create sockets on OpenAFS (this is probably true for other remote/distributed file systems).
Currently awesome reports its unable to bind a socket (with permission denied) and continues normaly. However this means the user is unable to control awesome using awesome-client or similar. A simple workaround for this is to fall back to /tmp/.awesome-ctl before giving up after ~/.awesome-ctl failed. The following patch does precisly this, it works perfectly on my desktop (on openafs) and my laptop (regular ext3). PS: As a bonus I attached a path to merge two loops in the keybinding section of aweseomerc.lua into 1, I see no reason to spam the list again for such a small patch. Cheers, Alex
From f5ec724fa12792cec6a81a59df0399af307ed114 Mon Sep 17 00:00:00 2001 From: Alex Cornejo <[email protected]> Date: Tue, 17 Mar 2009 18:41:52 -0400 Subject: [PATCH] Fixed socket usage to work with AFS home folders. On corporate/university environments it is not uncommon for the home folder of each user to be hosted on OpenAFS (so you can work from any terminal and IT services can backup everything at will). However it is not possible to create sockets in AFS, hence when awesome attempts to create a socket at ~/.awesome-ctl it fails. To fix this awesome now uses /tmp/.awesome-ctl as a fallback before giving up. Signed-off-by: Alex Cornejo <[email protected]> --- awesome-client.c | 9 +++++++-- common/socket.c | 10 +++++----- common/socket.h | 2 +- luaa.c | 8 ++++++-- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/awesome-client.c b/awesome-client.c index c7c84fa..7ed52a9 100644 --- a/awesome-client.c +++ b/awesome-client.c @@ -56,11 +56,16 @@ sockets_init(void) if((csfd = socket_getclient()) < 0) return false; - if(!(addr = socket_getaddr(display))) + if(!(addr = socket_getaddr(getenv("HOME"),display))) return false; if(connect(csfd, addr, sizeof(struct sockaddr_un)) == -1) - return false; + { + if(!(addr = socket_getaddr("/tmp",display))) + return false; + if(connect(csfd, addr, sizeof(struct sockaddr_un)) == -1) + return false; + } return true; } diff --git a/common/socket.c b/common/socket.c index ba89831..d7f66ea 100644 --- a/common/socket.c +++ b/common/socket.c @@ -34,20 +34,20 @@ /** Get a sockaddr_un struct with information feeded for opening a * communication to the awesome socket for given display + * \param directory where socket is created * \param display the display number * \return sockaddr_un struct ready to be used or NULL if a problem occured */ struct sockaddr_un * -socket_getaddr(const char *display) +socket_getaddr(const char *directory, const char *display) { - char *homedir, *host = NULL; + char *host = NULL; int screenp = 0, displayp = 0; ssize_t path_len, len; struct sockaddr_un *addr; addr = p_new(struct sockaddr_un, 1); - homedir = getenv("HOME"); - + xcb_parse_display(NULL, &host, &displayp, &screenp); len = a_strlen(host); @@ -55,7 +55,7 @@ socket_getaddr(const char *display) /* + 2 for / and . and \0 */ path_len = snprintf(addr->sun_path, sizeof(addr->sun_path), "%s/" CONTROL_UNIX_SOCKET_PATH "%s%s%d", - homedir, len ? host : "", len ? "." : "", + directory, len ? host : "", len ? "." : "", displayp); p_delete(&host); diff --git a/common/socket.h b/common/socket.h index df131c1..55e1127 100644 --- a/common/socket.h +++ b/common/socket.h @@ -22,7 +22,7 @@ #ifndef AWESOME_COMMON_SOCKET_H #define AWESOME_COMMON_SOCKET_H -struct sockaddr_un * socket_getaddr(const char *); +struct sockaddr_un * socket_getaddr(const char *, const char *); int socket_getclient(void); #endif diff --git a/luaa.c b/luaa.c index 9ce3a8a..87df9f2 100644 --- a/luaa.c +++ b/luaa.c @@ -1115,7 +1115,7 @@ luaA_cs_init(void) if (csfd < 0 || fcntl(csfd, F_SETFD, FD_CLOEXEC) == -1) return; - addr = socket_getaddr(getenv("DISPLAY")); + addr = socket_getaddr(getenv("HOME"), getenv("DISPLAY")); /* Needed for some OSes like Solaris */ #ifndef SUN_LEN @@ -1132,7 +1132,11 @@ luaA_cs_init(void) return warn("error binding UNIX domain socket: %s", strerror(errno)); } else - return warn("error binding UNIX domain socket: %s", strerror(errno)); + { + addr = socket_getaddr("/tmp", getenv("DISPLAY")); + if (bind(csfd, (const struct sockaddr *) addr, SUN_LEN(addr))) + return warn("error binding UNIX domain socket: %s", strerror(errno)); + } } listen(csfd, 10); -- 1.5.6.3
From 2871f101e52ebf6873c4cbacbc6f4ca3d4045519 Mon Sep 17 00:00:00 2001 From: Alex Cornejo <[email protected]> Date: Tue, 17 Mar 2009 18:47:41 -0400 Subject: [PATCH] Replaced double loop with a single one. Unless I am missing something there is no purpose of using two loops instead of one. Signed-off-by: Alex Cornejo <[email protected]> --- awesomerc.lua.in | 22 ++++++++++------------ 1 files changed, 10 insertions(+), 12 deletions(-) diff --git a/awesomerc.lua.in b/awesomerc.lua.in index 8c6e49d..3c6b3ee 100644 --- a/awesomerc.lua.in +++ b/awesomerc.lua.in @@ -299,21 +299,19 @@ for i = 1, keynumber do awful.client.toggletag(tags[client.focus.screen][i]) end end)) + table.insert(globalkeys, + key({ modkey, "Shift" }, "F" .. i, + function () + local screen = mouse.screen + if tags[screen][i] then + for k, c in pairs(awful.client.getmarked()) do + awful.client.movetotag(tags[screen][i], c) + end + end + end)) end -for i = 1, keynumber do - table.insert(globalkeys, key({ modkey, "Shift" }, "F" .. i, - function () - local screen = mouse.screen - if tags[screen][i] then - for k, c in pairs(awful.client.getmarked()) do - awful.client.movetotag(tags[screen][i], c) - end - end - end)) -end - -- Set keys root.keys(globalkeys) -- }}} -- 1.5.6.3
