Uploaded image for project: 'Commons Daemon'
  1. Commons Daemon
  2. DAEMON-401

Environment variables set on service not available in JNI dll

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.1.1, 1.2.1
    • None
    • None
    • Patch

    Description

      I have a JNI dll loaded by a Java process running as a Windows service on Windows 2019 using prunsrv. The JNI library is built with VC14, and makes calls to getenv(), which is imported from ucrtbase.dll.

      This call to getenv does not pick up environment variables that are set on the service via //US//Service ++Environment "key=value". Commons Daemon is setting these environment variables using _wputenv(), which is imported from msvcrt.dll.

      I started a discussion on the mailing list regarding this. I have patch which dynamically loads ucrtbase.dll and calls its _wputenv method as well, if it is available.

      I'm happy to provide changes or further patches, and work on this issue, but feedback would be useful and very much appreciated.

      Attachments

        1. daemon-1.diff
          3 kB
          Jonathan Gallimore
        2. daemon-env.diff
          1 kB
          Jonathan Gallimore
        3. simple-jni.zip
          24 kB
          Jonathan Gallimore

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jgallimore Jonathan Gallimore
              Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m