summaryrefslogtreecommitdiff
path: root/src/sysv-generator
AgeCommit message (Collapse)Author
2015-04-12sysv-generator: free memory allocated for service stubsZbigniew Jędrzejewski-Szmek
2015-04-12sysv-generator: always log on oomZbigniew Jędrzejewski-Szmek
This code appears to follow the following convention: - all errors are logged at point of origin - oom errors abort execution, non-oom errors are logged but execution continues. Make sure all ooms result in a log message, and remove warning which could not be reached. Downgrade non-fatal errors to warnings.
2015-04-12sysv-generator: split out two nested blocks into functionsZbigniew Jędrzejewski-Szmek
No functional change intended. Just splitting this out to make it easier to edit in the future.
2015-04-12sysv-generator: free LookupPaths also on errorZbigniew Jędrzejewski-Szmek
Followup for 7a03974a6f.
2015-04-11sysv-generator: fix mem leaksThomas Hindoe Paaboel Andersen
2015-03-14sysv-generator: initialize LookupPaths just onceZbigniew Jędrzejewski-Szmek
With debugging on, sysv-generator would print the full set of lookup paths for *every* sysv script. While at it, pass LookupPaths as a pointer in sysv-generator, and constify it everywhere.
2015-02-23remove unused includesThomas Hindoe Paaboel Andersen
This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
2015-02-19sysv-generator: fix wrong "Overwriting existing symlink" warningsMartin Pitt
Fix result testing of is_symlink() to ignore negative results, which happen if the file name does not exist at all. In this case we do not want a warning and unlink the non-existing link. https://bugs.debian.org/778700
2015-02-18everywhere: remove configurability of sysv runlevel to target mappingLennart Poettering
With this change runlevel 2, 3, 4 are mapped to multi-user.target for good, and 5 to graphical.target. This was already the previous mapping but is now no longer reconfigurable, but hard-coded into the core. This should generally simplify things, but also fix one bug: the sysv-generator previously generated symlinks to runlevel[2-5].target units, which possibly weren't picked up if these aliases were otherwise only referenced by the real names "multi-user.target" and "graphical.target". We keep compat aliases "runlevel[2345].target" arround for cases where this target name is explicitly requested.
2015-02-11sysv-generator: Skip init scripts for existing native servicesMartin Pitt
This avoids taking the SysV init script enablement state into account if we have native units. Otherwise systemctl disable on native unit would not be respected in the presence of an enabled SysV script. Also, there's no need to do all the parsing and creation of service files if we already have a native systemd unit for the processed SysV init script.
2015-01-28sysv-generator: no need to check for identical symlinks source and target twiceLennart Poettering
http://lists.freedesktop.org/archives/systemd-devel/2015-January/027594.html
2015-01-28sysv-generator: Re-fix .sh suffix handlingMartin Pitt
Commit 4e48855534 caused the .sh suffix to be stripped from the original "filename", which caused the generated units to call the wrong init.d script. Only use the .sh stripped file name for comparing with Provides:, not for generating the Exec*= lines. Spotted by sysv-generator-test.
2015-01-28sysv-generator: there's really no need to invoke fstatat() multiple times on ↵Lennart Poettering
the same sysv script It's sufficient to check once if something is a regular file, hence, let's do that.
2015-01-27sysv-generator: use is_symlink() utility call where appropriateLennart Poettering
2015-01-27sysv-generator: minor simplificationsLennart Poettering
2015-01-22sysv-generator: only allow regular files in enumerate_sysv()Cristian Rodríguez
Otherwise, if the directory contains other directories we fail at fopen in load_sysv() with EISDIR.
2015-01-21sysv-generator: Replace Provides: symlinks with real unitsMartin Pitt
Since commit b7e7184 the SysV generator creates symlinks for all "Provides:" in the LSB header. However, this is too greedy; there are cases where the creation of a unit .service file fails because of an already existing symlink with the same name: - Backup files such as /etc/init.d/foo.bak still have "Provides: foo", and thus get a foo.service -> foo.bak.service link. foo.bak would not be enabled in rcN.d/, but we (deliberately) create units for all executables in init.d/ so that a manual "systemctl start" works. If foo.bak is processed before, the symlink already exists. - init.d/bar has "Provides: foo", while there also is a real init.d/foo. The former would create a link foo.service -> bar.service, while the latter would fail to create the real foo.service. If we encounter an existing symlink, just remove it before writing a real unit. Note that two init.d scripts "foo" and "bar" which both provide the same name "common" already work. The first processed init script wins and creates the "common.service" symlink, and the second just fails to create the symlink again. Thus create an additional test case for this to ensure that it keeps working sensibly. https://bugs.debian.org/775404
2015-01-21sysv-generator: Handle .sh suffixes when translating Provides:Martin Pitt
When deciding whether the provided name equals the file name in sysv_translate_facility(), also consider them equal if the file name has a ".sh" suffix. This was uncovered by commit b7e7184 which then created a symlink "<name>.service" to itself for ".sh" suffixed init.d scripts. For additional robustness, refuse to create symlinks to itself in add_alias(). Add test case which reproduces the bug. https://bugs.debian.org/775889
2015-01-14sysv-generator: always use fstatat() if we canLennart Poettering
2015-01-14sysv-generator: fix memory leak on failureLennart Poettering
This fixes a memory leak introduced by 1ed0c19f81fd13cdf283c6def0168ce122a853a9
2015-01-07sysv-generator: initialize units before use to ensure correct orderingMichael Biebl
The original loop called fix_order() on each service immediately after loading it, but fix_order() would reference other units which were not loaded yet. This resulted in bogus and unnecessary orderings based on the static start priorities. Therefore call load_sysv() for every init script when traversing them in enumerate_sysv(). This ensures that all units are loaded when fix_order() is called. Bug-Debian: https://bugs.debian.org/771118
2015-01-07sysv-generator: handle Provides: for non-virtual facility namesMichael Biebl
The list of provided facility names as specified via Provides: in the LSB header was originally implemented by adding those facilities to the Names= property via unit_add_name(). In commit 95ed3294c632f5606327149f10cef1eb34422862 the internal SysV support was replaced by a generator and support for parsing the Names= option had been removed from the unit file parsing in v186. As a result, Provides: for non-virtual facility was dropped when introducing the sysv-generator. Since quite a few SysV init scripts still use that functionality (at least in distros like Debian which have a large body of SysV init scripts), add back support by making those facility names available via symlinks to the unit filename to ensure correct orderings between SysV init scripts which use those facility names. Bug-Debian: https://bugs.debian.org/774335
2014-12-19sysv-generator: properly add Makefile symlinkLennart Poettering
2014-12-19util: rename ignore_file() to hidden_file()Lennart Poettering
hidden_file() is a bit more precise, since dot files usually shouldn't be ignored, but certainly be considered hidden.
2014-11-30core: warn and ignore SysVStartPriority=Zbigniew Jędrzejewski-Szmek
Option was being parsed but not used for anything.
2014-11-28treewide: another round of simplificationsMichal Schmidt
Using the same scripts as in f647962d64e "treewide: yet more log_*_errno + return simplifications".
2014-11-28treewide: use log_*_errno whenever %m is in the format stringMichal Schmidt
If the format string contains %m, clearly errno must have a meaningful value, so we might as well use log_*_errno to have ERRNO= logged. Using: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\((".*%m.*")/log_\1_errno(errno, \2/' Plus some whitespace, linewrap, and indent adjustments.
2014-11-28core: convert log_unit_*() to log_unit_*_errno()Michal Schmidt
Using: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_unit_(debug|info|notice|warning|error|emergency)\(([^"]+), "(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_unit_\1_errno(\2, \5, "\3%m"\4);/'
2014-11-27sysv-generator: advertise the man pageZbigniew Jędrzejewski-Szmek
2014-11-27log: rearrange log function namingLennart Poettering
- Rename log_meta() → log_internal(), to follow naming scheme of most other log functions that are usually invoked through macros, but never directly. - Rename log_info_object() to log_object_info(), simply because the object should be before any other parameters, to follow OO-style programming style.
2014-10-01Remove repeated includesThomas Hindoe Paaboel Andersen
In pty.c there was both an include of our pty.h and the system installed pty.h. The latter contains only two functions openpty and forkpty. We use neither so I assume it was a typo and removed it. We still compile and pass all tests.
2014-09-17sysv-generator: don't check first if hashmap contains the service nameThomas Hindoe Paaboel Andersen
Just test if hashmap_get returns null. hashmap_contains does exactly same thing internally so this is slightly more efficient for the true case. Silences a coverity warning too. CID#1237648
2014-09-16sysv-generator: fix resource leakAndreas Henriksson
The "unit" string allocation is not freed on either error or success path. Found by coverity. Fixes: CID#1237755
2014-09-15hashmap: introduce hash_ops to make struct Hashmap smallerMichal Schmidt
It is redundant to store 'hash' and 'compare' function pointers in struct Hashmap separately. The functions always comprise a pair. Store a single pointer to struct hash_ops instead. systemd keeps hundreds of hashmaps, so this saves a little bit of memory.
2014-07-31Properly report invalid quoted stringsZbigniew Jędrzejewski-Szmek
$ systemd-analyze verify trailing-g.service [./trailing-g.service:2] Trailing garbage, ignoring. trailing-g.service lacks ExecStart setting. Refusing. Error: org.freedesktop.systemd1.LoadFailed: Unit trailing-g.service failed to load: Invalid argument. Failed to create trailing-g.service/start: Invalid argument
2014-07-31Reject invalid quoted stringsZbigniew Jędrzejewski-Szmek
String which ended in an unfinished quote were accepted, potentially with bad memory accesses. Reject anything which ends in a unfished quote, or contains non-whitespace characters right after the closing quote. _FOREACH_WORD now returns the invalid character in *state. But this return value is not checked anywhere yet. Also, make 'word' and 'state' variables const pointers, and rename 'w' to 'word' in various places. Things are easier to read if the same name is used consistently. mbiebl_> am I correct that something like this doesn't work mbiebl_> ExecStart=/usr/bin/encfs --extpass='/bin/systemd-ask-passwd "Unlock EncFS"' mbiebl_> systemd seems to strip of the quotes mbiebl_> systemctl status shows mbiebl_> ExecStart=/usr/bin/encfs --extpass='/bin/systemd-ask-password Unlock EncFS $RootDir $MountPoint mbiebl_> which is pretty weird
2014-07-30sysv: order initscripts which provide $network before network.targetLukas Nykryn
Due to recent changes where $network "maps" to network-online.target it is not guaranteed that initscript which provides networking will be terminated after network.target during shutdown which is against LSB.
2014-06-26sysv-generator: fix incorect ordering of WantsThomas Hindoe Paaboel Andersen
2014-06-24sysv-generator: rename PidFile to PIDFileThomas Hindoe Paaboel Andersen
Spotted by Alexey Shabalin
2014-06-13Fix spelling mistake, scirpt --> scriptColin Ian King
2014-06-07Move handling of sysv initscripts to a generatorThomas Hindoe Paaboel Andersen
Reuses logic from service.c and the rc-local generator. Note that this drops reading of chkconfig entirely. It also drops reading runlevels from the LSB headers. The runlevels were only used to check for runlevels outside of the normal 1-5 range and then add special dependencies and settings. Special runlevels were dropped in the past so it seemed to be unused code. The generator does not know about non-generated units with a value set with SysVStartPriority=. These are therefor not taken into account when converting start priority to before/after.