diff options
author | Ron Yorston <rmy@pobox.com> | 2015-05-18 13:17:02 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2015-05-18 13:17:02 +0100 |
commit | 10695d3d3472bb5ad7b9f5d9313f073fc67a8f1a (patch) | |
tree | f1b00d0728d99de1dc25ed22c62e6aba9941ed21 | |
parent | 9eb16cb1dcbda28dc82689a422c6c77455804682 (diff) | |
download | busybox-w32-10695d3d3472bb5ad7b9f5d9313f073fc67a8f1a.tar.gz busybox-w32-10695d3d3472bb5ad7b9f5d9313f073fc67a8f1a.tar.bz2 busybox-w32-10695d3d3472bb5ad7b9f5d9313f073fc67a8f1a.zip |
mingw: implement getpwnam (but only for current user)
This allows the shell to expand ~user.
-rw-r--r-- | include/mingw.h | 2 | ||||
-rw-r--r-- | win32/mingw.c | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/include/mingw.h b/include/mingw.h index 86259f2d1..f3b260f5a 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
@@ -82,7 +82,7 @@ struct passwd { | |||
82 | gid_t pw_gid; | 82 | gid_t pw_gid; |
83 | }; | 83 | }; |
84 | 84 | ||
85 | IMPL(getpwnam,struct passwd *,NULL,const char *name UNUSED_PARAM); | 85 | struct passwd *getpwnam(const char *name); |
86 | struct passwd *getpwuid(uid_t uid); | 86 | struct passwd *getpwuid(uid_t uid); |
87 | static inline void setpwent(void) {} | 87 | static inline void setpwent(void) {} |
88 | static inline void endpwent(void) {} | 88 | static inline void endpwent(void) {} |
diff --git a/win32/mingw.c b/win32/mingw.c index 514d00692..5847e0fa0 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -603,6 +603,18 @@ static char *get_user_name(void) | |||
603 | return user_name; | 603 | return user_name; |
604 | } | 604 | } |
605 | 605 | ||
606 | struct passwd *getpwnam(const char *name) | ||
607 | { | ||
608 | const char *myname; | ||
609 | |||
610 | if ( (myname=get_user_name()) != NULL && | ||
611 | strcmp(myname, name) == 0 ) { | ||
612 | return getpwuid(DEFAULT_UID); | ||
613 | } | ||
614 | |||
615 | return NULL; | ||
616 | } | ||
617 | |||
606 | struct passwd *getpwuid(uid_t uid UNUSED_PARAM) | 618 | struct passwd *getpwuid(uid_t uid UNUSED_PARAM) |
607 | { | 619 | { |
608 | static struct passwd p; | 620 | static struct passwd p; |