pseudo_util: Silence symlink errors and fix resolution bug
PATCH 1/1 pseudo_util: Silence symlink errors and fix resolution bug
readlink() failures are normal. pseudo should just set errno and let the program decide whether to report it. E.g. /proc/$pid/{cwd,exe,fd/*,root} are unreadable for other users' processes. The "pidof" program calls stat() on each /proc/$pid/exe, which causes pseudo to spam stderr. "pidof" is used e.g. by various dpkg postinst scripts.
This if branch also forgot to update *pcurrent, so "cat /proc/1/cwd/stat" would read /proc/1/stat instead of failing as it should.
Signed-off-by Tomi Belan <[email protected]>
---
Hi. I'd like to contribute this patch to 'pseudo'. I'm not familiar with git-send-email so I hope I sent it to the right place and it looks good. Cheers!
pseudo_util.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
pseudo_util.c +3 -2
@@ -679,7 +679,7 @@ pseudo_append_element(char *newpath, char *root, size_t allocated, char **pcurreif (!leave_this && is_dir) {int is_link =S_ISLNK (buf->st_mode);if (link_recursion >=PSEUDO_MAX_LINK_RECURSION && is_link) { -pseudo_diag ("link recursion too deep, not expanding path '%s'.\n" , newpath); +pseudo_debug (PDBGF_PATH ,"link recursion too deep, not expanding path '%s'.\n" , newpath); is_link =0 ; }if (is_link) {
@@ -689,7 +689,8 @@ pseudo_append_element(char *newpath, char *root, size_t allocated, char **pcurre linklen =readlink (newpath, linkbuf,pseudo_path_max ());if (linklen ==-1 ) { -pseudo_diag ("uh-oh! '%s' seems to be a symlink, but I can't read it. Ignoring." , newpath); +pseudo_debug (PDBGF_PATH ,"uh-oh! '%s' seems to be a symlink, but I can't read it. Ignoring.\n" , newpath); + *pcurrent = current;return 0 ; }/* null-terminate buffer */
Signature · 1 line
2.25.1