diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2019-02-23 23:48:32 +0100 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2019-02-23 23:48:32 +0100 |
commit | 2ae2d648ab0bd5340ca1342c97d704b2d4ce948c (patch) | |
tree | 8edea5ed6859668fdf9ca12a86b5ca4adcd9424f /src | |
parent | 83952ad3d567fc9a307d9f330033f4036618f1f8 (diff) | |
download | blogc-2ae2d648ab0bd5340ca1342c97d704b2d4ce948c.tar.gz blogc-2ae2d648ab0bd5340ca1342c97d704b2d4ce948c.tar.bz2 blogc-2ae2d648ab0bd5340ca1342c97d704b2d4ce948c.zip |
blogc: sysinfo: simplified username impl. fixed tests
Diffstat (limited to 'src')
-rw-r--r-- | src/blogc/funcvars.c | 5 | ||||
-rw-r--r-- | src/blogc/sysinfo.c | 19 | ||||
-rw-r--r-- | src/blogc/sysinfo.h | 8 |
3 files changed, 2 insertions, 30 deletions
diff --git a/src/blogc/funcvars.c b/src/blogc/funcvars.c index 42411e2..6f0700b 100644 --- a/src/blogc/funcvars.c +++ b/src/blogc/funcvars.c @@ -30,14 +30,11 @@ static const struct func_map { {"BLOGC_SYSINFO_HOSTNAME", blogc_sysinfo_inject_hostname}, #endif -#ifdef HAVE_SYSINFO_USERNAME - {"BLOGC_SYSINFO_USERNAME", blogc_sysinfo_inject_username}, -#endif - #ifdef HAVE_SYSINFO_DATETIME {"BLOGC_SYSINFO_DATETIME", blogc_sysinfo_inject_datetime}, #endif + {"BLOGC_SYSINFO_USERNAME", blogc_sysinfo_inject_username}, {"BLOGC_SYSINFO_INSIDE_DOCKER", blogc_sysinfo_inject_inside_docker}, {NULL, NULL}, }; diff --git a/src/blogc/sysinfo.c b/src/blogc/sysinfo.c index 4ec1411..cdb860e 100644 --- a/src/blogc/sysinfo.c +++ b/src/blogc/sysinfo.c @@ -14,14 +14,6 @@ #include <unistd.h> #endif /* HAVE_UNISTD_H */ -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif /* HAVE_SYS_TYPES_H */ - -#ifdef HAVE_PWD_H -#include <pwd.h> -#endif /* HAVE_PWD_H */ - #ifdef HAVE_TIME_H #include <time.h> #endif /* HAVE_TIME_H */ @@ -66,16 +58,7 @@ blogc_sysinfo_inject_hostname(bc_trie_t *global) char* blogc_sysinfo_get_username(void) { -#ifndef HAVE_SYSINFO_USERNAME - return NULL; -#else - uid_t u = geteuid(); - struct passwd *p = getpwuid(u); - if (p == NULL) - return NULL; - - return bc_strdup(p->pw_name); -#endif + return bc_strdup(getenv("LOGNAME")); } diff --git a/src/blogc/sysinfo.h b/src/blogc/sysinfo.h index 783b656..b249661 100644 --- a/src/blogc/sysinfo.h +++ b/src/blogc/sysinfo.h @@ -19,14 +19,6 @@ #endif /* HAVE_GETHOSTNAME */ #endif /* HAVE_UNISTD_H */ -#ifdef HAVE_UNISTD_H -#ifdef HAVE_SYS_TYPES_H -#ifdef HAVE_PWD_H -#define HAVE_SYSINFO_USERNAME 1 -#endif /* HAVE_PWD_H */ -#endif /* HAVE_SYS_TYPES_H */ -#endif /* HAVE_UNISTD_H */ - #ifdef HAVE_TIME_H #define HAVE_SYSINFO_DATETIME 1 #endif /* HAVE_TIME_H */ |