Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config_scan_pem_dir() should handle DT_UNKNOWN #331

Closed
xavierog opened this issue Apr 6, 2020 · 2 comments · Fixed by #353
Closed

config_scan_pem_dir() should handle DT_UNKNOWN #331

xavierog opened this issue Apr 6, 2020 · 2 comments · Fixed by #353

Comments

@xavierog
Copy link
Contributor

xavierog commented Apr 6, 2020

Hi,

Small bug, unlikely to have been triggered before: config_scan_pem_dir() scans pemdir and keeps only files using if (d[i]->d_type != DT_REG).

However, some filesystems do not support d_type, which is liable to be DT_UNKNOWN instead of the usual DT_DIR, DT_REG, DT_LNK, etc.

As stated in readdir(3):

Currently, only some filesystems (among them: Btrfs, ext2, ext3, and ext4) have full support for returning the file type in d_type. All applications must properly handle a return of DT_UNKNOWN.

If it encounters DT_UNKNOWN, Hitch should stat() or lstat() the file (depending on how you wish to handle symlinks) and test the st_mode field.

If you need to set up a filesystem that does not support d_type to reproduce/fix the issue, I recommend using passthrough.py from python-fuse-sample.

@neverexists
Copy link

Hi,
we have a problem bound to this issue, i think, testing hitch on our server with root partition on Reiserfs.
Using pem-dir with some pem files on a Reiserfs partition trigger this error:
No x509 certificate PEM file specified for frontend '[(null)]:443'!

strace output:
openat(AT_FDCWD, "/nucleus/vX/etc-old/", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
fstat(3, {st_mode=S_IFDIR|0755, st_size=360, ...}) = 0
getdents64(3, 0x5620d6665a10 /* 10 entries /, 32768) = 408
getdents64(3, 0x5620d6665a10 /
0 entries */, 32768) = 0
close(3) = 0
write(2, "No x509 certificate PEM file specified for frontend '[(null)]:443'!\n", 68No x509 certificate PEM file specified for frontend '[(null)]:443'!
) = 68

Using a pem-dir on an ext4 partitions works as expected:
openat(AT_FDCWD, "/nucleus/vX/etc/", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
fstat(3, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
getdents64(3, 0x55dd1f837a10 /* 12 entries /, 32768) = 472
getdents64(3, 0x55dd1f837a10 /
0 entries */, 32768) = 0
close(3) = 0
stat("/nucleus/vX/etc/aaaa.pem", {st_mode=S_IFREG|0400, st_size=7767, ...}) = 0
stat("/nucleus/vX/etc/bbbb.pem", {st_mode=S_IFREG|0600, st_size=8063, ...}) = 0
....

It would be useful fixing this issue for filesystem without d_type support.

@neverexists
Copy link

Perfect, it works.
Thanks

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 a pull request may close this issue.

2 participants