From: Ben Pfaff Date: Mon, 14 May 2012 21:32:14 +0000 (-0700) Subject: socket-util: Remove 'passcred' parameter from make_unix_socket(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=openvswitch;a=commitdiff_plain;h=5ca92d1d5dc0d8dba9ed554444cd0ae00a43209f socket-util: Remove 'passcred' parameter from make_unix_socket(). Nothing in the tree ever tries to send or receive credentials over a Unix domain socket so there's no point in configuring them to be received. Signed-off-by: Ben Pfaff --- diff --git a/lib/socket-util.c b/lib/socket-util.c index 82a33c20..53d0fb69 100644 --- a/lib/socket-util.c +++ b/lib/socket-util.c @@ -384,12 +384,11 @@ bind_unix_socket(int fd, struct sockaddr *sun, socklen_t sun_len) /* Creates a Unix domain socket in the given 'style' (either SOCK_DGRAM or * SOCK_STREAM) that is bound to '*bind_path' (if 'bind_path' is non-null) and * connected to '*connect_path' (if 'connect_path' is non-null). If 'nonblock' - * is true, the socket is made non-blocking. If 'passcred' is true, the socket - * is configured to receive SCM_CREDENTIALS control messages. + * is true, the socket is made non-blocking. * * Returns the socket's fd if successful, otherwise a negative errno value. */ int -make_unix_socket(int style, bool nonblock, bool passcred OVS_UNUSED, +make_unix_socket(int style, bool nonblock, const char *bind_path, const char *connect_path) { int error; @@ -457,16 +456,6 @@ make_unix_socket(int style, bool nonblock, bool passcred OVS_UNUSED, } } -#ifdef SCM_CREDENTIALS - if (passcred) { - int enable = 1; - if (setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &enable, sizeof(enable))) { - error = errno; - goto error; - } - } -#endif - return fd; error: diff --git a/lib/socket-util.h b/lib/socket-util.h index 56c72cd3..4a1df12e 100644 --- a/lib/socket-util.h +++ b/lib/socket-util.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011 Nicira, Inc. + * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ int get_socket_rcvbuf(int sock); int check_connection_completion(int fd); int drain_rcvbuf(int fd); void drain_fd(int fd, size_t n_packets); -int make_unix_socket(int style, bool nonblock, bool passcred, +int make_unix_socket(int style, bool nonblock, const char *bind_path, const char *connect_path); int get_unix_name_len(socklen_t sun_len); ovs_be32 guess_netmask(ovs_be32 ip); diff --git a/lib/stream-unix.c b/lib/stream-unix.c index 99a99623..689dcf1c 100644 --- a/lib/stream-unix.c +++ b/lib/stream-unix.c @@ -46,7 +46,7 @@ unix_open(const char *name, char *suffix, struct stream **streamp, const char *connect_path = suffix; int fd; - fd = make_unix_socket(SOCK_STREAM, true, false, NULL, connect_path); + fd = make_unix_socket(SOCK_STREAM, true, NULL, connect_path); if (fd < 0) { VLOG_ERR("%s: connection failed (%s)", connect_path, strerror(-fd)); return -fd; @@ -79,7 +79,7 @@ punix_open(const char *name OVS_UNUSED, char *suffix, { int fd, error; - fd = make_unix_socket(SOCK_STREAM, true, true, suffix, NULL); + fd = make_unix_socket(SOCK_STREAM, true, suffix, NULL); if (fd < 0) { VLOG_ERR("%s: binding failed: %s", suffix, strerror(errno)); return errno; diff --git a/tests/test-unix-socket.c b/tests/test-unix-socket.c index 9279fdab..c5c6a2b9 100644 --- a/tests/test-unix-socket.c +++ b/tests/test-unix-socket.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Nicira, Inc. + * Copyright (c) 2010, 2012 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ main(int argc, char *argv[]) alarm(5); /* Create a listening socket under name 'sockname1'. */ - sock1 = make_unix_socket(SOCK_STREAM, false, false, sockname1, NULL); + sock1 = make_unix_socket(SOCK_STREAM, false, sockname1, NULL); if (sock1 < 0) { ovs_fatal(-sock1, "%s: bind failed", sockname1); } @@ -52,7 +52,7 @@ main(int argc, char *argv[]) /* Connect to 'sockname2' (which should be the same file, perhaps under a * different name). */ - sock2 = make_unix_socket(SOCK_STREAM, false, false, NULL, sockname2); + sock2 = make_unix_socket(SOCK_STREAM, false, NULL, sockname2); if (sock2 < 0) { ovs_fatal(-sock2, "%s: connect failed", sockname2); }