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

/tmp/ is noexec on some Linux systems #387

Closed
fenugrec opened this issue Jan 9, 2022 · 2 comments
Closed

/tmp/ is noexec on some Linux systems #387

fenugrec opened this issue Jan 9, 2022 · 2 comments

Comments

@fenugrec
Copy link

fenugrec commented Jan 9, 2022

(continuing after I hijacked #277 )

I was getting errors such as

Exception in thread "Scan ports" java.lang.UnsatisfiedLinkError: Cannot load native libraries /tmp/jSerialComm/1641691463497-libjSerialComm.so or /tmp/jSerialComm/1641691463497-backup-libjSerialComm.so with expected architectures: Linux/x86_64 or Linux/x86
	at com.fazecast.jSerialComm.SerialPort.<clinit>(SerialPort.java:334)
	at dk.hkj.comm.SerialInterface.getSerialPorts(SerialInterface.java:276)
	at dk.hkj.main.InterfaceThreads$ScanPorts.run(InterfaceThreads.java:736)

For various reasons (and discussed a lot over the years, e.g. https://serverfault.com/questions/72356/how-useful-is-mounting-tmp-noexec etc) , some linux distros mount /tmp with noexec to prevent executing arbitrary files created in there.

I already knew my system was doing this (fstab has tmpfs /tmp tmpfs rw,size=4G,nr_inodes=40k,noexec,nodev,nosuid,mode=1700 ), but since the Java error didn't mention anything about permissions I didn't think about it much.

Finding a hint in unrelated issue #361, I added -Djava.io.tmpdir=/home/...tmpdir/ to start my application, and that eliminated the errors !

I have no proposed fix for this situation ( I don't java at all, just an end-user...) but would it be possible to get a more accurate diagnostic message in the case of that UnsatisfiedLinkError ? Not sure how far up the chain you can go to find the root cause... There's no global "errno", I imagine P )

Or perhaps there's an alternate method to accomplish whatever required copying those libs in the first place (also, why are they being set to Writeable ?

@hedgecrw
Copy link
Contributor

There's unfortunately no way to further determine what caused the UnsatisfiedLinkError as this exception gets thrown by the OS itself when it tries to load the native library. For a fix that should hopefully circumvent this issue in the future, I just released v2.8.1 which will first try load the library from the system tmp directory, but if that fails, it will then try to use the user's home directory to load the library. Hopefully this cuts down on some of the confusion moving forward.

@fenugrec
Copy link
Author

Perfect, thanks for looking at this.

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

No branches or pull requests

2 participants