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 <acornejo@gmail.com> Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
691b732f1a
commit
96cf05f002
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
8
luaa.c
8
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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue