en_US when you want en_GB date formatting) or for working around broken use of system() to launch background tasks.
- C 78.5%
- Makefile 16.7%
- Shell 4.8%
| debian | Version number. | |
| localefix | Set sonames. | |
| systemwrap | Set sonames. | |
| .gitignore | Add makefile rules for some simple test code; related adjustments. | |
| LICENCE | Initial commit. | |
| Makefile | Don't override user-set PREFIX. | |
| README.md | Add a warning about possible breakage through systemwrap. | |
| TODO.md | Add systemwrap; reorganise the source. | |
Fixer Wrappers
localefix : a wrapper for overriding environment variables, written to handle
LANG, LANGUAGE and those matching LC_*.
systemwrap : a wrapper for replacing system("... &") with the
corresponding fork/exec.
These are both intended for situations where the offending program isn't fixable for whatever reason.
Compilation
Requirements:
make(usually GNU make)- A GNU99-conformant C compiler (usually gcc or clang)
To compile, just run make.
If building on i386 or amd64, this will build two copies of each library, one
for each architecture. You're probably going to want both. You can
override this behaviour with make SINGLEARCH=1.
If you want to run tests, make run-tests.
Installation
Depends on where you're installing.
make install
make install DESTDIR=foo
The libraries will be installed in a directory named for the architecture
triplet, e.g. /usr/local/lib/x86_64-linux-gnu.
localefix
This is intended for recalcitrant programs which limit you to a "blessed" set of locales & languages which don't include yours, potentially causing problems with the likes of date formats..
It consists of a wrapper script and one or more shared libraries (which will
be loaded via LD_PRELOAD).
It alters the initial values of LANG, LANGUAGE and the other locale
variables (names beginning with LC_) if needed.
It intercepts setenv and putenv to override considered-bad values.
The replacement locale also enforces encoding (at present; this may change).
Rationale
Its reason for being is to work around Steam's game-specific configuration, particularly the fact that if you want English, you get American English instead.
Steam is a lot better with things like date formats these days, choosing
neutral (if not ideal) formats for them. However, things can break where it
offers game-specific choice of language: that's when it sets variables such
as LC_MESSAGES.
There's some variation here, but basically it boils down to some software offering languages which Steam doesn't but not fully handling it: there may be use of functions which get their locale data from an incompletely-configured environment (external configuration), leading to lookups being done for a language (or language variant) other than for which the software is configured via its own means (internally).
I always select English (UK) where the option is offered but I may get
mm/dd/yyyy or, worse, a mix of date formats. This is why localefix's
defaults are what they are: it's what I need, and (so far as I know) it's
the common case of wrong date format.
Usage
[ENVIRONMENT] localefix PROGRAM [ARGS...]_
Environment
_LC_BAD- target locale without encoding_LC_GOOD- replacement locale with optional encoding (use*as the encoding to retain the original)
Defaults
_LC_BAD=en_US
_LC_GOOD=en_GB.*
Matching
Matching of _LC_BAD ignores encodings: the default will match en_US,
en_US.UTF-8, en_US.ISO8859-15 etc.
_LC_BAD=en_US and _LC_GOOD=en_GB.* will keep whatever encoding was
used for en_US (including none), e.g. en_US.ISO8859-15 will give en_GB.ISO8859-15.
systemwrap
Simple wrapper for handling certain calls to system() for avoidance of
security bugs. It is only triggered when the command to be executed has at
least one parameter and is backgrounded: it will parse the command string
and use fork and exec instead.
⚠ This will break some correct use of system(), so only use it
where you definitely need it.
It contains an overly-simplified command line tokeniser which does the following:
- strips out redirection, piping,
&&and||; - stops at and traps backgrounding;
- handles string quoting and escapes (without failures);
- blindly copies everything else as plain text
with the following aims:
- handle improperly or incompletely escaped command lines;
- prevent backgrounding of the task (for error reporting).
Usage
[ENVIRONMENT] systemwrap PROGRAM [ARGS...]_