[CONC-405] connection socket has no close-on-exec flag set Created: 2019-04-29  Updated: 2019-04-29

Status: Open
Project: MariaDB Connector/C
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Krzysztof MaƂysa Assignee: Georg Richter
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Linux archlinux 5.0.9-arch1-1-ARCH #1 SMP PREEMPT Sat Apr 20 15:00:46 UTC 2019 x86_64 GNU/Linux

Installed mariadb packages:

  • local/mariadb 10.3.14-1
  • local/mariadb-clients 10.3.14-1
  • local/mariadb-libs 10.3.14-1


 Description   

After opening connection with mysql_real_connect(), the connection socket (the one that mysql_get_socket() returns) has no close-on-exec flag set. The following code is needed after calling mysql_real_connect() to get this flag set:

// Set CLOEXEC flag on the mysql socket
int mysql_socket = mysql_get_socket(...);
int flags = fcntl(mysql_socket, F_GETFD);
if (flags == -1)
	/* Handle error */;
if (fcntl(mysql_socket, F_SETFD, flags | FD_CLOEXEC) == -1)
	/* Handle error */;

I suppose that this flag should be set by the connector, for security reasons.


Generated at Thu Feb 08 03:05:05 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.