rrthomas / libpaper

Library and command-line tools for configuring and getting information on paper sizes
GNU Lesser General Public License v2.1
9 stars 11 forks source link

Avoid SIGSEGV in builds without HOME env var set #25

Closed bitstreamout closed 2 years ago

bitstreamout commented 2 years ago

In OBS build environments the HOME environment variable is not set to get a clean build. This leads with libpaper 1.2.2 to a SIGSEGV in paperinit(). Also it is not always ensured that paperspecs are there and had lead also to a SIGSEGV in systempapername()

Signed-off-by: Werner Fink werner@suse.de

rrthomas commented 2 years ago

Thanks for reporting the problem with HOME and suggesting a fix. I prefer not to use this fix, as it doesn't work on Windows. Instead, I have pushed a fix that simply gives up if HOME is not set. I have also added a test.

I will now look into the second problem you report as part of this PR!

rrthomas commented 2 years ago

I've pushed your fix for systempapername() as a separate commit; thanks again! Closing this PR as fixed.

bitstreamout commented 2 years ago

Thanks for reporting the problem with HOME and suggesting a fix. I prefer not to use this fix, as it doesn't work on Windows. Instead, I have pushed a fix that simply gives up if HOME is not set. I have also added a test.

A possible way would be to use cpp macros which are defined for getuid(3) as well as for getpwuid(3) as both are defined with POSIX.1-2001 :)

rrthomas commented 2 years ago

Thanks for reporting the problem with HOME and suggesting a fix. I prefer not to use this fix, as it doesn't work on Windows. Instead, I have pushed a fix that simply gives up if HOME is not set. I have also added a test.

A possible way would be to use cpp macros which are defined for getuid(3) as well as for getpwuid(3) as both are defined with POSIX.1-2001 :)

Thanks for the hint. If you're happy with the current functionality, I'm happy to leave it as-is; otherwise it would be good to know what the requirement to work without HOME (other than for building) is. If it were really useful, it might be worth either having platform-specific code, or adding a gnulib module for the missing APIs.