summaryrefslogtreecommitdiff
path: root/src/misc/cuserid.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc/cuserid.c')
-rw-r--r--src/misc/cuserid.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/misc/cuserid.c b/src/misc/cuserid.c
new file mode 100644
index 00000000..8ad0b9f3
--- /dev/null
+++ b/src/misc/cuserid.c
@@ -0,0 +1,13 @@
+#include <pwd.h>
+#include <stdio.h>
+#include <unistd.h>
+
+char *cuserid(char *buf)
+{
+ struct passwd pw, *ppw;
+ long pwb[256];
+ if (getpwuid_r(geteuid(), &pw, (void *)pwb, sizeof pwb, &ppw))
+ return 0;
+ snprintf(buf, L_cuserid, "%s", pw.pw_name);
+ return buf;
+}