From 7b666aafe6faab4e16401870829ae1a8f8718e02 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 18 Jul 2023 16:05:42 +0600 Subject: [PATCH] Fixed user home directory getting --- source/ubl-utils.c | 6 +++++- source/ubl-utils.h | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 482d1e8..dbca61e 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -802,7 +802,11 @@ char *yon_ubl_root_user_get(){ } char *yon_ubl_user_get_home_directory(){ - return getenv("HOME"); + FILE *path = popen(get_home_dir_command,"r"); + char *ret = g_malloc(4096); + fgets(ret,4096,path); + ret=yon_char_divide_search(ret,"\n",-1); + return ret; } // parsing functions diff --git a/source/ubl-utils.h b/source/ubl-utils.h index a7394ea..d92f7c2 100644 --- a/source/ubl-utils.h +++ b/source/ubl-utils.h @@ -9,6 +9,8 @@ #include #include #include +#include +#include #include #include #include @@ -24,6 +26,7 @@ #define new(type) malloc(sizeof(type)) #define new_arr(type,size) malloc(sizeof(type)*size) +#define get_home_dir_command yon_char_unite("getent passwd \"",yon_ubl_root_user_get(),"\" | cut -d: -f6",NULL) typedef enum {