summaryrefslogtreecommitdiff
path: root/src/passwd/getspnam.c
diff options
context:
space:
mode:
authorVladimir Azarov <avm@intermediate-node.net>2024-10-01 15:47:05 +0200
committerVladimir Azarov <avm@intermediate-node.net>2024-10-01 15:47:05 +0200
commit4abab5ad6c8465a7528ccdd5f49367da05f78bbd (patch)
treeebf009bf1376a5a223a915bc27cbbd791a1316bc /src/passwd/getspnam.c
Initial version
Diffstat (limited to 'src/passwd/getspnam.c')
-rw-r--r--src/passwd/getspnam.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/passwd/getspnam.c b/src/passwd/getspnam.c
new file mode 100644
index 0000000..709b526
--- /dev/null
+++ b/src/passwd/getspnam.c
@@ -0,0 +1,18 @@
+#include "pwf.h"
+
+#define LINE_LIM 256
+
+struct spwd *getspnam(const char *name)
+{
+ static struct spwd sp;
+ static char *line;
+ struct spwd *res;
+ int e;
+ int orig_errno = errno;
+
+ if (!line) line = malloc(LINE_LIM);
+ if (!line) return 0;
+ e = getspnam_r(name, &sp, line, LINE_LIM, &res);
+ errno = e ? e : orig_errno;
+ return res;
+}