AcademySoftwareFoundation / AcademySoftwareFoundation/rawtoaces
exiftool calls fail when popen() leaves errno set (Docker default seccomp)
- Dominant language
- C++
- Stars
- 193
- Forks
- 65
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 6
Description
rawtoaces main at 868a571, Ubuntu 24.04 inside Docker with the default seccomp profile, gcc 13.3, exiftool 12.76 in PATH.
Test_Exiftool and Test_ImageConverter (test_fetch_missing_metadata) fail although exiftool is installed and works from the shell:
```
FAILED: success == should_succeed
values were 'Failed to execute exiftool. Please make sure that its location is available in PATH. Alternatively you can provide the path to the exiftool binary via the RAWTOACES_EXIFTOOL_PATH environment variable.' and ''
```
`execute()` in src/rawtoaces_util/exiftool.cpp decides the call failed when errno is set after popen():
```cpp
errno = 0;
FILE *file = popen( command.c_str(), "r" );
bool success = ( errno == 0 );
```
popen() only sets errno when it returns NULL; a successful call is free to leave it non-zero. Under Docker's default seccomp profile glibc's posix_spawn tries clone3 first, gets ENOSYS, falls back to clone and runs the command fine, but errno stays at 38:
```c
errno = 0;
FILE *f = popen( "exiftool -ver", "r" );
/* output=12.76, errno after popen = 38 (Function not implemented) */
```
With `--security-opt seccomp=unconfined` errno is 0 and all 17 tests pass. GitHub's runners don't run under that profile, which is why CI never sees it. The comment above the check already says errno is unreliable, and the empty-output workaround was added because of it, but the errno check is still there and wins.
Two smaller things in the same function: if popen() does return NULL, `pclose( NULL )` is called; and the exit status from pclose() is discarded, so a command that prints something and then fails (exiftool exiting with 1, or 127 from the shell) counts as success as long as stdout is not empty.
PR coming up that checks the NULL return and the pclose() status instead of errno.
Contributor guide
Research direction
Start in src/rawtoaces_util/exiftool.cpp at execute(), then run Test_Exiftool and Test_ImageConverter, including test_fetch_missing_metadata, under Docker's default seccomp profile. Done means successful popen() calls are not rejected by a leftover errno, NULL returns are handled safely, and pclose() failures are not reported as successful executions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, docker, linux
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 82/100