Fixed config creation failure

pull/36/head
parent fc7db60f16
commit a9cad1c28a

@ -2263,22 +2263,33 @@ int yon_file_create(char *path, char *name, int rules){
int yon_file_create_full_path(char *path, int rules){ int yon_file_create_full_path(char *path, int rules){
if (path){ if (path){
if (access(path,F_OK)){ if (access(path,F_OK)){
FILE *fl = fopen(path,"w"); int size;
if (fl){ config_str parsed = yon_char_parse(path,&size,"/");
struct passwd *user = getpwnam(yon_ubl_root_user_get()); char *current = "";
chown(path,user->pw_uid,user->pw_gid); for (int i=0;i<size;i++){
chmod(path,rules); char *temp = yon_char_unite(current,strcmp(current,"/")?"/":"",parsed[i],NULL);
fclose(fl); if (!yon_char_is_empty(temp)){
return 1; if (access(temp,F_OK)){
} else { if (i!=size-1){
return 0; mkdir(temp,0555);
} else {
FILE *fl = fopen(temp,"w");
}
struct passwd *user = getpwnam(yon_ubl_root_user_get());
int chown_success = chown(temp,user->pw_uid,user->pw_gid);
int chmod_success = chmod(temp,rules);
}
}
if (!yon_char_is_empty(current)) free(current);
current = temp;
} }
return 1;
} else { } else {
return -1; return 0;
} }
} else {
return 0;
} }
return 0;
} }
config_str yon_file_list_dirs (char *path, int *size){ config_str yon_file_list_dirs (char *path, int *size){

Loading…
Cancel
Save