v-webui icon indicating copy to clipboard operation
v-webui copied to clipboard

setroot is broken on linux

Open StephaneTy-Pro opened this issue 1 year ago • 1 comments

Description

nothing is shown (default html page for fail)

Expected Behavior

use the page to show

Reproduction Steps

No response

Error Logs

No response

Possible Solution

  • file detection using access give true if it's a file or a dir , so _webui_file_exist used by _webui_folder_exist return it's a file despite it was a folder

i'm not a c dev , but this was the solution i use

add sys/stat.h on header for linux

and replace

//return (WEBUI_FILE_EXIST(full_path, 0) == 0);

by

    struct stat path_stat;
    if (stat(full_path, &path_stat) != 0) {
        return false;  // Path does not exist
        #ifdef WEBUI_LOG_VERBOSE
        printf("[Core]\t\t_webui_file_exist() Path does not exist\n", full_path);
        #endif
    }
     // Check if it's a regular file (not a directory)
    if (S_ISREG(path_stat.st_mode)) {
		#ifdef WEBUI_LOG_VERBOSE
		printf("[Core]\t\t_webui_file_exist() [%s] is a regular file\n", full_path);
		#endif
        return true;
    } else {
		#ifdef WEBUI_LOG_VERBOSE
		printf("[Core]\t\t_webui_file_exist() [%s] is NOT a regular file\n", full_path);
		#endif
        return false;
    }

Version

2.5.0-beta2

Environment Details (OS name, version, etc.)

linux 5.10.0-12

StephaneTy-Pro avatar Oct 22 '24 17:10 StephaneTy-Pro

That's sound a legitimate fix! 👍 Can you please open a PR with those changes?

AlbertShown avatar Oct 22 '24 19:10 AlbertShown