mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-07 14:24:14 +01:00
WINGs: Do not look static information up every time
Signed-off-by: Tamas TEVESZ <ice@extreme.hu>
This commit is contained in:
committed by
Carlos R. Mafra
parent
752d084609
commit
660b61a182
@@ -35,38 +35,50 @@
|
|||||||
|
|
||||||
char *wgethomedir()
|
char *wgethomedir()
|
||||||
{
|
{
|
||||||
char *home = getenv("HOME");
|
static char *home = NULL;
|
||||||
struct passwd *user;
|
struct passwd *user;
|
||||||
|
|
||||||
|
if (home)
|
||||||
|
return home;
|
||||||
|
|
||||||
|
home = getenv("HOME");
|
||||||
if (home)
|
if (home)
|
||||||
return home;
|
return home;
|
||||||
|
|
||||||
user = getpwuid(getuid());
|
user = getpwuid(getuid());
|
||||||
if (!user) {
|
if (!user) {
|
||||||
werror(_("could not get password entry for UID %i"), getuid());
|
werror(_("could not get password entry for UID %i"), getuid());
|
||||||
return "/";
|
home = "/";
|
||||||
}
|
|
||||||
if (!user->pw_dir) {
|
|
||||||
return "/";
|
|
||||||
} else {
|
|
||||||
return user->pw_dir;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!user->pw_dir)
|
||||||
|
home = "/";
|
||||||
|
else
|
||||||
|
home = wstrdup(user->pw_dir);
|
||||||
|
|
||||||
|
out:
|
||||||
|
return home;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *getuserhomedir(const char *username)
|
static char *getuserhomedir(const char *username)
|
||||||
{
|
{
|
||||||
|
static char *home = NULL;
|
||||||
struct passwd *user;
|
struct passwd *user;
|
||||||
|
|
||||||
|
if (home)
|
||||||
|
return home;
|
||||||
|
|
||||||
user = getpwnam(username);
|
user = getpwnam(username);
|
||||||
if (!user) {
|
if (!user) {
|
||||||
werror(_("could not get password entry for user %s"), username);
|
werror(_("could not get password entry for user %s"), username);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!user->pw_dir) {
|
if (!user->pw_dir)
|
||||||
return "/";
|
home = "/";
|
||||||
} else {
|
else
|
||||||
return user->pw_dir;
|
home = wstrdup(user->pw_dir);
|
||||||
}
|
|
||||||
|
return home;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *wexpandpath(char *path)
|
char *wexpandpath(char *path)
|
||||||
|
|||||||
Reference in New Issue
Block a user