Hello,

I thought maybe some people here may be interested in a tool that I primarily developed for my studies where I have to use MATLAB and Simulink to program an Arduino board. Trying to access the Arduino serial port caused me trouble because of missing write access to /var/lock.

Of course it would have been easier to screw up my system security by blindly allowing access to a directory where my distributor decided that users should not write to. Instead of doing this, I decided to take this opportunity to learn something about LD_PRELOAD to redirect /var/lock access to a (newly created) directory below $XDG_RUNTIME_DIR and fine-tuned until MATLAB was happy and finally connected to my Arduino without actual write access to /var/lock.

What it does is overriding glibc functions that are commonly used for device locking mechanisms. If the accessed path is in a list of known lock file paths, then the path is rewritten to point to a directory below $XDG_RUNTIME_DIR before forwarding the call to the actual glibc function and the return value back to the caller.

For development, I used "rxtx" (Java library) and "liblockdev" (Debian device locking library) first. They are also included in my repo for testing after build. The MATLAB part (that I actually wanted to solve) was way more difficult as I don't know how device locking is implemented there. I hoped that making open source libraries work, first, may cover everything MATLAB uses, but it didn't. This required many hours of trial and error with adding random additional glibc function overrides until I finally catched the right ones and then removing unneeded overrides again as I didn't want to mess with unnecessarily many glibc functions. This also means that I probably didn't catch them all and there may still be issues there.

If you are interested in trying out my tool, you can find it here: https://github.com/M-Reimer/lockdev-redirect

Regards,

Manuel
_______________________________________________
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org

Reply via email to