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

Make use of the O_CLOEXEC flag when dealing with file descriptors #145

Merged
merged 4 commits into from
Apr 13, 2018

Commits on Apr 10, 2018

  1. Open file descriptors with O_CLOEXEC

    This opens any file descriptors with the O_CLOEXEC flag, which will make sure
    that file descriptors won't be leaked into any child process. This was
    previously an issue due to a forgotten fclose() (Yubico#136).
    kbabioch committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    079b975 View commit details
    Browse the repository at this point in the history
  2. Add "e" flag to fopen() calls

    This adds the `e` flag to fopen() calls, making sure the `O_CLOEXEC` flag is
    used. This makes sure that the file descriptor is being closed and not leaked
    into child processes. This was an issues previously due to a missing fclose()
    (Yubico#136).
    kbabioch committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    d51124e View commit details
    Browse the repository at this point in the history
  3. Use mkotemp() instead of mkstemp()

    This uses mkostemp() instead of mkstemp(), passing along the `O_CLOEXEC` flag,
    which makes sure that the file descriptor is closed and won't be leaked into
    any child process, which was previously an issue due to a missing fclose()
    (Yubico#136).
    kbabioch committed Apr 10, 2018
    Configuration menu
    Copy the full SHA
    0b595ee View commit details
    Browse the repository at this point in the history

Commits on Apr 11, 2018

  1. Open file handlers manually using open() and fdopen() instead of usin…

    …g fopen()
    
    A previous commit (d51124e) added the `e` flag to the `fopen()` calls. However
    this flag is not supported on all platforms (MacOS) and will be silently
    dropped (see Yubico#145). This patch works around those issues by manually opening
    the file descriptor using `open()` with the `O_CLOEXEC` flag, and invoking
    `fd_open()` on the resulting file descriptor to open an appropriate `FILE`
    stream.
    
    This makes sure that all files used by pam_yubico will be opened with the
    `O_CLOEXEC` flag on all supported platforms to mitigate issues with missing
    `fclose()` invocation (see Yubico#136).
    kbabioch committed Apr 11, 2018
    Configuration menu
    Copy the full SHA
    e5bd2ef View commit details
    Browse the repository at this point in the history