SHA256
1
0
forked from pool/systemd
Dr. Werner Fink 2014-04-10 09:02:21 +00:00 committed by Git OBS Bridge
parent 5337977759
commit 3ab138fcd9
13 changed files with 319 additions and 189 deletions

View File

@ -0,0 +1,13 @@
Index: systemd-210/src/udev/udev-rules.c
===================================================================
--- systemd-210.orig/src/udev/udev-rules.c
+++ systemd-210/src/udev/udev-rules.c
@@ -2027,7 +2027,7 @@ int udev_rules_apply_to_event(struct ude
case TK_M_PROGRAM: {
char program[UTIL_PATH_SIZE];
char **envp;
- char result[UTIL_PATH_SIZE];
+ char result[UTIL_LINE_SIZE];
free(event->program_result);
event->program_result = NULL;

View File

@ -1,3 +1,26 @@
-------------------------------------------------------------------
Wed Apr 9 08:53:21 UTC 2014 - rmilasan@suse.com
- Increase result size for programs stdout (bnc#867840).
add: 1010-udev-increase-result-size-for-programs.patch
- Update udev-generate-peristent-rule.sh to the latest version.
- Clean-up spec file, re-arange patch to suit the setup, all udev
patches start with 1XXX-*.{patch,diff}.
- Rename: 0013-cdrom_id-use-the-old-MMC-fallback.patch to
1009-cdrom_id-use-the-old-MMC-fallback.patch
- Rename: 1009-make-xsltproc-use-correct-ROFF-links.patch to
0009-make-xsltproc-use-correct-ROFF-links.patch
- Rename: 1010-do-not-install-sulogin-unit-with-poweroff.patch to
0010-do-not-install-sulogin-unit-with-poweroff.patch
- Rename: 1014-journald-with-journaling-FS.patch to
0014-journald-with-journaling-FS.patch
- Rename: 1018-Make-LSB-Skripts-know-about-Required-and-Should.patch to
0018-Make-LSB-Skripts-know-about-Required-and-Should.patch
- Rename: 1019-make-completion-smart-to-be-able-to-redirect.patch to
0019-make-completion-smart-to-be-able-to-redirect.patch
- Rename: 1022-systemd-tmpfiles-ownerkeep.patch to
0022-systemd-tmpfiles-ownerkeep.patch
-------------------------------------------------------------------
Tue Apr 8 07:27:49 UTC 2014 - werner@suse.de

View File

@ -329,57 +329,54 @@ Patch169: 0007-sd-event-don-t-accidentally-turn-of-watchdog-timer-e.patch
Patch170: 0008-systemctl-kill-mode-is-long-long-gone-don-t-mention-.patch
# PATCH-FIX-USTREAM added at 2014/03/28
Patch171: 0009-ask-password-when-the-user-types-a-overly-long-passw.patch
# PATCH-FIX-USTREAM added at 2014/04/08
Patch172: 0001-journal-fix-export-of-messages-containing-newlines.patch
# PATCH-FIX-USTREAM added at 2014/04/08
Patch173: 0002-systemctl-update-NAME-to-PATTERN-in-help.patch
# PATCH-FIX-USTREAM added at 2014/04/08
Patch174: 0003-tty-ask-password-agent-return-negative-errno.patch
# PATCH-FIX-USTREAM added at 2014/04/08
Patch175: 0004-systemd-python-use-.hex-instead-of-.get_hex.patch
# PATCH-FIX-USTREAM added at 2014/04/08
Patch176: 0005-systemd-python-fix-failing-assert.patch
# PATCH-FIX-OPENSUSE 1009-make-xsltproc-use-correct-ROFF-links.patch -- Make ROFF links working again in manual pages (bnc#842844)
Patch1009: 1009-make-xsltproc-use-correct-ROFF-links.patch
# PATCH-FIX-OPENSUSE 1010-do-not-install-sulogin-unit-with-poweroff.patch -- Avoid installing console-shell.service (bnc#849071)
Patch1010: 1010-do-not-install-sulogin-unit-with-poweroff.patch
# PATCH-FIX-OPENSUSE 0009-make-xsltproc-use-correct-ROFF-links.patch -- Make ROFF links working again in manual pages (bnc#842844)
Patch172: 0009-make-xsltproc-use-correct-ROFF-links.patch
# PATCH-FIX-OPENSUSE 0010-do-not-install-sulogin-unit-with-poweroff.patch -- Avoid installing console-shell.service (bnc#849071)
Patch173: 0010-do-not-install-sulogin-unit-with-poweroff.patch
# PATCH-FIX-SUSE 0001-pam_systemd_do_override_XDG_RUNTIME_DIR_of_the_original_user.patch
Patch1012: 0001-pam_systemd_do_override_XDG_RUNTIME_DIR_of_the_original_user.patch
# PATCH-FIX-OPENSUSE 1014-journald-with-journaling-FS.patch
Patch1014: 1014-journald-with-journaling-FS.patch
# PATCH-FIX-SUSE 1018-Make-LSB-Skripts-know-about-Required-and-Should.patch
Patch1018: 1018-Make-LSB-Skripts-know-about-Required-and-Should.patch
# PATCH-FIX-SUSE 1019-make-completion-smart-to-be-able-to-redirect.patch
Patch1019: 1019-make-completion-smart-to-be-able-to-redirect.patch
Patch174: 0001-pam_systemd_do_override_XDG_RUNTIME_DIR_of_the_original_user.patch
# PATCH-FIX-OPENSUSE 0014-journald-with-journaling-FS.patch
Patch175: 0014-journald-with-journaling-FS.patch
# PATCH-FIX-SUSE 0018-Make-LSB-Skripts-know-about-Required-and-Should.patch
Patch176: 0018-Make-LSB-Skripts-know-about-Required-and-Should.patch
# PATCH-FIX-SUSE 0019-make-completion-smart-to-be-able-to-redirect.patch
Patch177: 0019-make-completion-smart-to-be-able-to-redirect.patch
# PATCH-FIX-SUSE 0001-add-network-device-after-NFS-mount-units.patch werner@suse.com
Patch1020: 0001-add-network-device-after-NFS-mount-units.patch
# PATCH-FIX-SUSE 1022-systemd-tmpfiles-ownerkeep.patch
Patch1022: 1022-systemd-tmpfiles-ownerkeep.patch
Patch178: 0001-add-network-device-after-NFS-mount-units.patch
# PATCH-FIX-SUSE 0022-systemd-tmpfiles-ownerkeep.patch
Patch179: 0022-systemd-tmpfiles-ownerkeep.patch
# PATCH-FIX-SUSE systemd-powerd-initctl-support.patch
Patch1023: systemd-powerd-initctl-support.patch
Patch180: systemd-powerd-initctl-support.patch
# PATCH-FIX-SUSE systemctl-set-default-target.patch
Patch1024: systemctl-set-default-target.patch
Patch181: systemctl-set-default-target.patch
# PATCH-FIX-SUSE prepare-suspend-to-disk.patch (fate #316824)
Patch1025: prepare-suspend-to-disk.patch
Patch182: prepare-suspend-to-disk.patch
# PATCH-FIX-SUSE boot-local-start.patch (bnc #869142)
Patch1026: boot-local-start.patch
Patch183: boot-local-start.patch
# PATCH-FIX-SUSE avoid random hangs on timeouts due lost cwd at terminating user manager
Patch1027: avoid-random-hangs-on-timeouts-due-lost-cwd.patch
Patch184: avoid-random-hangs-on-timeouts-due-lost-cwd.patch
# PATCH-FIX-SUSE systemd-install-compat_pkgconfig-always.patch
Patch1999: systemd-install-compat_pkgconfig-always.patch
Patch185: systemd-install-compat_pkgconfig-always.patch
# PATCH-FIX-OPENSUSE systemd-dbus-system-bus-address.patch always use /run/dbus not /var/run
Patch2000: systemd-dbus-system-bus-address.patch
Patch186: systemd-dbus-system-bus-address.patch
# PATCH-FIX-SUSE During linkage of systemd-cryptsetup let linker find libudev for libdevmapper
Patch2001: let-linker-find-libudev-for-libdevmapper.patch
# PATCH-FIX-SUSE Make sure that rpcbind socket as well as service is up with the target
Patch2002: portmap-wants-rpcbind-socket.patch
# udev patches
# PATCH-FIX-USTREAM added at 2014/03/03
Patch1034: 0013-cdrom_id-use-the-old-MMC-fallback.patch
Patch187: let-linker-find-libudev-for-libdevmapper.patch
# PATCH-FIX-USTREAM added at 2014/03/11
Patch1035: 0007-dbus-suppress-duplicate-and-misleading-messages.patch
Patch188: 0007-dbus-suppress-duplicate-and-misleading-messages.patch
# PATCH-FIX-SUSE Make sure that rpcbind socket as well as service is up with the target
Patch189: portmap-wants-rpcbind-socket.patch
# PATCH-FIX-USTREAM added at 2014/04/08
Patch190: 0001-journal-fix-export-of-messages-containing-newlines.patch
# PATCH-FIX-USTREAM added at 2014/04/08
Patch191: 0002-systemctl-update-NAME-to-PATTERN-in-help.patch
# PATCH-FIX-USTREAM added at 2014/04/08
Patch192: 0003-tty-ask-password-agent-return-negative-errno.patch
# PATCH-FIX-USTREAM added at 2014/04/08
Patch193: 0004-systemd-python-use-.hex-instead-of-.get_hex.patch
# PATCH-FIX-USTREAM added at 2014/04/08
Patch194: 0005-systemd-python-fix-failing-assert.patch
# udev patches (NOTE: all udev patches start with 1XXX-*.patch, do not use anything else)
# PATCH-FIX-OPENSUSE 1001-re-enable-by_path-links-for-ata-devices.patch
Patch1001: 1001-re-enable-by_path-links-for-ata-devices.patch
# PATCH-FIX-OPENSUSE 1002-rules-create-by-id-scsi-links-for-ATA-devices.patch
@ -394,6 +391,10 @@ Patch1006: 1006-udev-always-rename-network.patch
Patch1007: 1007-physical-hotplug-cpu-and-memory.patch
# PATCH-FIX-OPENSUSE 1008-add-msft-compability-rules.patch -- for code base <= 1310
Patch1008: 1008-add-msft-compability-rules.patch
# PATCH-FIX-USTREAM added at 2014/03/03
Patch1009: 1009-cdrom_id-use-the-old-MMC-fallback.patch
# PATCH-FIX-SUSE increase result size for programs (bnc#867840)
Patch1010: 1010-udev-increase-result-size-for-programs.patch
%description
Systemd is a system and service manager, compatible with SysV and LSB
@ -702,31 +703,31 @@ cp %{SOURCE7} m4/
%patch169 -p0
%patch170 -p0
%patch171 -p0
%patch172 -p0
%patch173 -p0
%patch174 -p0
%patch175 -p0
%patch176 -p0
%patch1009 -p1
%patch1010 -p1
%patch1012 -p1
%patch1014 -p1
%patch1018 -p1
%patch1019 -p1
%patch1020 -p1
%patch1022 -p1
%patch1023 -p1
%patch1024 -p1
%patch1025 -p1
%patch1026 -p1
%patch1027 -p1
%patch1999 -p1
%patch2000 -p1
%patch2001 -p1
%patch2002 -p1
%patch172 -p1
%patch173 -p1
%patch174 -p1
%patch175 -p1
%patch176 -p1
%patch177 -p1
%patch178 -p1
%patch179 -p1
%patch180 -p1
%patch181 -p1
%patch182 -p1
%patch183 -p1
%patch184 -p1
%patch185 -p1
%patch186 -p1
%patch187 -p1
%patch188 -p0
%patch189 -p1
%patch190 -p0
%patch191 -p0
%patch192 -p0
%patch193 -p0
%patch194 -p0
# udev patches
%patch1034 -p0
%patch1035 -p0
%patch1001 -p1
%patch1002 -p1
%patch1003 -p1
@ -736,6 +737,8 @@ cp %{SOURCE7} m4/
%if 0%{?suse_version} <= 1310
%patch1008 -p1
%endif
%patch1009 -p0
%patch1010 -p1
# ensure generate files are removed
rm -f units/emergency.service

View File

@ -1,3 +1,26 @@
-------------------------------------------------------------------
Wed Apr 9 08:53:21 UTC 2014 - rmilasan@suse.com
- Increase result size for programs stdout (bnc#867840).
add: 1010-udev-increase-result-size-for-programs.patch
- Update udev-generate-peristent-rule.sh to the latest version.
- Clean-up spec file, re-arange patch to suit the setup, all udev
patches start with 1XXX-*.{patch,diff}.
- Rename: 0013-cdrom_id-use-the-old-MMC-fallback.patch to
1009-cdrom_id-use-the-old-MMC-fallback.patch
- Rename: 1009-make-xsltproc-use-correct-ROFF-links.patch to
0009-make-xsltproc-use-correct-ROFF-links.patch
- Rename: 1010-do-not-install-sulogin-unit-with-poweroff.patch to
0010-do-not-install-sulogin-unit-with-poweroff.patch
- Rename: 1014-journald-with-journaling-FS.patch to
0014-journald-with-journaling-FS.patch
- Rename: 1018-Make-LSB-Skripts-know-about-Required-and-Should.patch to
0018-Make-LSB-Skripts-know-about-Required-and-Should.patch
- Rename: 1019-make-completion-smart-to-be-able-to-redirect.patch to
0019-make-completion-smart-to-be-able-to-redirect.patch
- Rename: 1022-systemd-tmpfiles-ownerkeep.patch to
0022-systemd-tmpfiles-ownerkeep.patch
-------------------------------------------------------------------
Tue Apr 8 07:27:49 UTC 2014 - werner@suse.de

View File

@ -324,57 +324,54 @@ Patch169: 0007-sd-event-don-t-accidentally-turn-of-watchdog-timer-e.patch
Patch170: 0008-systemctl-kill-mode-is-long-long-gone-don-t-mention-.patch
# PATCH-FIX-USTREAM added at 2014/03/28
Patch171: 0009-ask-password-when-the-user-types-a-overly-long-passw.patch
# PATCH-FIX-USTREAM added at 2014/04/08
Patch172: 0001-journal-fix-export-of-messages-containing-newlines.patch
# PATCH-FIX-USTREAM added at 2014/04/08
Patch173: 0002-systemctl-update-NAME-to-PATTERN-in-help.patch
# PATCH-FIX-USTREAM added at 2014/04/08
Patch174: 0003-tty-ask-password-agent-return-negative-errno.patch
# PATCH-FIX-USTREAM added at 2014/04/08
Patch175: 0004-systemd-python-use-.hex-instead-of-.get_hex.patch
# PATCH-FIX-USTREAM added at 2014/04/08
Patch176: 0005-systemd-python-fix-failing-assert.patch
# PATCH-FIX-OPENSUSE 1009-make-xsltproc-use-correct-ROFF-links.patch -- Make ROFF links working again in manual pages (bnc#842844)
Patch1009: 1009-make-xsltproc-use-correct-ROFF-links.patch
# PATCH-FIX-OPENSUSE 1010-do-not-install-sulogin-unit-with-poweroff.patch -- Avoid installing console-shell.service (bnc#849071)
Patch1010: 1010-do-not-install-sulogin-unit-with-poweroff.patch
# PATCH-FIX-OPENSUSE 0009-make-xsltproc-use-correct-ROFF-links.patch -- Make ROFF links working again in manual pages (bnc#842844)
Patch172: 0009-make-xsltproc-use-correct-ROFF-links.patch
# PATCH-FIX-OPENSUSE 0010-do-not-install-sulogin-unit-with-poweroff.patch -- Avoid installing console-shell.service (bnc#849071)
Patch173: 0010-do-not-install-sulogin-unit-with-poweroff.patch
# PATCH-FIX-SUSE 0001-pam_systemd_do_override_XDG_RUNTIME_DIR_of_the_original_user.patch
Patch1012: 0001-pam_systemd_do_override_XDG_RUNTIME_DIR_of_the_original_user.patch
# PATCH-FIX-OPENSUSE 1014-journald-with-journaling-FS.patch
Patch1014: 1014-journald-with-journaling-FS.patch
# PATCH-FIX-SUSE 1018-Make-LSB-Skripts-know-about-Required-and-Should.patch
Patch1018: 1018-Make-LSB-Skripts-know-about-Required-and-Should.patch
# PATCH-FIX-SUSE 1019-make-completion-smart-to-be-able-to-redirect.patch
Patch1019: 1019-make-completion-smart-to-be-able-to-redirect.patch
Patch174: 0001-pam_systemd_do_override_XDG_RUNTIME_DIR_of_the_original_user.patch
# PATCH-FIX-OPENSUSE 0014-journald-with-journaling-FS.patch
Patch175: 0014-journald-with-journaling-FS.patch
# PATCH-FIX-SUSE 0018-Make-LSB-Skripts-know-about-Required-and-Should.patch
Patch176: 0018-Make-LSB-Skripts-know-about-Required-and-Should.patch
# PATCH-FIX-SUSE 0019-make-completion-smart-to-be-able-to-redirect.patch
Patch177: 0019-make-completion-smart-to-be-able-to-redirect.patch
# PATCH-FIX-SUSE 0001-add-network-device-after-NFS-mount-units.patch werner@suse.com
Patch1020: 0001-add-network-device-after-NFS-mount-units.patch
# PATCH-FIX-SUSE 1022-systemd-tmpfiles-ownerkeep.patch
Patch1022: 1022-systemd-tmpfiles-ownerkeep.patch
Patch178: 0001-add-network-device-after-NFS-mount-units.patch
# PATCH-FIX-SUSE 0022-systemd-tmpfiles-ownerkeep.patch
Patch179: 0022-systemd-tmpfiles-ownerkeep.patch
# PATCH-FIX-SUSE systemd-powerd-initctl-support.patch
Patch1023: systemd-powerd-initctl-support.patch
Patch180: systemd-powerd-initctl-support.patch
# PATCH-FIX-SUSE systemctl-set-default-target.patch
Patch1024: systemctl-set-default-target.patch
Patch181: systemctl-set-default-target.patch
# PATCH-FIX-SUSE prepare-suspend-to-disk.patch (fate #316824)
Patch1025: prepare-suspend-to-disk.patch
Patch182: prepare-suspend-to-disk.patch
# PATCH-FIX-SUSE boot-local-start.patch (bnc #869142)
Patch1026: boot-local-start.patch
Patch183: boot-local-start.patch
# PATCH-FIX-SUSE avoid random hangs on timeouts due lost cwd at terminating user manager
Patch1027: avoid-random-hangs-on-timeouts-due-lost-cwd.patch
Patch184: avoid-random-hangs-on-timeouts-due-lost-cwd.patch
# PATCH-FIX-SUSE systemd-install-compat_pkgconfig-always.patch
Patch1999: systemd-install-compat_pkgconfig-always.patch
Patch185: systemd-install-compat_pkgconfig-always.patch
# PATCH-FIX-OPENSUSE systemd-dbus-system-bus-address.patch always use /run/dbus not /var/run
Patch2000: systemd-dbus-system-bus-address.patch
Patch186: systemd-dbus-system-bus-address.patch
# PATCH-FIX-SUSE During linkage of systemd-cryptsetup let linker find libudev for libdevmapper
Patch2001: let-linker-find-libudev-for-libdevmapper.patch
# PATCH-FIX-SUSE Make sure that rpcbind socket as well as service is up with the target
Patch2002: portmap-wants-rpcbind-socket.patch
# udev patches
# PATCH-FIX-USTREAM added at 2014/03/03
Patch1034: 0013-cdrom_id-use-the-old-MMC-fallback.patch
Patch187: let-linker-find-libudev-for-libdevmapper.patch
# PATCH-FIX-USTREAM added at 2014/03/11
Patch1035: 0007-dbus-suppress-duplicate-and-misleading-messages.patch
Patch188: 0007-dbus-suppress-duplicate-and-misleading-messages.patch
# PATCH-FIX-SUSE Make sure that rpcbind socket as well as service is up with the target
Patch189: portmap-wants-rpcbind-socket.patch
# PATCH-FIX-USTREAM added at 2014/04/08
Patch190: 0001-journal-fix-export-of-messages-containing-newlines.patch
# PATCH-FIX-USTREAM added at 2014/04/08
Patch191: 0002-systemctl-update-NAME-to-PATTERN-in-help.patch
# PATCH-FIX-USTREAM added at 2014/04/08
Patch192: 0003-tty-ask-password-agent-return-negative-errno.patch
# PATCH-FIX-USTREAM added at 2014/04/08
Patch193: 0004-systemd-python-use-.hex-instead-of-.get_hex.patch
# PATCH-FIX-USTREAM added at 2014/04/08
Patch194: 0005-systemd-python-fix-failing-assert.patch
# udev patches (NOTE: all udev patches start with 1XXX-*.patch, do not use anything else)
# PATCH-FIX-OPENSUSE 1001-re-enable-by_path-links-for-ata-devices.patch
Patch1001: 1001-re-enable-by_path-links-for-ata-devices.patch
# PATCH-FIX-OPENSUSE 1002-rules-create-by-id-scsi-links-for-ATA-devices.patch
@ -389,6 +386,10 @@ Patch1006: 1006-udev-always-rename-network.patch
Patch1007: 1007-physical-hotplug-cpu-and-memory.patch
# PATCH-FIX-OPENSUSE 1008-add-msft-compability-rules.patch -- for code base <= 1310
Patch1008: 1008-add-msft-compability-rules.patch
# PATCH-FIX-USTREAM added at 2014/03/03
Patch1009: 1009-cdrom_id-use-the-old-MMC-fallback.patch
# PATCH-FIX-SUSE increase result size for programs (bnc#867840)
Patch1010: 1010-udev-increase-result-size-for-programs.patch
%description
Systemd is a system and service manager, compatible with SysV and LSB
@ -697,31 +698,31 @@ cp %{SOURCE7} m4/
%patch169 -p0
%patch170 -p0
%patch171 -p0
%patch172 -p0
%patch173 -p0
%patch174 -p0
%patch175 -p0
%patch176 -p0
%patch1009 -p1
%patch1010 -p1
%patch1012 -p1
%patch1014 -p1
%patch1018 -p1
%patch1019 -p1
%patch1020 -p1
%patch1022 -p1
%patch1023 -p1
%patch1024 -p1
%patch1025 -p1
%patch1026 -p1
%patch1027 -p1
%patch1999 -p1
%patch2000 -p1
%patch2001 -p1
%patch2002 -p1
%patch172 -p1
%patch173 -p1
%patch174 -p1
%patch175 -p1
%patch176 -p1
%patch177 -p1
%patch178 -p1
%patch179 -p1
%patch180 -p1
%patch181 -p1
%patch182 -p1
%patch183 -p1
%patch184 -p1
%patch185 -p1
%patch186 -p1
%patch187 -p1
%patch188 -p0
%patch189 -p1
%patch190 -p0
%patch191 -p0
%patch192 -p0
%patch193 -p0
%patch194 -p0
# udev patches
%patch1034 -p0
%patch1035 -p0
%patch1001 -p1
%patch1002 -p1
%patch1003 -p1
@ -731,6 +732,8 @@ cp %{SOURCE7} m4/
%if 0%{?suse_version} <= 1310
%patch1008 -p1
%endif
%patch1009 -p0
%patch1010 -p1
# ensure generate files are removed
rm -f units/emergency.service

View File

@ -9,17 +9,19 @@
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This script run manually by user, will generate a persistent rule for
# a given network interface to rename it to new interface name.
#
prj=${0##*/}
_prj="$(basename $0 2>/dev/null)"
prj="${_prj%.*}"
ver="0.2"
log_info()
{
@ -29,28 +31,33 @@ log_info()
log_error()
{
local msg=$1
local msg="$1"
echo "$prj: $msg" >&2
}
usage()
{
set -f
cat << EOF
$prj: udev persistent rule generator
$prj: udev persistent rule generator script
Usage: $prj [OPTION] ...
-h show this help
-m generate the persistent rule based on interface MAC address
-p generate the persistent rule based on interface PCI slot
-v be verbose
-c <INTERFACE> current interface name (ex: "ip a s")
-n <INTERFACE> new interface name (ex: net0)
-o <FILE> where to write the new generate rule (default: /dev/stdout)
prefered location is /etc/udev/rules.d/70-persistent-net.rules
-h Show this help
-l List available interfaces
-m Generate the persistent rule based on interface MAC address
default option, if nothing is specified
-p Generate the persistent rule based on interface PCI slot
-v Be more verbose
-V Output the version number
-c [INTERFACE] Current interface name (ex: ip link)
only needed for retrieving information
-n [INTERFACE] New interface name (ex: net0)
-o [FILE] Where to write the new generate rule (default: /dev/stdout)
prefered location is /etc/udev/rules.d/70-persistent-net.rules
Example:
$prj -v -c enp0s4 -n lan0
or
$prj -m -c enp0s4 -n net0 -o /etc/udev/rules.d/70-persistent-net.rules
or
$prj -p -c wlp3s0 -n wlan0 -o /etc/udev/rules.d/50-mynet.rules
@ -60,22 +67,19 @@ EOF
display_note()
{
cat <<'EOF'
NOTE: Using the generate persistent rule might mean you will need to do extra
work to ensure that it will work accordingly. This mean, regenerating the
initramfs/initrd image and/or using 'net.ifnames=0' option at boot time.
In openSUSE/SUSE, the user will need to regenerate the initramfs/initrd image,
but usually there is no need for 'net.ifnames=0' option if the persistent rule
is available in initramfs/initrd image.
cat << EOF
NOTE: Using the generate persistent rule might mean you will need to do extra work to ensure
that it will work accordingly. This mean, regenerating the initramfs/initrd image and/or using
'net.ifnames=0' option at boot time.
In openSUSE/SUSE, the user will need to regenerate the initramfs/initrd image, but usually there
is no need for 'net.ifnames=0' option if the persistent rule is available in initramfs/initrd image.
EOF
}
get_pci()
{
local path=$1
local path="$1"
local pci=""
if [ -L "$path/device" ]; then
@ -87,7 +91,7 @@ get_pci()
get_pci_id()
{
local path=$1
local path="$1"
local pci_id=""
if [ -r "$path/device/uevent" ]; then
@ -99,7 +103,7 @@ get_pci_id()
get_macaddr()
{
local path=$1
local path="$1"
local macaddr=""
if [ -r "$path/address" ]; then
@ -110,7 +114,7 @@ get_macaddr()
get_type()
{
local path=$1
local path="$1"
local dev_type=""
if [ -r "$path/type" ]; then
@ -121,7 +125,7 @@ get_type()
get_dev_id()
{
local path=$1
local path="$1"
local dev_id=""
if [ -r "$path/dev_id" ]; then
@ -132,7 +136,7 @@ get_dev_id()
get_devtype()
{
local path=$1
local path="$1"
local devtype=""
if [ -r "$path/uevent" ]; then
local _devtype="$(cat $path/uevent|grep ^DEVTYPE 2>/dev/null)"
@ -143,7 +147,7 @@ get_devtype()
get_subsystem()
{
local path=$1
local path="$1"
local subsystem=""
if [ -L "$path/subsystem" ]; then
@ -153,9 +157,21 @@ get_subsystem()
echo $subsystem
}
get_parent_subsystem()
{
local path="$1"
local subsystem=""
if [ -L "$path/device/subsystem" ]; then
local subsystem_link="$(readlink -f $path/device/subsystem 2>/dev/null)"
subsystem="$(basename $subsystem_link 2>/dev/null)"
fi
echo $subsystem
}
get_driver()
{
local path=$1
local path="$1"
local driver=""
if [ -L "$path/device/driver" ]; then
@ -167,7 +183,7 @@ get_driver()
valid_mac()
{
local macaddr=$1
local macaddr="$1"
local valid_macaddr=""
if [ -n "$macaddr" ]; then
@ -178,9 +194,11 @@ valid_mac()
generate_comment()
{
local pci_id=$1
local driver=$2
local output=$3
local pci_id="$1"
local driver="$2"
local output="$3"
local device_type="$4"
local _type=""
if [ -z "$pci_id" ]; then
log_error "\$pci_id empty."
@ -192,20 +210,27 @@ generate_comment()
log_error "\$output empty."
exit 1
else
echo "# PCI device $pci_id ($driver) with official udev name $interface renamed to unsupported $new_interface" >> $output
if [ "$device_type" == "pci" ]; then
_type="PCI"
elif [ "$device_type" == "usb" ]; then
_type="USB"
else
_type="Unknown"
fi
echo "# $_type device $pci_id ($driver)" >> $output
fi
}
generate_rule()
{
local _subsystem=$1
local _mac=$2
local _pci=$3
local _dev_id=$4
local _dev_type=$5
local _kernel=$6
local _interface=$7
local output=$8
local _subsystem="$1"
local _mac="$2"
local _pci="$3"
local _dev_id="$4"
local _dev_type="$5"
local _kernel="$6"
local _interface="$7"
local output="$8"
if [ -z "$_subsystem" ]; then
log_error "\$_subsystem empty."
@ -238,26 +263,57 @@ ATTR{dev_id}==\"$_dev_id\", ATTR{type}==\"$_dev_type\", KERNEL==\"$_kernel\", NA
fi
}
list_adapters()
{
declare -a netdev
local count=0
local _netdev=""
local _dev=""
for _dev in $SYSPATH/*; do
if [ -L "$_dev/device" ]; then
_dev="$(basename $_dev 2>/dev/null)"
netdev[$count]="$_dev"
count=$((count + 1))
fi
done
echo "Found $count network interfaces:"
for _netdev in "${netdev[@]}"; do
_macaddr="$(get_macaddr $SYSPATH/$_netdev)"
_pcislot="$(get_pci $SYSPATH/$_netdev)"
echo "I: INTERFACE: $_netdev"
echo "I: MACADDR: $_macaddr"
echo "I: PCI: $_pcislot"
done
}
if [ $# -eq 0 ]; then
usage
log_error "missing option(s)."
exit 1
fi
SYSPATH="/sys/class/net"
use_mac=0
use_pci=0
use_verbose=0
while getopts "hmpvc:n:o:" opt; do
while getopts "hlmpvVc:n:o:" opt; do
case "$opt" in
h)
usage; exit 0;;
l)
list_adapters; exit 0;;
m)
use_mac=1 ;;
p)
use_pci=1 ;;
v)
use_verbose=1 ;;
V)
echo "$prj $ver"; exit 0;;
c)
ifcur="$OPTARG" ;;
n)
@ -269,14 +325,18 @@ while getopts "hmpvc:n:o:" opt; do
esac
done
if [[ "$use_mac" -eq 0 ]] && [[ "$use_pci" -eq 0 ]]; then
use_mac=1
fi
if [[ "$use_mac" -eq 1 ]] && [[ "$use_pci" -eq 1 ]]; then
log_error "generating a persistent rule can be done only using one of the option, -m or -p, not both."
exit 1
fi
outfile=$output
outfile="$output"
if [ -z "$output" ]; then
outfile=/dev/stdout
outfile="/dev/stdout"
else
dir="$(dirname $outfile 2>/dev/null)"
tmpfile="$dir/.tmp_file"
@ -293,7 +353,7 @@ else
fi
fi
interface=$ifcur
interface="$ifcur"
if [ -z "$interface" ]; then
log_error "current interface must be specified."
exit 1
@ -303,7 +363,7 @@ elif [ "$interface" == "lo" ]; then
fi
[ "$use_verbose" -eq 1 ] && echo "I: INTERFACE=$interface"
new_interface=$ifnew
new_interface="$ifnew"
if [ -z "$new_interface" ]; then
log_error "new interface must be specified."
exit 1
@ -313,7 +373,7 @@ elif [ "$new_interface" == "lo" ]; then
fi
[ "$use_verbose" -eq 1 ] && echo "I: INTERFACE_NEW=$new_interface"
path="/sys/class/net/$interface"
path="$SYSPATH/$interface"
if [ ! -d "$path" ]; then
log_error "devpath $path not a directory."
exit 1
@ -325,6 +385,13 @@ if [ -n "$devtype" ]; then
[ "$use_verbose" -eq 1 ] && echo "I: DEVTYPE=$devtype"
fi
parent_subsystem="$(get_parent_subsystem $path)"
if [ -z "$parent_subsystem" ]; then
log_error "unable to retrieve parent subsystem for interface $interface."
exit 1
fi
[ "$use_verbose" -eq 1 ] && echo "I: PARENT_SUBSYSTEM=$parent_subsystem"
subsystem="$(get_subsystem $path)"
if [ -z "$subsystem" ]; then
log_error "unable to retrieve subsystem for interface $interface."
@ -334,8 +401,7 @@ fi
pci_id="$(get_pci_id $path)"
if [ -z "$pci_id" ]; then
log_error "unable to retrieve PCI_ID for interface $interface."
exit 1
pci_id="0x:0x"
fi
[ "$use_verbose" -eq 1 ] && echo "I: PCI_ID=$pci_id"
@ -382,23 +448,22 @@ if [ -z "$dev_type" ]; then
fi
[ "$use_verbose" -eq 1 ] && echo "I: TYPE=$dev_type"
if [ "$devtype" == "wlan" ]; then
kernel="wlan*"
else
kernel="eth*"
kernel="eth*"
if [ -n "$devtype" ]; then
if [ "$devtype" == "wlan" ]; then
kernel="wlan*"
fi
fi
if [ -n "$output" ]; then
echo "Persistent rule saved in "$outfile""
echo
generate_comment "$pci_id" "$driver" "$output"
echo "Persistent rule written to "$outfile""
generate_comment "$pci_id" "$driver" "$outfile" "$parent_subsystem"
fi
set -f
if [ "$use_mac" -eq 1 ]; then
generate_rule "$subsystem" "$macaddr" "none" "$dev_id" "$dev_type" "$kernel" "$new_interface"
if [ -n "$output" ]; then
generate_rule "$subsystem" "$macaddr" "none" "$dev_id" "$dev_type" "$kernel" "$new_interface" "$output"
generate_rule "$subsystem" "$macaddr" "none" "$dev_id" "$dev_type" "$kernel" "$new_interface" "$outfile"
fi
elif [ "$use_pci" -eq 1 ]; then
generate_rule "$subsystem" "none" "$pci" "$dev_id" "$dev_type" "$kernel" "$new_interface"