Use sockets in abstract namespace only if running on linux

Also adds fallback to shell client which uses `uname -o` in place of `ostype`.

Closes #1215
This commit is contained in:
ZyX 2014-12-06 00:05:25 +03:00
parent 432cc5031f
commit aaf52c92c5
4 changed files with 28 additions and 12 deletions

View File

@ -42,12 +42,12 @@ void do_write(int sd, const char *raw, size_t len) {
} }
} }
#ifdef __APPLE__ #ifdef __linux__
# define ADDRESS_TEMPLATE "/tmp/powerline-ipc-%d"
# define A
#else
# define ADDRESS_TEMPLATE "powerline-ipc-%d" # define ADDRESS_TEMPLATE "powerline-ipc-%d"
# define A +1 # define A +1
#else
# define ADDRESS_TEMPLATE "/tmp/powerline-ipc-%d"
# define A
#endif #endif
#define ADDRESS_SIZE sizeof(ADDRESS_TEMPLATE) + (sizeof(uid_t) * 4) #define ADDRESS_SIZE sizeof(ADDRESS_TEMPLATE) + (sizeof(uid_t) * 4)

View File

@ -26,9 +26,7 @@ if len(sys.argv) < 2:
print('Must provide at least one argument.', file=sys.stderr) print('Must provide at least one argument.', file=sys.stderr)
raise SystemExit(1) raise SystemExit(1)
platform = sys.platform.lower() use_filesystem = not sys.platform.lower().startswith('linux')
use_filesystem = 'darwin' in platform
del platform
if sys.argv[1] == '--socket': if sys.argv[1] == '--socket':
address = sys.argv[2] address = sys.argv[2]

View File

@ -1,6 +1,22 @@
#!/bin/sh #!/bin/sh
test "${OSTYPE#darwin}" = "${OSTYPE}" && darwin=n || darwin=y use_filesystem=1
darwin=
if test -n "$OSTYPE" ; then
# OSTYPE variable is a shell feature. supported by bash and zsh, but not
# dash, busybox or (m)ksh.
if test "${OSTYPE#linux}" '!=' "${OSTYPE}" ; then
use_filesystem=
elif test "${OSTYPE#darwin}" ; then
darwin=1
fi
elif which uname >/dev/null ; then
if uname -o | grep -iqF linux ; then
use_filesystem=
elif uname -o | grep -iqF darwin ; then
darwin=1
fi
fi
if test "$1" = "--socket" ; then if test "$1" = "--socket" ; then
shift shift
@ -8,13 +24,16 @@ if test "$1" = "--socket" ; then
shift shift
else else
ADDRESS="powerline-ipc-${UID:-`id -u`}" ADDRESS="powerline-ipc-${UID:-`id -u`}"
test "$darwin" = y && ADDRESS="/tmp/$ADDRESS" test -n "$use_filesystem" && ADDRESS="/tmp/$ADDRESS"
fi fi
if test "$darwin" = y; then if test -n "$darwin" ; then
ENV=genv ENV=genv
else else
ENV=env ENV=env
fi
if test -z "$use_filesystem" ; then
ADDRESS="abstract-client:$ADDRESS" ADDRESS="abstract-client:$ADDRESS"
fi fi

View File

@ -24,8 +24,7 @@ from powerline.commands.daemon import get_argparser as get_daemon_argparser
is_daemon = False is_daemon = False
platform = sys.platform.lower() use_filesystem = not sys.platform.lower().startswith('linux')
use_filesystem = 'darwin' in platform
address = None address = None
pidfile = None pidfile = None