summaryrefslogtreecommitdiffstats
path: root/module/obmc
diff options
context:
space:
mode:
authorVernon Mauery <vernon.mauery@linux.intel.com>2018-12-19 10:33:46 -0800
committerVernon Mauery <vernon.mauery@linux.intel.com>2018-12-19 18:45:12 +0000
commitdbc46919bddedb159d05558053963df40b2c9300 (patch)
treeb1560c28dacec0c4d4e064d3c3a8ce1992e80538 /module/obmc
parent0f7019df1ecf905c72378dc9a3dcab625bb142b7 (diff)
downloadphosphor-rest-server-dbc46919bddedb159d05558053963df40b2c9300.tar.gz
phosphor-rest-server-dbc46919bddedb159d05558053963df40b2c9300.zip
phosphor-rest-server: connect with the correct sockaddr size
With the obmc-console-server binding to the correct socket, this is not needed. Abstract unix sockets start with the nul-charater, but are not nul terminated. In fact, the nul-character has no meaning in the path. According to the man page unix(7), abstract: an abstract socket address is distinguished (from a pathname socket) by the fact that sun_path[0] is a null byte ('\0'). The socket's address in this namespace is given by the additional bytes in sun_path that are covered by the specified length of the address structure. (Null bytes in the name have no special significance.) This means that when calling bind/connect, the size of the sockaddr structure is not sizeof(sockaddr_un), it is sizeof(sockaddr_un) - sizeof(sun_path) + (path_len) Change-Id: I1d978af9ace7fa137bab2f596a217d1ba243e5be Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
Diffstat (limited to 'module/obmc')
-rw-r--r--module/obmc/wsgi/apps/rest_dbus.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/module/obmc/wsgi/apps/rest_dbus.py b/module/obmc/wsgi/apps/rest_dbus.py
index a0f6e4d..0893d0b 100644
--- a/module/obmc/wsgi/apps/rest_dbus.py
+++ b/module/obmc/wsgi/apps/rest_dbus.py
@@ -1119,11 +1119,10 @@ class HostConsoleHandler(RouteHandler):
if not wsock:
abort(400, 'Expected WebSocket based request.')
- # A UNIX domain socket structure defines a 108-byte pathname. The
- # server in this case, obmc-console-server, expects a 108-byte path.
+ # An abstract Unix socket path must be less than or equal to 108 bytes
+ # and does not need to be nul-terminated or padded out to 108 bytes
socket_name = "\0obmc-console"
- trailing_bytes = "\0" * (108 - len(socket_name))
- socket_path = socket_name + trailing_bytes
+ socket_path = socket_name
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
try:
OpenPOWER on IntegriCloud