summaryrefslogtreecommitdiff
path: root/src/sysv-generator
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: drop NULL sentinel from strjoinZbigniew Jędrzejewski-Szmek2016-10-231-5/+5
| | | | | | | | | | | | | This makes strjoin and strjoina more similar and avoids the useless final argument. spatch -I . -I ./src -I ./src/basic -I ./src/basic -I ./src/shared -I ./src/shared -I ./src/network -I ./src/locale -I ./src/login -I ./src/journal -I ./src/journal -I ./src/timedate -I ./src/timesync -I ./src/nspawn -I ./src/resolve -I ./src/resolve -I ./src/systemd -I ./src/core -I ./src/core -I ./src/libudev -I ./src/udev -I ./src/udev/net -I ./src/udev -I ./src/libsystemd/sd-bus -I ./src/libsystemd/sd-event -I ./src/libsystemd/sd-login -I ./src/libsystemd/sd-netlink -I ./src/libsystemd/sd-network -I ./src/libsystemd/sd-hwdb -I ./src/libsystemd/sd-device -I ./src/libsystemd/sd-id128 -I ./src/libsystemd-network --sp-file coccinelle/strjoin.cocci --in-place $(git ls-files src/*.c) git grep -e '\bstrjoin\b.*NULL' -l|xargs sed -i -r 's/strjoin\((.*), NULL\)/strjoin(\1)/' This might have missed a few cases (spatch has a really hard time dealing with _cleanup_ macros), but that's no big issue, they can always be fixed later.
* exit-status: kill is_clean_exit_lsb(), move logic to sysv-generatorLennart Poettering2016-10-101-0/+8
| | | | | | | | | | | | Let's get rid of is_clean_exit_lsb(), let's move the logic for the special handling of the two LSB exit codes into the sysv-generator by writing out appropriate SuccessExitStatus= lines if the LSB header exists. This is not only semantically more correct, bug also fixes a bug as the code in service.c that chose between is_clean_exit_lsb() and is_clean_exit() based this check on whether a native unit files was available for the unit. However, that check was bogus since a long time, since the SysV generator was introduced and native SysV script support was removed from PID 1, as in that case a unit file always existed.
* sysv-generator: better error reporting (#3977)Felipe Sateler2016-08-171-7/+10
| | | | | | | | | | | Currently in the journal you get messages without context like: systemd-sysv-generator[$pid]: Failed to build name: Invalid argument When parsing the init script, show the file and line number where the error was found. At the same time, add more context information if available. Thus turning the message into something like: systemd-sysv-generator[$pid]: [/etc/init.d/root-system-proofd:13] Could not build name for facility $network,: Invalid argument
* sysv-generator: remove more dead code (#3462)Lennart Poettering2016-06-081-16/+11
| | | | | | | The changes in 788d2b088b13a2444b9eb2ea82c0cc57d9f0980f weren't complete, only half the code that dealt with K links was removed. This is a follow-up patch that removes the rest too. No functional changes.
* sysv-generator: don't create Conflicts= deps towards shutdown.target anymoreLennart Poettering2016-05-301-55/+9
| | | | | This is redundant as SysV services get DefaultDependencides=yes anyway, and thus conflict with shutdown.target anyway. Hence, let's simplify our code here.
* util-lib: make localed's nonempty() generic, rename it to empty_to_null() ↵Lennart Poettering2016-05-301-9/+3
| | | | and make use of it everywhere
* tree-wide: use ERFKILL instead of ESHUTDOWN for "unit masked"Zbigniew Jędrzejewski-Szmek2016-04-161-1/+1
| | | | | | | | | If the error code ever leaks (we print the strerror error instead of providing our own), the message for ESHUTDOWN is "Cannot send after transport endpoint shutdown", which can be misleading. In particular it suggest that some mishandling of the dbus connection occured. Let's change that to ERFKILL which has the advantage that a) it sounds implausible as actual error, b) has the connotation of disabling something manually.
* systemctl: when we want to know whether there's a native unit file, don't ↵Lennart Poettering2016-04-121-2/+2
| | | | | | | choke on ELOOP ELOOP indicates that there's a symlink in /etc for a native unit file, and that's completely OK.
* sysv-generator: port to use new unit_file_exists() callLennart Poettering2016-04-121-3/+3
| | | | | | The code previously queries the state of a unit file, but was only interested in the existance of it, hence let's use unit_file_exists() instead, the same way the SysV compat code in systemctl does it.
* systemctl: don't confuse sysv code with generated unitsLennart Poettering2016-04-121-1/+1
| | | | | | | | | | The SysV compat code checks whether there's a native unit file before looking for a SysV init script. Since the newest rework generated units will show up in the unit path, and hence the checks ended up assuming that there always was a native unit file for each init script: the generated one. With this change the generated unit file directory is suppressed from the search path when this check is done, to avoid the confusion.
* install: add root directory to LookupPaths structureLennart Poettering2016-04-121-1/+1
| | | | | | | | | We use the root directory parameter while putting together the LookupPaths structure, hence let's also store it in the structure as-is. That way we can drop a parameter from half of the functions in install.c Also, let's move the validation of the root paths into lookup_paths_init() so that we can drop even more code from install.c
* core: remove ManagerRunningAs enumLennart Poettering2016-04-121-1/+1
| | | | | | | | | | | Previously, we had two enums ManagerRunningAs and UnitFileScope, that were mostly identical and converted from one to the other all the time. The latter had one more value UNIT_FILE_GLOBAL however. Let's simplify things, and remove ManagerRunningAs and replace it by UnitFileScope everywhere, thus making the translation unnecessary. Introduce two new macros MANAGER_IS_SYSTEM() and MANAGER_IS_USER() to simplify checking if we are running in one or the user context.
* core: rework generator dir logic, move the dirs into LookupPaths structureLennart Poettering2016-04-121-1/+1
| | | | | | | | | | A long time ago – when generators where first introduced – the directories for them were randomly created via mkdtemp(). This was changed later so that they use fixed name directories now. Let's make use of this, and add the genrator dirs to the LookupPaths structure and into the unit file search path maintained in it. This has the benefit that the generator dirs are now normal part of the search path for all tools, and thus are shown in "systemctl list-unit-files" too.
* sysv-generator: don't use LookupPath logic for determining SysV pathsLennart Poettering2016-04-121-3/+44
| | | | | | | The sysv-generator is the only user of the SysV paths these days, let's make it figure out the right paths on its own. (In a subsequent commit we can then drop the same logic from LookupPath).
* tree-wide: minor formatting inconsistency cleanupsVito Caputo2016-02-231-1/+1
|
* tree-wide: make more global variables staticLennart Poettering2016-02-131-1/+1
| | | | let's export as little as we can
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* sysv-generator: do not join dependencies on one line, split themLukas Nykryn2016-01-211-17/+8
| | | | | | | | If there is a lot of initscripts and dependencies between them we might end generating After= (and similar) lines which are longer then LINE_MAX and thus rejected by parser in systemd. Fixes #2099
* install: follow unit file symlinks in /usr, but not /etc when looking for ↵Lennart Poettering2015-11-121-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [Install] data Some distributions use alias unit files via symlinks in /usr to cover for legacy service names. With this change we'll allow "systemctl enable" on such aliases. Previously, our rule was that symlinks are user configuration that "systemctl enable" + "systemctl disable" creates and removes, while unit files is where the instructions to do so are store. As a result of the rule we'd never read install information through symlinks, since that would mix enablement state with installation instructions. Now, the new rule is that only symlinks inside of /etc are configuration. Unit files, and symlinks in /usr are now valid for installation instructions. This patch is quite a rework of the whole install logic, and makes the following addional changes: - Adds a complete test "test-instal-root" that tests the install logic pretty comprehensively. - Never uses canonicalize_file_name(), because that's incompatible with operation relative to a specific root directory. - unit_file_get_state() is reworked to return a proper error, and returns the state in a call-by-ref parameter. This cleans up confusion between the enum type and errno-like errors. - The new logic puts a limit on how long to follow unit file symlinks: it will do so only for 64 steps at max. - The InstallContext object's fields are renamed to will_process and has_processed (will_install and has_installed) since they are also used for deinstallation and all kinds of other operations. - The root directory is always verified before use. - install.c is reordered to place the exported functions together. - Stricter rules are followed when traversing symlinks: the unit suffix must say identical, and it's not allowed to link between regular units and templated units. - Various modernizations - The "invalid" unit file state has been renamed to "bad", in order to avoid confusion between UNIT_FILE_INVALID and _UNIT_FILE_STATE_INVALID. Given that the state should normally not be seen and is not documented this should not be a problematic change. The new name is now documented however. Fixes #1375, #1718, #1706
* sysv-generator: remove duplicate constThomas Hindoe Paaboel Andersen2015-11-021-1/+1
| | | | I assume this was a typo in c279613f861636c816f2f7df051b02c2f55a5134
* sysv-generator: modernizeLennart Poettering2015-10-311-228/+248
| | | | | | | | | | | | | | - Make sure we log each error at least once, and at most once - Replace FOREACH_WORD loops by extract_first_word() loops - Use FOREACH_DIRENT() for directory loops - Use free_and_strdup() where appropriate - Do not operate on half-loaded SysV files - Always properly free all memory
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split stat()/statfs()/stavfs() related calls into stat-util.[ch]Lennart Poettering2015-10-271-1/+2
|
* util-lib: split out hex/dec/oct encoding/decoding into its own fileLennart Poettering2015-10-271-0/+1
|
* util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering2015-10-251-0/+1
| | | | | There are more than enough to deserve their own .c file, hence move them over.
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-8/+9
| | | | | | | | | | | | | | string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
* util: add safe_closedir() similar to safe_fclose()Lennart Poettering2015-09-221-2/+1
|
* sysv-generator: follow symlinks in /etc/rc.d/init.dLukas Nykryn2015-09-111-1/+1
| | | | | | | | | Some java packages puts a symlink to init.d and its content is pointing to latest java installation (because you can have multiple javas on you machine). On rhel-based distributions you can use alternatives --initscript instread of symlink, but this is not usable for other distributions.
* sysv-generator: fix coding-styleDavid Herrmann2015-07-011-13/+11
| | | | | | | | | Fix weird coding-style: - proper white-space - no if (func() >= 0) bail-outs - fix braces - avoid 'r' for anything but errno - init _cleanup_ variables unconditionally, even if not needed
* sysv-generator: escape names when translating from sysv nameFelipe Sateler2015-06-291-10/+12
| | | | | | While the LSB suggests only [A-Za-z0-9], that doesn't prevent admins from doing the wrong thing. Lets not generate invalid names in that case.
* sysv-generator: detect invalid provided unit namesFelipe Sateler2015-06-291-2/+8
| | | | Do not assume that a non-service unit type is a target.
* core: rename SystemdRunningAs to ManagerRunningAsLennart Poettering2015-05-111-1/+1
| | | | | | It's primarily just a property of the Manager object after all, and we try to refer to PID 1 as "manager" instead of "systemd", hence let's to stick to this here too.
* core,network: major per-object logging reworkLennart Poettering2015-05-111-20/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes log_unit_info() (and friends) to take a real Unit* object insted of just a unit name as parameter. The call will now prefix all logged messages with the unit name, thus allowing the unit name to be dropped from the various passed romat strings, simplifying invocations drastically, and unifying log output across messages. Also, UNIT= vs. USER_UNIT= is now derived from the Manager object attached to the Unit object, instead of getpid(). This has the benefit of correcting the field for --test runs. Also contains a couple of other logging improvements: - Drops a couple of strerror() invocations in favour of using %m. - Not only .mount units now warn if a symlinks exist for the mount point already, .automount units do that too, now. - A few invocations of log_struct() that didn't actually pass any additional structured data have been replaced by simpler invocations of log_unit_info() and friends. - For structured data a new LOG_UNIT_MESSAGE() macro has been added, that works like LOG_MESSAGE() but prefixes the message with the unit name. Similar, there's now LOG_LINK_MESSAGE() and LOG_NETDEV_MESSAGE(). - For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(), LOG_NETDEV_INTERFACE() macros have been added that generate the necessary per object fields. The old log_unit_struct() call has been removed in favour of these new macros used in raw log_struct() invocations. In addition to removing one more function call this allows generated structured log messages that contain two object fields, as necessary for example for network interfaces that are joined into another network interface, and whose messages shall be indexed by both. - The LOG_ERRNO() macro has been removed, in favour of log_struct_errno(). The latter has the benefit of ensuring that %m in format strings is properly resolved to the specified error number. - A number of logging messages have been converted to use log_unit_info() instead of log_info() - The client code in sysv-generator no longer #includes core code from src/core/. - log_unit_full_errno() has been removed, log_unit_full() instead takes an errno now, too. - log_unit_info(), log_link_info(), log_netdev_info() and friends, now avoid double evaluation of their parameters
* core: rework unit name validation and manipulation logicLennart Poettering2015-05-051-3/+5
| | | | | | | | | | | | | | | A variety of changes: - Make sure all our calls distuingish OOM from other errors if OOM is not the only error possible. - Be much stricter when parsing escaped paths, do not accept trailing or leading escaped slashes. - Change unit validation to take a bit mask for allowing plain names, instance names or template names or an combination thereof. - Refuse manipulating invalid unit name
* sysv-generator: avoid freeing uninitialized variableThomas Hindoe Paaboel Andersen2015-04-261-1/+1
| | | | Would happen if lookup_paths_init returns an error.
* sysv-generator: free memory allocated for service stubsZbigniew Jędrzejewski-Szmek2015-04-121-21/+31
|
* sysv-generator: always log on oomZbigniew Jędrzejewski-Szmek2015-04-121-27/+17
| | | | | | | | | | 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.
* sysv-generator: split out two nested blocks into functionsZbigniew Jędrzejewski-Szmek2015-04-121-110/+110
| | | | | No functional change intended. Just splitting this out to make it easier to edit in the future.
* sysv-generator: free LookupPaths also on errorZbigniew Jędrzejewski-Szmek2015-04-121-3/+1
| | | | Followup for 7a03974a6f.
* sysv-generator: fix mem leaksThomas Hindoe Paaboel Andersen2015-04-111-1/+5
|
* sysv-generator: initialize LookupPaths just onceZbigniew Jędrzejewski-Szmek2015-03-141-7/+7
| | | | | | | | 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.
* remove unused includesThomas Hindoe Paaboel Andersen2015-02-231-4/+0
| | | | | | 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.
* sysv-generator: fix wrong "Overwriting existing symlink" warningsMartin Pitt2015-02-191-1/+1
| | | | | | | | 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
* everywhere: remove configurability of sysv runlevel to target mappingLennart Poettering2015-02-181-5/+5
| | | | | | | | | | | | | | | 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.
* sysv-generator: Skip init scripts for existing native servicesMartin Pitt2015-02-111-1/+7
| | | | | | | | | 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.
* sysv-generator: no need to check for identical symlinks source and target twiceLennart Poettering2015-01-281-8/+4
| | | | http://lists.freedesktop.org/archives/systemd-devel/2015-January/027594.html
* sysv-generator: Re-fix .sh suffix handlingMartin Pitt2015-01-281-5/+3
| | | | | | | | | 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.
* sysv-generator: there's really no need to invoke fstatat() multiple times on ↵Lennart Poettering2015-01-281-8/+6
| | | | | | | the same sysv script It's sufficient to check once if something is a regular file, hence, let's do that.
* sysv-generator: use is_symlink() utility call where appropriateLennart Poettering2015-01-271-3/+2
|
* sysv-generator: minor simplificationsLennart Poettering2015-01-271-11/+9
|