]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Revert "tree-wide: Mount file descriptors via /proc/<pid>/fd"
authorLennart Poettering <lennart@poettering.net>
Fri, 8 Sep 2023 19:28:26 +0000 (21:28 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 8 Sep 2023 21:13:09 +0000 (22:13 +0100)
src/basic/fd-util.h
src/libsystemd-network/sd-dhcp6-client.c
src/network/networkd-dhcp-server.c
src/network/networkd-manager.c
src/network/networkd-state-file.c
src/resolve/resolved-link.c
src/test/test-fd-util.c
src/udev/net/link-config.c

index 4a02d920786350db15e5c6a586bda72d52266dd7..6aecb91fab3e98ec12d05de9f89d752af1f128ad 100644 (file)
@@ -8,8 +8,6 @@
 #include <sys/socket.h>
 
 #include "macro.h"
-#include "format-util.h"
-#include "process-util.h"
 #include "stdio-util.h"
 
 /* maximum length of fdname */
@@ -114,17 +112,14 @@ static inline int dir_fd_is_root_or_cwd(int dir_fd) {
         return dir_fd == AT_FDCWD ? true : path_is_root_at(dir_fd, NULL);
 }
 
-/* The maximum length a buffer for a /proc/<pid>/fd/<fd> path needs. We intentionally don't use /proc/self/fd
- * as these paths might be read by other programs (for example when mounting file descriptors the source path
- * ends up in /proc/mounts and related files) for which /proc/self/fd will be interpreted differently than
- * /proc/<pid>/fd. */
+/* The maximum length a buffer for a /proc/self/fd/<fd> path needs */
 #define PROC_FD_PATH_MAX \
-        (STRLEN("/proc//fd/") + DECIMAL_STR_MAX(pid_t) + DECIMAL_STR_MAX(int))
+        (STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int))
 
 static inline char *format_proc_fd_path(char buf[static PROC_FD_PATH_MAX], int fd) {
         assert(buf);
         assert(fd >= 0);
-        assert_se(snprintf_ok(buf, PROC_FD_PATH_MAX, "/proc/" PID_FMT "/fd/%i", getpid_cached(), fd));
+        assert_se(snprintf_ok(buf, PROC_FD_PATH_MAX, "/proc/self/fd/%i", fd));
         return buf;
 }
 
index fb209a0c624cf71b12c18d051205196dba3f4f3a..120384b3dafe6f5b5f451aa613234782544ed860 100644 (file)
@@ -5,9 +5,8 @@
 
 #include <errno.h>
 #include <sys/ioctl.h>
-#include <net/if.h>
-#include <linux/if_arp.h> /* Must be included after <net/if.h> */
-#include <linux/if_infiniband.h> /* Must be included after <net/if.h> */
+#include <linux/if_arp.h>
+#include <linux/if_infiniband.h>
 
 #include "sd-dhcp6-client.h"
 
index c1d9fbc17cf05301eac1c71cde1beb611fd0d761..240c512fd85a3fbbf3a84d9ab769752f57ebd929 100644 (file)
@@ -1,9 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include <netinet/in.h>
-#include <net/if.h>
-#include <linux/if_arp.h> /* Must be included after <net/if.h> */
-#include <linux/if.h> /* Must be included after <net/if.h> */
+#include <linux/if_arp.h>
+#include <linux/if.h>
 
 #include "sd-dhcp-server.h"
 
index 51434a1abd27eed0ac025bd74b2eb70bf7d1ab9d..ab5460db27ec9eb4cad25147f7af3640d735ef29 100644 (file)
@@ -3,8 +3,7 @@
 #include <netinet/in.h>
 #include <sys/socket.h>
 #include <unistd.h>
-#include <net/if.h>
-#include <linux/if.h> /* Must be included after <net/if.h> */
+#include <linux/if.h>
 #include <linux/fib_rules.h>
 #include <linux/nexthop.h>
 #include <linux/nl80211.h>
index e27984d2de8ace9fd1521bfd8dc4b0458d0d12be..85c9d2108204d391a95122a8cdc0b950d64b052e 100644 (file)
@@ -1,8 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include <netinet/in.h>
-#include <net/if.h>
-#include <linux/if.h> /* Must be included after <net/if.h> */
+#include <linux/if.h>
 
 #include "alloc-util.h"
 #include "dns-domain.h"
index a60aabb39590abd7492630a1af2a304a8addfa96..dd5daddce486f166f2123a46d2ebcca06c89e413 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <net/if.h>
-#include <linux/if.h> /* Must be included after <net/if.h> */
+#include <linux/if.h>
 #include <unistd.h>
 
 #include "sd-network.h"
index 1674758e6b87014c3c9946e23113a8a31fbb7a22..20d412f5c6c82292644e47d365a5bd1880db986c 100644 (file)
@@ -382,16 +382,11 @@ TEST(close_all_fds) {
 }
 
 TEST(format_proc_fd_path) {
-        _cleanup_free_ char *expected = NULL;
-
-        for (int i = 0; i < 4; i++) {
-                assert_se(asprintf(&expected, "/proc/" PID_FMT "/fd/%i", getpid_cached(), i) >= 0);
-                assert_se(streq_ptr(FORMAT_PROC_FD_PATH(i), expected));
-                expected = mfree(expected);
-        }
-
-        assert_se(asprintf(&expected, "/proc/" PID_FMT "/fd/2147483647", getpid_cached()) >= 0);
-        assert_se(streq_ptr(FORMAT_PROC_FD_PATH(2147483647), expected));
+        assert_se(streq_ptr(FORMAT_PROC_FD_PATH(0), "/proc/self/fd/0"));
+        assert_se(streq_ptr(FORMAT_PROC_FD_PATH(1), "/proc/self/fd/1"));
+        assert_se(streq_ptr(FORMAT_PROC_FD_PATH(2), "/proc/self/fd/2"));
+        assert_se(streq_ptr(FORMAT_PROC_FD_PATH(3), "/proc/self/fd/3"));
+        assert_se(streq_ptr(FORMAT_PROC_FD_PATH(2147483647), "/proc/self/fd/2147483647"));
 }
 
 TEST(fd_reopen) {
index e7b28d33f07b74c831ac80a73827533ef5135f18..ff8fb24f6695385edff4497575ee0398aad20a93 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <net/if.h>
-#include <linux/netdevice.h> /* Must be included after <net/if.h> */
+#include <linux/netdevice.h>
 #include <netinet/ether.h>
 #include <unistd.h>