Skip to content

conf: Return an error if zlog_init is called with a non-regular file#279

Open
iancuivasciuc wants to merge 1 commit intoHardySimpson:masterfrom
iancuivasciuc:bugfix/log_init
Open

conf: Return an error if zlog_init is called with a non-regular file#279
iancuivasciuc wants to merge 1 commit intoHardySimpson:masterfrom
iancuivasciuc:bugfix/log_init

Conversation

@iancuivasciuc
Copy link
Copy Markdown

Currently, calling zlog_init with a non-regular file (e.g., a directory) didn’t return an error. The logger would have been configured the same as with an empty file.

The file is now checked to ensure it is regular, and an error is returned if it is not.

Fixes #278.

@deemar
Copy link
Copy Markdown
Collaborator

deemar commented Nov 11, 2024

I think a symbolic link should be accepted too.

@iancuivasciuc
Copy link
Copy Markdown
Author

I don’t have extensive experience, so I could be mistaken. If I only check that the file is a symlink, it could still point to something other than a regular file, which should be avoided.

Shouldn't the stat command be used directly? I also noticed that stat is used directly in other parts of the project.

Currently, calling zlog_init with a non-regular file (e.g., a directory)
didn’t return an error. The logger would have been configured the same
as with an empty file.

The file is now checked to ensure it is regular, and an error is returned
if it is not.

Fixes HardySimpson#278.
@deemar
Copy link
Copy Markdown
Collaborator

deemar commented Nov 15, 2024

I don’t have extensive experience, so I could be mistaken. If I only check that the file is a symlink, it could still point to something other than a regular file, which should be avoided.

Shouldn't the stat command be used directly? I also noticed that stat is used directly in other parts of the project.

you can use realpath first

@iancuivasciuc
Copy link
Copy Markdown
Author

iancuivasciuc commented Nov 16, 2024

you can use realpath first

But is there a problem with the current pr?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

conf: zlog_init doesn't return an error when given a non-regular file path for initialization

2 participants