From 9da16c91477293e7b367127b0bdec92d9613440f Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Tue, 17 Jan 2012 14:43:23 -0500 Subject: util: move getusername to util.c Signed-off-by: Jeff Layton --- mount.cifs.c | 11 ----------- util.c | 13 +++++++++++++ util.h | 1 + 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 #include +#include /* 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 */ -- cgit v1.2.3