Skip to content

firetools can't create ~/.config/firetools if ~/.config doesn't exist #72

@audibleptr

Description

@audibleptr

The code here:

// create firetools directory if it doesn't exist
void create_config_directory() {
struct stat s;
char *path;
char *homedir = get_home_directory();
if (asprintf(&path, "%s/.config/firetools", homedir) == -1)
errExit("asprintf");
free(homedir);
if (stat(path, &s) == -1) {
/* coverity[toctou] */
int rv = mkdir(path, 0755);
if (rv == -1) {
fprintf(stderr, "Error: cannot create %s directory\n", path);
exit(1);
}
}
free(path);
}

can't create the ~/.config/firetools directory if ~/.configdoesn't exist. Apparently mkdir(...) doesn't directly support creating all the directories along the path (the way mkdir -p does).

This makes firetools fail to launch if ~/.configdoesn't exist.

Specifically, while this may be a rare occurrence in regular users' home directories, it can happen when launching firetools as root (having the home directory /root) where the home directory may not contain a .config subdirectory by default in some distributions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions