mirror of
https://github.com/git/git.git
synced 2026-03-13 18:33:25 +01:00
Fake implementions of getpwuid(), getuid(), and getpwnam().
getpwuid() is kept as simple as possible so that no errors are generated. Since the information that it returns is not very useful, users are still required to set up user.name and user.email configuration. All uses of getpwuid() are like getpwuid(getuid()), hence, the return value of getpwuid() is irrelevant. getpwnam() is only used to resolve '~' and '~username' paths, which is an idiom not known on Windows, hence, we don't implement it, either. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
This commit is contained in:
@@ -620,3 +620,17 @@ int mingw_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
|
||||
} while (len < 0);
|
||||
return len;
|
||||
}
|
||||
|
||||
struct passwd *mingw_getpwuid(int uid)
|
||||
{
|
||||
static char user_name[100];
|
||||
static struct passwd p;
|
||||
|
||||
DWORD len = sizeof(user_name);
|
||||
if (!GetUserName(user_name, &len))
|
||||
return NULL;
|
||||
p.pw_name = user_name;
|
||||
p.pw_gecos = "unknown";
|
||||
p.pw_dir = NULL;
|
||||
return &p;
|
||||
}
|
||||
|
||||
@@ -527,6 +527,16 @@ int git_fstat(int fd, struct stat *buf);
|
||||
int mingw_vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
|
||||
#define vsnprintf mingw_vsnprintf
|
||||
|
||||
struct passwd {
|
||||
char *pw_name;
|
||||
char *pw_gecos;
|
||||
char *pw_dir;
|
||||
};
|
||||
struct passwd *mingw_getpwuid(int uid);
|
||||
#define getpwuid mingw_getpwuid
|
||||
static inline int getuid() { return 1; }
|
||||
static inline struct passwd *getpwnam(const char *name) { return NULL; }
|
||||
|
||||
#endif /* __MINGW32__ */
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user