From: Babanpreet Singh <bbnpreetsingh@gmail.com>
To: yocto-patches@lists.yoctoproject.org
Cc: Richard Purdie <richard.purdie@linuxfoundation.org>,
Mark Hatle <mark.hatle@amd.com>,
Mark Hatle <mark.hatle@kernel.crashing.org>,
Paul Barker <paul@pbarker.dev>,
Randy MacLeod <randy.macleod@windriver.com>,
Vincent Haupert <mail@vincent-haupert.de>,
Babanpreet Singh <bbnpreetsingh@gmail.com>
Subject: [pseudo] [PATCH 3/3] pseudo_client: remove the unused pseudo_prefix_dir_fd
Date: Sat, 18 Jul 2026 04:37:50 +0000 [thread overview]
Message-ID: <20260718043750.7-4-bbnpreetsingh@gmail.com> (raw)
In-Reply-To: <20260718043750.7-1-bbnpreetsingh@gmail.com>
pseudo has kept an O_RDONLY descriptor on PSEUDO_PREFIX since its
first commit (33d9386, 2010), where client_connect() fchdir()'d
through it so the server socket could be reached by a path short
enough for sun_path. 551bf567 ("Add new environment values to allow
easy override of default locations") moved that job to
pseudo_localstate_dir_fd. Nothing has read pseudo_prefix_dir_fd back
since then.
Two side effects of opening it go away. Client init created a missing
PSEUDO_PREFIX with mkdir_p(); the default PSEUDO_LOCALSTATEDIR lives
under the prefix and its own setup runs the same mkdir_p(), so the
directory is still created there, while a custom PSEUDO_LOCALSTATEDIR
never needed the prefix directory at client init. An unset or
unopenable PSEUDO_PREFIX was a diagnostic and exit(1), and still is,
from the local state setup directly below.
The sweeps in OP_CLOSEFROM and OP_CLOSE_RANGE no longer need to step
around the descriptor, so the entries the previous commit added for
it go away again.
Discussed in
https://lore.kernel.org/yocto-patches/20260716055633.7-1-bbnpreetsingh@gmail.com/
AI-Generated: Uses Claude (claude-sonnet-5)
Signed-off-by: Babanpreet Singh <bbnpreetsingh@gmail.com>
---
doc/program_flow | 1 -
pseudo_client.c | 66 +++++-------------------------------------------
pseudo_client.h | 1 -
3 files changed, 6 insertions(+), 62 deletions(-)
diff --git a/doc/program_flow b/doc/program_flow
index 3a399a7..e987e4a 100644
--- a/doc/program_flow
+++ b/doc/program_flow
@@ -15,7 +15,6 @@ libpseudo execution flow:
setup pseudo_logfile
pseudo_client.c: pseudo_init_client()
setup PSEUDO_DISABLED
- setup pseudo_prefix_dir_fd
setup pseudo_localstate_dir_fd
setup PSEUDO_NOSYMLINKEXP
setup PSEUDO_UIDS
diff --git a/pseudo_client.c b/pseudo_client.c
index 7f80a3b..46b6a3b 100644
--- a/pseudo_client.c
+++ b/pseudo_client.c
@@ -46,7 +46,6 @@ static char *base_path(int dirfd, const char *path, int leave_last);
static int connect_fd = -1;
static int server_pid = 0;
-int pseudo_prefix_dir_fd = -1;
int pseudo_localstate_dir_fd = -1;
int pseudo_pwd_fd = -1;
int pseudo_pwd_lck_fd = -1;
@@ -532,7 +531,6 @@ pseudo_init_client(void) {
if (!pseudo_inited) {
/* Ensure that all of the values are reset */
server_pid = 0;
- pseudo_prefix_dir_fd = -1;
pseudo_localstate_dir_fd = -1;
pseudo_pwd_fd = -1;
pseudo_pwd_lck_fd = -1;
@@ -555,29 +553,6 @@ pseudo_init_client(void) {
pseudo_umask = umask(022);
umask(pseudo_umask);
- pseudo_path = pseudo_prefix_path(NULL);
- if (pseudo_prefix_dir_fd == -1) {
- if (pseudo_path) {
- pseudo_prefix_dir_fd = open(pseudo_path, O_RDONLY);
- /* directory is missing? */
- if (pseudo_prefix_dir_fd == -1 && errno == ENOENT) {
- pseudo_debug(PDBGF_CLIENT, "prefix directory '%s' doesn't exist, trying to create\n", pseudo_path);
- mkdir_p(pseudo_path);
- pseudo_prefix_dir_fd = open(pseudo_path, O_RDONLY);
- }
- pseudo_prefix_dir_fd = pseudo_fd(pseudo_prefix_dir_fd, MOVE_FD);
- } else {
- pseudo_diag("No prefix available to to find server.\n");
- exit(1);
- }
- if (pseudo_prefix_dir_fd == -1) {
- pseudo_diag("Can't open prefix path '%s' for server: %s\n",
- pseudo_path,
- strerror(errno));
- exit(1);
- }
- }
- free(pseudo_path);
pseudo_path = pseudo_localstatedir_path(NULL);
if (pseudo_localstate_dir_fd == -1) {
if (pseudo_path) {
@@ -1439,29 +1414,6 @@ pseudo_client_shutdown(int wait_on_socket) {
char *pseudo_path;
pseudo_debug(PDBGF_INVOKE, "attempting to shut down server.\n");
- pseudo_path = pseudo_prefix_path(NULL);
- if (pseudo_prefix_dir_fd == -1) {
- if (pseudo_path) {
- pseudo_prefix_dir_fd = open(pseudo_path, O_RDONLY);
- /* directory is missing? */
- if (pseudo_prefix_dir_fd == -1 && errno == ENOENT) {
- pseudo_debug(PDBGF_CLIENT, "prefix directory doesn't exist, trying to create\n");
- mkdir_p(pseudo_path);
- pseudo_prefix_dir_fd = open(pseudo_path, O_RDONLY);
- }
- pseudo_prefix_dir_fd = pseudo_fd(pseudo_prefix_dir_fd, COPY_FD);
- free(pseudo_path);
- } else {
- pseudo_diag("No prefix available to to find server.\n");
- exit(1);
- }
- if (pseudo_prefix_dir_fd == -1) {
- pseudo_diag("Can't open prefix path (%s) for server. (%s)\n",
- pseudo_prefix_path(NULL),
- strerror(errno));
- exit(1);
- }
- }
pseudo_path = pseudo_localstatedir_path(NULL);
mkdir_p(pseudo_path);
if (pseudo_localstate_dir_fd == -1) {
@@ -1970,8 +1922,6 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path
startfd = pseudo_util_debug_fd + 1;
if (pseudo_util_evlog_fd >= startfd)
startfd = pseudo_util_evlog_fd + 1;
- if (pseudo_prefix_dir_fd >= startfd)
- startfd = pseudo_prefix_dir_fd + 1;
if (pseudo_localstate_dir_fd >= startfd)
startfd = pseudo_localstate_dir_fd + 1;
if (pseudo_pwd_fd >= startfd)
@@ -1984,9 +1934,9 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path
startfd = connect_fd + 1;
for (i = fd; i < startfd; ++i) {
if (i == pseudo_util_debug_fd || i == pseudo_util_evlog_fd ||
- i == pseudo_prefix_dir_fd || i == pseudo_localstate_dir_fd ||
- i == pseudo_pwd_fd || i == pseudo_pwd_lck_fd ||
- i == pseudo_grp_fd || i == connect_fd)
+ i == pseudo_localstate_dir_fd || i == pseudo_pwd_fd ||
+ i == pseudo_pwd_lck_fd || i == pseudo_grp_fd ||
+ i == connect_fd)
continue;
pseudo_client_close(i);
close(i);
@@ -2004,8 +1954,6 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path
startfd = pseudo_util_debug_fd + 1;
if (pseudo_util_evlog_fd >= startfd)
startfd = pseudo_util_evlog_fd + 1;
- if (pseudo_prefix_dir_fd >= startfd)
- startfd = pseudo_prefix_dir_fd + 1;
if (pseudo_localstate_dir_fd >= startfd)
startfd = pseudo_localstate_dir_fd + 1;
if (pseudo_pwd_fd >= startfd)
@@ -2021,9 +1969,9 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path
*/
for (i = fd; i < startfd && (unsigned int) i <= close_range_maxfd; ++i) {
if (i == pseudo_util_debug_fd || i == pseudo_util_evlog_fd ||
- i == pseudo_prefix_dir_fd || i == pseudo_localstate_dir_fd ||
- i == pseudo_pwd_fd || i == pseudo_pwd_lck_fd ||
- i == pseudo_grp_fd || i == connect_fd)
+ i == pseudo_localstate_dir_fd || i == pseudo_pwd_fd ||
+ i == pseudo_pwd_lck_fd || i == pseudo_grp_fd ||
+ i == connect_fd)
continue;
pseudo_client_close(i);
close(i);
@@ -2045,8 +1993,6 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path
}
} else if (fd == pseudo_util_debug_fd) {
pseudo_util_debug_fd = pseudo_fd(fd, COPY_FD);
- } else if (fd == pseudo_prefix_dir_fd) {
- pseudo_prefix_dir_fd = pseudo_fd(fd, COPY_FD);
} else if (fd == pseudo_localstate_dir_fd) {
pseudo_localstate_dir_fd = pseudo_fd(fd, COPY_FD);
} else if (fd == pseudo_pwd_fd) {
diff --git a/pseudo_client.h b/pseudo_client.h
index a013f88..206f630 100644
--- a/pseudo_client.h
+++ b/pseudo_client.h
@@ -39,7 +39,6 @@ extern gid_t pseudo_egid;
extern gid_t pseudo_sgid;
extern gid_t pseudo_rgid;
extern gid_t pseudo_fgid;
-extern int pseudo_prefix_dir_fd;
extern int pseudo_localstate_dir_fd;
extern FILE *pseudo_pwd_open(void);
extern FILE *pseudo_grp_open(void);
--
2.43.0
prev parent reply other threads:[~2026-07-18 4:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 5:41 [pseudo] [PATCH 0/2] close_range: implement it rather than return ENOSYS Baban
2026-07-15 5:41 ` [pseudo] [PATCH 1/2] ports/linux/guts: Implement close_range() instead of returning ENOSYS Baban
2026-07-15 19:51 ` [yocto-patches] " Paul Barker
2026-07-15 5:41 ` [pseudo] [PATCH 2/2] tests: Add close_range() test Baban
2026-07-15 20:03 ` [yocto-patches] " Paul Barker
2026-07-16 5:56 ` [pseudo] [PATCH v2 0/2] close_range: implement it rather than return ENOSYS Babanpreet Singh
2026-07-16 5:56 ` [pseudo] [PATCH v2 1/2] ports/linux/guts: Implement close_range() instead of returning ENOSYS Babanpreet Singh
2026-07-16 5:56 ` [pseudo] [PATCH v2 2/2] tests: Add close_range() test Babanpreet Singh
2026-07-16 10:46 ` [pseudo] [PATCH v2 0/2] close_range: implement it rather than return ENOSYS Richard Purdie
2026-07-16 15:46 ` Babanpreet Singh
2026-07-16 16:55 ` Richard Purdie
2026-07-16 23:16 ` [yocto-patches] " Mark Hatle
2026-07-16 23:08 ` Mark Hatle
2026-07-18 4:37 ` [pseudo] [PATCH 0/3] closefrom/close_range: protect every pseudo fd, then drop one Babanpreet Singh
2026-07-18 4:37 ` [pseudo] [PATCH 1/3] pseudo_client: step fully past pseudo's own fds when computing startfd Babanpreet Singh
2026-07-18 4:37 ` [pseudo] [PATCH 2/3] pseudo_client: step around all of pseudo's own fds in closefrom/close_range Babanpreet Singh
2026-07-18 4:37 ` Babanpreet Singh [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260718043750.7-4-bbnpreetsingh@gmail.com \
--to=bbnpreetsingh@gmail.com \
--cc=mail@vincent-haupert.de \
--cc=mark.hatle@amd.com \
--cc=mark.hatle@kernel.crashing.org \
--cc=paul@pbarker.dev \
--cc=randy.macleod@windriver.com \
--cc=richard.purdie@linuxfoundation.org \
--cc=yocto-patches@lists.yoctoproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.