SHA256
1
0
forked from pool/systemd
Dr. Werner Fink 2014-10-15 12:26:07 +00:00 committed by Git OBS Bridge
parent f1db6f5530
commit 6e35d5d56c
8 changed files with 315 additions and 0 deletions

View File

@ -0,0 +1,95 @@
Based on f29c77bc0179b0fa57407dbe30b495be9f5ad2e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Tue, 14 Oct 2014 20:20:07 -0400
Subject: [PATCH] shell-completion: fix completion of inactive units
Units which not loaded were not proposed properly. OTOH, we should
filter units from get-unit-files by their state if they are currently
loaded. Bring zsh completions in line with bash completion, the same
logic should be used in both implementations.
https://bugzilla.redhat.com/show_bug.cgi?id=1024379
https://bugzilla.redhat.com/show_bug.cgi?id=790768
https://bugs.freedesktop.org/show_bug.cgi?id=84720
---
shell-completion/bash/systemctl | 17 +++++++++--------
shell-completion/zsh/_systemctl | 16 +++++++++-------
2 files changed, 18 insertions(+), 15 deletions(-)
--- shell-completion/bash/systemctl
+++ shell-completion/bash/systemctl
@@ -55,10 +55,14 @@ __get_all_units () { { __systemctl $1 list-unit-files; __systemctl $1 list-
| { while read -r a b; do echo " $a"; done; }; }
__get_active_units () { __systemctl $1 list-units \
| { while read -r a b; do echo " $a"; done; }; }
-__get_startable_units () { {
- __systemctl $1 list-units --all -t service,timer,socket,mount,automount,path,snapshot,swap
- __systemctl $1 list-unit-files -t service,timer,socket,mount,automount,path,snapshot,swap; } \
- | { while read -r a b c d; do [[ $c == "inactive" || $c == "failed" ]] && echo " $a"; done; }; }
+__get_startable_units () {
+ # find inactive or failed units, filter out masked and not-found
+ __systemctl $1 list-units --state inactive,failed -- $( __get_all_units ) | \
+ { while read -r a b c d; do [[ $b == "loaded" ]] && echo " $a"; done; }; }
+__get_restartable_units () {
+ # find !masked, filter out masked and not-found
+ __systemctl $1 list-units --state active,inactive,failed -- $( __get_all_units ) | \
+ { while read -r a b c d; do [[ $b == "loaded" ]] && echo " $a"; done; }; }
__get_failed_units () { __systemctl $1 list-units \
| { while read -r a b c d; do [[ $c == "failed" ]] && echo " $a"; done; }; }
__get_enabled_units () { __systemctl $1 list-unit-files \
@@ -180,10 +184,7 @@ _systemctl () {
elif __contains_word "$verb" ${VERBS[RESTARTABLE_UNITS]}; then
comps=$( __filter_units_by_property $mode CanStart yes \
- $( __get_all_units $mode \
- | while read -r line; do \
- [[ "$line" =~ @\.|\.(device|snapshot|socket|timer)$ ]] || echo " $line"; \
- done ))
+ $( __get_restartable_units $mode))
compopt -o filenames
elif __contains_word "$verb" ${VERBS[STOPPABLE_UNITS]}; then
--- shell-completion/zsh/_systemctl
+++ shell-completion/zsh/_systemctl
@@ -138,8 +138,11 @@ _filter_units_by_property() {
done
}
+_systemctl_all_units() { { __systemctl list-unit-files; __systemctl list-units --all; } | { while read -r a b; do echo -E - " $a"; done; } }
+
_systemctl_active_units() {_sys_active_units=( $(__systemctl list-units | { while read -r a b; do echo -E - " $a"; done; }) )}
-_systemctl_inactive_units(){_sys_inactive_units=($(__systemctl list-units --all | { while read -r a b c d; do [[ $c == "inactive" || $c == "failed" ]] && echo -E - " $a"; done; }) )}
+_systemctl_startable_units(){_sys_startable_units=($(__systemctl list-units --state inactive,failed -- $(_systemctl_all_units) | { while read -r a b c d; do [[ $b == "loaded" ]] && echo -E - " $a"; done; }) )}
+_systemctl_restartable_units(){_sys_restartable_units=($(__systemctl list-units --state inactive,failed,active -- $(_systemctl_all_units) | { while read -r a b c d; do [[ $b == "loaded" ]] && echo -E - " $a"; done; }) )}
_systemctl_failed_units() {_sys_failed_units=( $(__systemctl list-units --failed | { while read -r a b; do echo -E - " $a"; done; }) )}
_systemctl_enabled_units() {_sys_enabled_units=( $(__systemctl list-unit-files | { while read -r a b; do [[ $b == "enabled" ]] && echo -E - " $a"; done; }) )}
_systemctl_disabled_units(){_sys_disabled_units=($(__systemctl list-unit-files | { while read -r a b; do [[ $b == "disabled" ]] && echo -E - " $a"; done; }) )}
@@ -181,8 +184,9 @@ done
# Completion functions for STARTABLE_UNITS
(( $+functions[_systemctl_start] )) || _systemctl_start()
{
- _systemctl_inactive_units
- compadd "$@" -a - _sys_inactive_units
+ _systemctl_startable_units
+ compadd "$@" - $( _filter_units_by_property CanStart yes \
+ ${_sys_startable_units[*]} )
}
# Completion functions for STOPPABLE_UNITS
@@ -217,11 +221,9 @@ done
for fun in restart reload-or-restart ; do
(( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
{
- _systemctl_all_units
+ _systemctl_restartable_units
compadd "$@" - $( _filter_units_by_property CanStart yes \
- ${_sys_all_units[*]} | while read -r line; do \
- [[ "$line" =~ \.device$ ]] || echo -E - " $line"; \
- done )
+ ${_sys_restartable_units[*]} )
}
done
--
1.7.9.2

View File

@ -0,0 +1,111 @@
Based on e9a19bd882ff8a2c8aef5c63b39525ea231e5fb9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Tue, 14 Oct 2014 21:10:02 -0400
Subject: [PATCH] shell-completion: propose templates for
disable/[re]enable/[re]start
Templates can be [re]enabled, on their own if the have DefaultInstance set,
and with an instance suffix in all cases. Propose just the template name
ending in @, to underline the instance suffix may have to be appended.
Likewise for start/restart.
This means that sometimes superflous units that one will not really
want to operate on will be proposed, but this seems better than
proposing a very incomplete set of names.
https://bugs.freedesktop.org/show_bug.cgi?id=66912
---
shell-completion/bash/systemctl | 15 +++++++++++----
shell-completion/zsh/_systemctl | 20 +++++++++++++-------
2 files changed, 24 insertions(+), 11 deletions(-)
--- shell-completion/bash/systemctl
+++ shell-completion/bash/systemctl
@@ -53,6 +53,9 @@ __filter_units_by_property () {
__get_all_units () { { __systemctl $1 list-unit-files; __systemctl $1 list-units --all; } \
| { while read -r a b; do echo " $a"; done; }; }
+__get_template_names () { __systemctl $1 list-unit-files \
+ | { while read -r a b; do [[ $a =~ @\. ]] && echo " ${a%%@.*}@"; done; }; }
+
__get_active_units () { __systemctl $1 list-units \
| { while read -r a b; do echo " $a"; done; }; }
__get_startable_units () {
@@ -169,22 +172,26 @@ _systemctl () {
compopt -o filenames
elif __contains_word "$verb" ${VERBS[DISABLED_UNITS]}; then
- comps=$( __get_disabled_units $mode )
+ comps=$( __get_disabled_units $mode;
+ __get_template_names $mode)
compopt -o filenames
elif __contains_word "$verb" ${VERBS[REENABLABLE_UNITS]}; then
comps=$( __get_disabled_units $mode;
- __get_enabled_units $mode )
+ __get_enabled_units $mode;
+ __get_template_names $mode)
compopt -o filenames
elif __contains_word "$verb" ${VERBS[STARTABLE_UNITS]}; then
comps=$( __filter_units_by_property $mode CanStart yes \
- $( __get_startable_units $mode))
+ $( __get_startable_units $mode);
+ __get_template_names $mode)
compopt -o filenames
elif __contains_word "$verb" ${VERBS[RESTARTABLE_UNITS]}; then
comps=$( __filter_units_by_property $mode CanStart yes \
- $( __get_restartable_units $mode))
+ $( __get_restartable_units $mode); \
+ __get_template_names $mode)
compopt -o filenames
elif __contains_word "$verb" ${VERBS[STOPPABLE_UNITS]}; then
--- shell-completion/zsh/_systemctl
+++ shell-completion/zsh/_systemctl
@@ -139,6 +139,8 @@ _filter_units_by_property() {
}
_systemctl_all_units() { { __systemctl list-unit-files; __systemctl list-units --all; } | { while read -r a b; do echo -E - " $a"; done; } }
+_systemctl_get_template_names() { __systemctl list-unit-files | { while read -r a b; do [[ $a =~ @\. ]] && echo -E - " ${a%%@.*}@"; done; } }
+
_systemctl_active_units() {_sys_active_units=( $(__systemctl list-units | { while read -r a b; do echo -E - " $a"; done; }) )}
_systemctl_startable_units(){_sys_startable_units=($(__systemctl list-units --state inactive,failed -- $(_systemctl_all_units) | { while read -r a b c d; do [[ $b == "loaded" ]] && echo -E - " $a"; done; }) )}
@@ -158,20 +160,24 @@ for fun in is-active is-failed is-enabled status show cat mask preset help list-
done
# Completion functions for ENABLED_UNITS
-for fun in disable reenable ; do
- (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
- {
+(( $+functions[_systemctl_disable] )) || _systemctl_disable()
+{
+ _systemctl_enabled_units
+ compadd "$@" -a - _sys_enabled_units
+}
+
+(( $+functions[_systemctl_reenable] )) || _systemctl_reenable()
+{
_systemctl_enabled_units
_systemctl_disabled_units
- compadd "$@" -a - _sys_enabled_units _sys_disabled_units
- }
-done
+ compadd "$@" -a - _sys_enabled_units _sys_disabled_units $(_systemctl_get_template_names)
+}
# Completion functions for DISABLED_UNITS
(( $+functions[_systemctl_enable] )) || _systemctl_enable()
{
_systemctl_disabled_units
- compadd "$@" -a - _sys_disabled_units
+ compadd "$@" -a - _sys_disabled_units $(_systemctl_get_template_names)
}
# Completion functions for FAILED_UNITS
--
1.7.9.2

View File

@ -0,0 +1,29 @@
From 3e883473a0f36c220fc45ecf61d6878c9ac308b4 Mon Sep 17 00:00:00 2001
From: Lukas Nykryn <lnykryn@redhat.com>
Date: Wed, 15 Oct 2014 09:28:31 +0200
Subject: [PATCH] man: we don't have 'Wanted' dependency
---
man/systemd.unit.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git man/systemd.unit.xml man/systemd.unit.xml
index e9395ff..88c9d7f 100644
--- man/systemd.unit.xml
+++ man/systemd.unit.xml
@@ -181,10 +181,10 @@
<filename>foo.service.wants/</filename> may exist. All
unit files symlinked from such a directory are
implicitly added as dependencies of type
- <varname>Wanted=</varname> to the unit. This is useful
+ <varname>Wants=</varname> to the unit. This is useful
to hook units into the start-up of other units,
without having to modify their unit files. For details
- about the semantics of <varname>Wanted=</varname>, see
+ about the semantics of <varname>Wants=</varname>, see
below. The preferred way to create symlinks in the
<filename>.wants/</filename> directory of a unit file
is with the <command>enable</command> command of the
--
1.7.9.2

View File

@ -0,0 +1,38 @@
From 5e78424f4a27c07be50e246308035c877f204038 Mon Sep 17 00:00:00 2001
From: Michal Sekletar <msekleta@redhat.com>
Date: Mon, 13 Oct 2014 15:25:09 +0200
Subject: [PATCH] selinux: fix potential double free crash in child process
Before returning from function we should reset ret to NULL, thus cleanup
function is nop.
Also context_str() returns pointer to a string containing context but not a
copy, hence we must make copy it explicitly.
---
src/shared/label.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git src/shared/label.c src/shared/label.c
index b6af38d..69d4616 100644
--- src/shared/label.c
+++ src/shared/label.c
@@ -334,7 +334,7 @@ int label_get_child_mls_label(int socket_fd, const char *exe, char **label) {
}
freecon(mycon);
- mycon = context_str(bcon);
+ mycon = strdup(context_str(bcon));
if (!mycon) {
r = -errno;
goto out;
@@ -348,6 +348,7 @@ int label_get_child_mls_label(int socket_fd, const char *exe, char **label) {
}
*label = ret;
+ ret = NULL;
r = 0;
out:
--
1.7.9.2

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Wed Oct 15 12:03:36 UTC 2014 - werner@suse.de
- Add upstream patches
0001-shell-completion-fix-completion-of-inactive-units.patch
0002-shell-completion-propose-templates-for-disable-re-en.patch
0003-man-we-don-t-have-Wanted-dependency.patch
0004-selinux-fix-potential-double-free-crash-in-child-pro.patch
-------------------------------------------------------------------
Wed Oct 15 08:48:36 UTC 2014 - werner@suse.de

View File

@ -950,6 +950,14 @@ Patch459: 0005-util-avoid-double-close-of-fd.patch
Patch460: 0001-systemctl-when-mangle-unit-names-for-the-isolate-suf.patch
# PATCH-FIX-UPSTREAM added at 2014/10/14
Patch461: 0001-tmpfiles-compare-return-against-correct-errno.patch
# PATCH-FIX-UPSTREAM added at 2014/10/15
Patch462: 0001-shell-completion-fix-completion-of-inactive-units.patch
# PATCH-FIX-UPSTREAM added at 2014/10/15
Patch463: 0002-shell-completion-propose-templates-for-disable-re-en.patch
# PATCH-FIX-UPSTREAM added at 2014/10/15
Patch464: 0003-man-we-don-t-have-Wanted-dependency.patch
# PATCH-FIX-UPSTREAM added at 2014/10/15
Patch465: 0004-selinux-fix-potential-double-free-crash-in-child-pro.patch
# UDEV PATCHES
# ============
@ -1755,6 +1763,10 @@ cp %{SOURCE7} m4/
%patch459 -p0
%patch460 -p0
%patch461 -p0
%patch462 -p0
%patch463 -p0
%patch464 -p0
%patch465 -p0
# udev patches
%patch1001 -p1

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Wed Oct 15 12:03:36 UTC 2014 - werner@suse.de
- Add upstream patches
0001-shell-completion-fix-completion-of-inactive-units.patch
0002-shell-completion-propose-templates-for-disable-re-en.patch
0003-man-we-don-t-have-Wanted-dependency.patch
0004-selinux-fix-potential-double-free-crash-in-child-pro.patch
-------------------------------------------------------------------
Wed Oct 15 08:48:36 UTC 2014 - werner@suse.de

View File

@ -945,6 +945,14 @@ Patch459: 0005-util-avoid-double-close-of-fd.patch
Patch460: 0001-systemctl-when-mangle-unit-names-for-the-isolate-suf.patch
# PATCH-FIX-UPSTREAM added at 2014/10/14
Patch461: 0001-tmpfiles-compare-return-against-correct-errno.patch
# PATCH-FIX-UPSTREAM added at 2014/10/15
Patch462: 0001-shell-completion-fix-completion-of-inactive-units.patch
# PATCH-FIX-UPSTREAM added at 2014/10/15
Patch463: 0002-shell-completion-propose-templates-for-disable-re-en.patch
# PATCH-FIX-UPSTREAM added at 2014/10/15
Patch464: 0003-man-we-don-t-have-Wanted-dependency.patch
# PATCH-FIX-UPSTREAM added at 2014/10/15
Patch465: 0004-selinux-fix-potential-double-free-crash-in-child-pro.patch
# UDEV PATCHES
# ============
@ -1750,6 +1758,10 @@ cp %{SOURCE7} m4/
%patch459 -p0
%patch460 -p0
%patch461 -p0
%patch462 -p0
%patch463 -p0
%patch464 -p0
%patch465 -p0
# udev patches
%patch1001 -p1