From fc7db60f16a1e8a9e5899f11225da775c67a2e33 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 8 Nov 2024 14:40:40 +0600 Subject: [PATCH 1/4] file creation fixes --- source/libublsettings.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/libublsettings.c b/source/libublsettings.c index 54e9dee..9aa99b7 100644 --- a/source/libublsettings.c +++ b/source/libublsettings.c @@ -2227,6 +2227,8 @@ config_str yon_file_open(char *file_path, int *size){ int yon_file_save(char *file_path, char *text){ FILE *file = fopen(file_path,"w"); + struct passwd *user = getpwnam(yon_ubl_root_user_get()); + chown(file_path,user->pw_uid,user->pw_gid); chmod(file_path,0777); if (file){ fputs(text,file); @@ -2241,8 +2243,9 @@ int yon_file_create(char *path, char *name, int rules){ char *full_path = yon_char_unite(path,"/",name,NULL); if (access(full_path,F_OK)){ FILE *fl = fopen(full_path,"w"); - chmod(full_path,0777); if (fl){ + struct passwd *user = getpwnam(yon_ubl_root_user_get()); + chown(path,user->pw_uid,user->pw_gid); chmod(full_path,rules); fclose(fl); return 1; @@ -2261,8 +2264,9 @@ int yon_file_create_full_path(char *path, int rules){ if (path){ if (access(path,F_OK)){ FILE *fl = fopen(path,"w"); - chmod(path,0777); if (fl){ + struct passwd *user = getpwnam(yon_ubl_root_user_get()); + chown(path,user->pw_uid,user->pw_gid); chmod(path,rules); fclose(fl); return 1; From a9cad1c28a705772a7b28ce9618b24923a7f018f Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 11 Nov 2024 14:32:34 +0600 Subject: [PATCH 2/4] Fixed config creation failure --- source/libublsettings.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/source/libublsettings.c b/source/libublsettings.c index 9aa99b7..86b6a84 100644 --- a/source/libublsettings.c +++ b/source/libublsettings.c @@ -2263,22 +2263,33 @@ int yon_file_create(char *path, char *name, int rules){ int yon_file_create_full_path(char *path, int rules){ if (path){ if (access(path,F_OK)){ - FILE *fl = fopen(path,"w"); - if (fl){ - struct passwd *user = getpwnam(yon_ubl_root_user_get()); - chown(path,user->pw_uid,user->pw_gid); - chmod(path,rules); - fclose(fl); - return 1; - } else { - return 0; + int size; + config_str parsed = yon_char_parse(path,&size,"/"); + char *current = ""; + for (int i=0;ipw_uid,user->pw_gid); + int chmod_success = chmod(temp,rules); + } + } + if (!yon_char_is_empty(current)) free(current); + current = temp; } + + return 1; } else { - return -1; + return 0; } - } else { - return 0; } + return 0; } config_str yon_file_list_dirs (char *path, int *size){ From cf0913d1d5c826fa5102f31cd3ca64c02a720e73 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 12 Nov 2024 12:14:06 +0600 Subject: [PATCH 3/4] Changed chmod rules --- source/libublsettings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libublsettings.c b/source/libublsettings.c index 86b6a84..026f32c 100644 --- a/source/libublsettings.c +++ b/source/libublsettings.c @@ -2229,7 +2229,7 @@ int yon_file_save(char *file_path, char *text){ FILE *file = fopen(file_path,"w"); struct passwd *user = getpwnam(yon_ubl_root_user_get()); chown(file_path,user->pw_uid,user->pw_gid); - chmod(file_path,0777); + chmod(file_path,0644); if (file){ fputs(text,file); fclose(file); From 96b1289ac94ea7352c101c69dcd143de115b4a09 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 15 Nov 2024 10:16:38 +0600 Subject: [PATCH 4/4] fixes --- source/libublsettings.c | 22 ++++++++++++++++++---- source/libublsettings.h | 2 ++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/source/libublsettings.c b/source/libublsettings.c index 026f32c..33a26ca 100644 --- a/source/libublsettings.c +++ b/source/libublsettings.c @@ -664,6 +664,20 @@ int yon_char_parsed_check_exist(char **parameters, int size, char *param){ return -1; } + +int yon_char_parsed_strstr(char **parameters, int size, char *param){ + if (parameters){ + for (int i=0;ipw_uid,user->pw_gid); - int chmod_success = chmod(temp,rules); + struct passwd *user = getpwnam(yon_ubl_root_user_get()); + int chown_success = chown(temp,user->pw_uid,user->pw_gid); } } if (!yon_char_is_empty(current)) free(current); diff --git a/source/libublsettings.h b/source/libublsettings.h index 20b6ff5..dcc84a8 100644 --- a/source/libublsettings.h +++ b/source/libublsettings.h @@ -432,6 +432,8 @@ char **yon_char_parsed_rip(char **char_string, int *size, int item_to_delete); */ int yon_char_parsed_check_exist(char **parameters, int size, char *param); +int yon_char_parsed_strstr(char **parameters, int size, char *param); + /**yon_char_parsed_check_repeats(char **parameters, int size) * [EN] * Checks if [parameters] string array of length [size]