summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Layton <jlayton@samba.org>2012-01-17 14:43:23 -0500
committerJeff Layton <jlayton@samba.org>2012-01-17 14:43:23 -0500
commit9da16c91477293e7b367127b0bdec92d9613440f (patch)
tree592b72ad0c8ce3d12d64ddc5ae52de1cb04e535e
parent92be8b6775958814d39fb19247ff85947a2e4f9e (diff)
downloadcifs-utils-9da16c91477293e7b367127b0bdec92d9613440f.tar.gz
cifs-utils-9da16c91477293e7b367127b0bdec92d9613440f.tar.bz2
cifs-utils-9da16c91477293e7b367127b0bdec92d9613440f.zip
util: move getusername to util.c
Signed-off-by: Jeff Layton <jlayton@samba.org>
-rw-r--r--mount.cifs.c11
-rw-r--r--util.c13
-rw-r--r--util.h1
3 files changed, 14 insertions, 11 deletions
diff --git a/mount.cifs.c b/mount.cifs.c
index 78a4811..a46a22c 100644
--- a/mount.cifs.c
+++ b/mount.cifs.c
@@ -363,17 +363,6 @@ static int set_password(struct parsed_mount_info *parsed_info, const char *src)
return 0;
}
-/* caller frees username if necessary */
-static char *getusername(uid_t uid)
-{
- char *username = NULL;
- struct passwd *password = getpwuid(uid);
-
- if (password)
- username = password->pw_name;
- return username;
-}
-
/*
* Parse a username string into parsed_mount_info fields. The format is:
*
diff --git a/util.c b/util.c
index 41c6784..80d5a80 100644
--- a/util.c
+++ b/util.c
@@ -24,6 +24,7 @@
#include <sys/types.h>
#include <string.h>
+#include <pwd.h>
/* glibc doesn't have strlcpy, strlcat. Ensure we do. JRA. We
* don't link to libreplace so need them here. */
@@ -69,3 +70,15 @@ size_t strlcat(char *d, const char *s, size_t bufsize)
}
#endif
+/* caller frees username if necessary */
+char *
+getusername(uid_t uid)
+{
+ char *username = NULL;
+ struct passwd *password = getpwuid(uid);
+
+ if (password)
+ username = password->pw_name;
+ return username;
+}
+
diff --git a/util.h b/util.h
index 7a44faf..d3ca015 100644
--- a/util.h
+++ b/util.h
@@ -28,5 +28,6 @@
size_t strlcpy(char *d, const char *s, size_t bufsize);
size_t strlcat(char *d, const char *s, size_t bufsize);
+char *getusername(uid_t uid);
#endif /* _LIBUTIL_H */