* bug#48503: [PATCH] Improve error reporting of getpw and getgr.
@ 2021-05-18 17:51 Taylan Kammer
0 siblings, 0 replies; only message in thread
From: Taylan Kammer @ 2021-05-18 17:51 UTC (permalink / raw)
To: 48503
[-- Attachment #1: Type: text/plain, Size: 114 bytes --]
Tag: patch
Severity: minor
The attached patch fixes/improves the error-reporting of getpw and getgr.
--
Taylan
[-- Attachment #2: 0001-Improve-error-reporting-of-getpw-and-getgr.patch --]
[-- Type: text/plain, Size: 1579 bytes --]
From 0b3faa5c01ed2d41fd7fc30e7bb4490d79ec2586 Mon Sep 17 00:00:00 2001
From: Taylan Kammer <taylan.kammer@gmail.com>
Date: Tue, 18 May 2021 19:32:10 +0200
Subject: [PATCH] Improve error reporting of getpw and getgr.
* libguile/posix.c (scm_getpwuid): Check errno to see if a SYSERROR
should be raised; otherwise improve not-found error message.
(scm_getgrgid): Raise a meaningful error when errno isn't set.
---
libguile/posix.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/libguile/posix.c b/libguile/posix.c
index 31c4ab192..6ce00b9b5 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -372,7 +372,12 @@ SCM_DEFINE (scm_getpwuid, "getpw", 0, 1, 0,
entry = getpwnam (c_user));
}
if (!entry)
- SCM_MISC_ERROR ("entry not found", SCM_EOL);
+ {
+ if (errno)
+ SCM_SYSERROR;
+ else
+ SCM_MISC_ERROR ("No such POSIX user.", scm_list_1 (user));
+ }
SCM_SIMPLE_VECTOR_SET(result, 0, scm_from_locale_string (entry->pw_name));
SCM_SIMPLE_VECTOR_SET(result, 1, scm_from_locale_string (entry->pw_passwd));
@@ -438,7 +443,12 @@ SCM_DEFINE (scm_getgrgid, "getgr", 0, 1, 0,
STRING_SYSCALL (name, c_name,
entry = getgrnam (c_name));
if (!entry)
- SCM_SYSERROR;
+ {
+ if (errno)
+ SCM_SYSERROR;
+ else
+ SCM_MISC_ERROR ("No such POSIX user group.", scm_list_1 (name));
+ }
SCM_SIMPLE_VECTOR_SET(result, 0, scm_from_locale_string (entry->gr_name));
SCM_SIMPLE_VECTOR_SET(result, 1, scm_from_locale_string (entry->gr_passwd));
--
2.30.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-05-18 17:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-18 17:51 bug#48503: [PATCH] Improve error reporting of getpw and getgr Taylan Kammer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).