From 35125edb9a009fbf5147edb1391b0c7409632a6f Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Wed, 17 Jun 2015 01:43:11 +0000 Subject: [PATCH 01/80] - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild --- beep.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beep.spec b/beep.spec index 46e9fbb..b7ed59b 100644 --- a/beep.spec +++ b/beep.spec @@ -8,7 +8,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.3 -Release: 9%{?dist} +Release: 10%{?dist} Group: Applications/System License: GPLv2+ @@ -101,6 +101,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Wed Jun 17 2015 Fedora Release Engineering - 1.3-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + * Fri Aug 15 2014 Fedora Release Engineering - 1.3-9 - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild From b469a4e44f0025d4aa6b0af184efcec7faaa93cf Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 18 Jan 2016 00:17:53 +0100 Subject: [PATCH 02/80] Do not replace config file modprobe.d/beep.conf (#1087616) --- beep.spec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/beep.spec b/beep.spec index 46e9fbb..46194c6 100644 --- a/beep.spec +++ b/beep.spec @@ -8,7 +8,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.3 -Release: 9%{?dist} +Release: 11%{?dist} Group: Applications/System License: GPLv2+ @@ -96,11 +96,14 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man1/beep.1.gz %if %{ship_modprobe_config} %doc README.fedora -%attr(0644,root,root) %{_sysconfdir}/modprobe.d/beep.conf +%config(noreplace) %attr(0644,root,root) %{_sysconfdir}/modprobe.d/beep.conf %endif %changelog +* Sun Jan 17 2016 Hans Ulrich Niedermann - 1.3-11 +- Do not replace config file modprobe.d/beep.conf (#1087616) + * Fri Aug 15 2014 Fedora Release Engineering - 1.3-9 - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild From 0e50fe895de22d6f8d4de3066c76493f0c98b6d4 Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Wed, 3 Feb 2016 16:57:38 +0000 Subject: [PATCH 03/80] - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild --- beep.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beep.spec b/beep.spec index 844ad44..ae49f9c 100644 --- a/beep.spec +++ b/beep.spec @@ -8,7 +8,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.3 -Release: 11%{?dist} +Release: 12%{?dist} Group: Applications/System License: GPLv2+ @@ -101,6 +101,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Wed Feb 03 2016 Fedora Release Engineering - 1.3-12 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + * Sun Jan 17 2016 Hans Ulrich Niedermann - 1.3-11 - Do not replace config file modprobe.d/beep.conf (#1087616) From 450ec29ae76561adb81cda045492a69d2d6016d0 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 17 May 2016 02:09:45 +0200 Subject: [PATCH 04/80] remove useless %%defattr for clarity --- beep.spec | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/beep.spec b/beep.spec index ae49f9c..56c8c58 100644 --- a/beep.spec +++ b/beep.spec @@ -8,7 +8,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.3 -Release: 12%{?dist} +Release: 13%{?dist} Group: Applications/System License: GPLv2+ @@ -90,7 +90,6 @@ rm -rf $RPM_BUILD_ROOT %files -%defattr(-,root,root,-) %doc CHANGELOG COPYING CREDITS README %attr(0755,root,root) %{_bindir}/beep %{_mandir}/man1/beep.1.gz @@ -101,6 +100,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Mon May 16 2016 Hans Ulrich Niedermann - 1.3-13 +- remove useless %%defattr for clarity + * Wed Feb 03 2016 Fedora Release Engineering - 1.3-12 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild From 67e6aabedc6e6eef0495f7ec6fab01bec903f5dc Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 31 May 2016 17:45:50 +0200 Subject: [PATCH 05/80] Document how non-root users can run beep via sudo (#1133231) --- beep-README.fedora | 112 ++++++++++++++++++++++++++++++++++++++------- beep.spec | 10 +++- beep.sudoers | 5 ++ 3 files changed, 109 insertions(+), 18 deletions(-) create mode 100644 beep.sudoers diff --git a/beep-README.fedora b/beep-README.fedora index 9572598..31604c5 100644 --- a/beep-README.fedora +++ b/beep-README.fedora @@ -1,22 +1,100 @@ -On systems with Fedora 12 or later, the kernel does not by default -alias the system device to the pcspkr.ko kernel driver any more. This -means that the pcspkr.ko driver is not loaded by default any more on -system startup. +Content +======= -You can check whether pcspkr.ko is loaded by running "lsmod | grep -pcspkr". +1. Load the pkspkr.ko Kernel Driver Module (required) +2. Set Up `beep` For Use As non-root Users Via `sudo` (optional) +3. Example Usage -On these systems, the beep package ships a config file -/etc/modprobe.d/beep.conf with a configuration line that reintroduces -the default loading of pcspkr.ko. Due to possible side effects, you -will need to manually uncomment that line in the beep.conf file, though. -You do not need to reboot your system in order to get pcspkr.ko -loaded, though. Running "modprobe pcspkr" should do the job without a -reboot. +1. Load the pkspkr.ko Kernel Driver Module (required) +----------------------------------------------------- -Caution: There appear to be some issues with access to the -/dev/console device which beep uses, possibly related to -ConsoleKit. This means that sometimes, just having pcspkr.ko loaded is -not enough for beep to actually beep. This issue is being +To have a working PC speaker beep on Fedora >= 12, you must load the +kernel driver module `pcspkr.ko` first. + +You can do this manually as root as follows: + + # modprobe pcspkr + +If you want the system to automatically load the pcspkr driver the +next time it boots, uncomment the + + alias platform:pcspkr pcspkr + +line in the `/etc/modprobe.d/beep.conf` config file. + +You can check whether pcspkr.ko is loaded by running + + # lsmod | grep pcspkr + +as root. + +When pcspkr is loaded, you can run + + # beep + +as root and verify that you hear the beep coming from the PC speaker. + +CAUTION: There (used to?) appear to be some issues with access to the +`/dev/console` device which beep uses, possibly related to +`ConsoleKit`. This means that sometimes, just having `pcspkr.ko` +loaded is not enough for beep to actually beep. This issue is being investigated. + + +2. Set Up `beep` For Use As non-root Users Via `sudo` (optional) +---------------------------------------------------------------- + +If you want non-root users can run the `beep` command, you can set up +`sudo` such that non-root users can run beep. This might have security +implications if the `beep` executable and/or the `pcspkr.ko` kernel +driver contain exploitable flaws. + +An alternative way to get sound output for non-root users without +becoming root works if the system has a sound card set up and a +speaker connected. The example chime from the `sox(1)` man page from +the `sox` package could be a nice sounding alternative to the harsh +rectangle wave beep from the common PC piezo buzzer: + + $ play -q -n synth -j 3 sin %3 sin %-2 sin %-5 sin %-9 \ + sin %-14 sin %-21 fade h .01 2 1.5 delay \ + 1.3 1 .76 .54 .27 remix - fade h 0 2.7 2.5 norm -1 + +So, if you still insist on making non-root users run beep as root, +then do read on. + +As root, edit the `/etc/sudoers.d/beep` file to allow certain users or +groups to run beep. The example file shipped by the beep package +contains those two simple examples which you can uncomment and adapt: + + # Allow user 'jane' to run beep as root (if uncommented) + # jane NOPASSWD: /usr/bin/beep + + # Allow all members of the group 'mock' to run beep as root (if uncommented) + # %mock NOPASSWD: /usr/bin/beep + +For more information on setting up sudo, read the `sudoers(5)` man page. + +When you have finished setting up the `sudoers` file, you can check +whether `sudo beep` works with commands run as non-root users like + + [jane@home ~]$ id + uid=1000(jane) gid=1000(jane) groups=1000(jane) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 + [jane@home ~]$ sudo beep + + [bill@home ~]$ id + uid=1066(bill) gid=1066(bill) groups=1066(bill),135(mock) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 + [bill@home ~]$ sudo beep + + +3. Example Usage +---------------- + +An acoustic notification when a compile job finishes (whether the +build was successful or not) could be done with + + [jane@home ~/src/foobar]$ ./configure && make && make check && make install; sudo -n beep + +or + + [bill@home ~/rpms/foobar]$ fedpkg mockbuild; sudo -n beep diff --git a/beep.spec b/beep.spec index 56c8c58..2a06054 100644 --- a/beep.spec +++ b/beep.spec @@ -8,7 +8,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.3 -Release: 13%{?dist} +Release: 14%{?dist} Group: Applications/System License: GPLv2+ @@ -27,6 +27,7 @@ Source0: http://www.johnath.com/beep/%{name}-%{version}.tar.gz # Fedora specific files Source1: %{name}-README.fedora Source2: %{name}-modprobe.conf +Source3: %{name}.sudoers # Fix from upstream github repo @@ -84,6 +85,9 @@ install -d -m 0755 "$RPM_BUILD_ROOT/etc/modprobe.d/" install -p -m 0644 %{SOURCE2} "$RPM_BUILD_ROOT/etc/modprobe.d/beep.conf" %endif +install -d -m 0700 "$RPM_BUILD_ROOT/%{_sysconfdir}/sudoers.d/" +install -p -m 0600 %{SOURCE3} "$RPM_BUILD_ROOT/%{_sysconfdir}/sudoers.d/beep" + %clean rm -rf $RPM_BUILD_ROOT @@ -97,9 +101,13 @@ rm -rf $RPM_BUILD_ROOT %doc README.fedora %config(noreplace) %attr(0644,root,root) %{_sysconfdir}/modprobe.d/beep.conf %endif +%config(noreplace) %attr(0600,root,root) %{_sysconfdir}/sudoers.d/beep %changelog +* Tue May 31 2016 Hans Ulrich Niedermann - 1.3-14 +- Document how non-root users can run beep via sudo (#1133231) + * Mon May 16 2016 Hans Ulrich Niedermann - 1.3-13 - remove useless %%defattr for clarity diff --git a/beep.sudoers b/beep.sudoers new file mode 100644 index 0000000..130144d --- /dev/null +++ b/beep.sudoers @@ -0,0 +1,5 @@ +# Allow user 'jane' to run beep as root (if uncommented) +# jane ALL=NOPASSWD: /usr/bin/beep + +# Allow all members of the group 'mock' to run beep as root (if uncommented) +# %mock ALL=NOPASSWD: /usr/bin/beep From 80295a81b26b0643a0cb3366bd10cd7f5060f23d Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 31 May 2016 17:46:19 +0200 Subject: [PATCH 06/80] RPM spec file changelog capitalization fix --- beep.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beep.spec b/beep.spec index 2a06054..3b511a4 100644 --- a/beep.spec +++ b/beep.spec @@ -109,7 +109,7 @@ rm -rf $RPM_BUILD_ROOT - Document how non-root users can run beep via sudo (#1133231) * Mon May 16 2016 Hans Ulrich Niedermann - 1.3-13 -- remove useless %%defattr for clarity +- Remove useless %%defattr for clarity * Wed Feb 03 2016 Fedora Release Engineering - 1.3-12 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild From 9b271ba1b3a9facad4d0260b97e6dc2aafe985cf Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 31 May 2016 17:47:00 +0200 Subject: [PATCH 07/80] Put quotes into %%install shell script --- beep.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/beep.spec b/beep.spec index 3b511a4..caed7f4 100644 --- a/beep.spec +++ b/beep.spec @@ -77,8 +77,8 @@ make %{?_smp_mflags} CFLAGS="${RPM_OPT_FLAGS}" %install -rm -rf $RPM_BUILD_ROOT -make install DESTDIR=$RPM_BUILD_ROOT +rm -rf "$RPM_BUILD_ROOT" +make install DESTDIR="$RPM_BUILD_ROOT" %if %{ship_modprobe_config} install -d -m 0755 "$RPM_BUILD_ROOT/etc/modprobe.d/" From 08e29442a5c28602e8690d9cba335c772443519b Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 31 May 2016 17:47:30 +0200 Subject: [PATCH 08/80] Remove spec file conditional required in Fedora 12 times --- beep.spec | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/beep.spec b/beep.spec index caed7f4..19fd0b2 100644 --- a/beep.spec +++ b/beep.spec @@ -1,10 +1,3 @@ -%if 0%{?fedora} >= 12 -%global ship_modprobe_config 1 -%else -%global ship_modprobe_config 0 -%endif - - Summary: Beep the PC speaker any number of ways Name: beep Version: 1.3 @@ -80,10 +73,8 @@ make %{?_smp_mflags} CFLAGS="${RPM_OPT_FLAGS}" rm -rf "$RPM_BUILD_ROOT" make install DESTDIR="$RPM_BUILD_ROOT" -%if %{ship_modprobe_config} -install -d -m 0755 "$RPM_BUILD_ROOT/etc/modprobe.d/" -install -p -m 0644 %{SOURCE2} "$RPM_BUILD_ROOT/etc/modprobe.d/beep.conf" -%endif +install -d -m 0755 "$RPM_BUILD_ROOT/%{_sysconfdir}/modprobe.d/" +install -p -m 0644 %{SOURCE2} "$RPM_BUILD_ROOT/%{_sysconfdir}/modprobe.d/beep.conf" install -d -m 0700 "$RPM_BUILD_ROOT/%{_sysconfdir}/sudoers.d/" install -p -m 0600 %{SOURCE3} "$RPM_BUILD_ROOT/%{_sysconfdir}/sudoers.d/beep" @@ -97,16 +88,15 @@ rm -rf $RPM_BUILD_ROOT %doc CHANGELOG COPYING CREDITS README %attr(0755,root,root) %{_bindir}/beep %{_mandir}/man1/beep.1.gz -%if %{ship_modprobe_config} %doc README.fedora %config(noreplace) %attr(0644,root,root) %{_sysconfdir}/modprobe.d/beep.conf -%endif %config(noreplace) %attr(0600,root,root) %{_sysconfdir}/sudoers.d/beep %changelog * Tue May 31 2016 Hans Ulrich Niedermann - 1.3-14 - Document how non-root users can run beep via sudo (#1133231) +- Remove spec file conditional required in Fedora 12 times * Mon May 16 2016 Hans Ulrich Niedermann - 1.3-13 - Remove useless %%defattr for clarity From a4231f55ef7a58cd2e1355b771be5e834fa1c0fd Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 31 May 2016 20:47:05 +0200 Subject: [PATCH 09/80] Add shell aliases to allow non-root users to run beep from the shell --- beep-README.fedora | 56 +++++++++++++++++++++++++++++++++++++--------- beep.csh | 6 +++++ beep.sh | 6 +++++ beep.spec | 15 +++++++++++-- 4 files changed, 70 insertions(+), 13 deletions(-) create mode 100644 beep.csh create mode 100644 beep.sh diff --git a/beep-README.fedora b/beep-README.fedora index 31604c5..bb669d6 100644 --- a/beep-README.fedora +++ b/beep-README.fedora @@ -1,9 +1,9 @@ Content ======= -1. Load the pkspkr.ko Kernel Driver Module (required) -2. Set Up `beep` For Use As non-root Users Via `sudo` (optional) -3. Example Usage + 1. Load the pkspkr.ko Kernel Driver Module (required) + 2. Set Up `beep` For Use As non-root Users Via `sudo` (optional) + 3. Example Usage 1. Load the pkspkr.ko Kernel Driver Module (required) @@ -63,6 +63,8 @@ rectangle wave beep from the common PC piezo buzzer: So, if you still insist on making non-root users run beep as root, then do read on. +First, make sure the `sudo` package is installed. + As root, edit the `/etc/sudoers.d/beep` file to allow certain users or groups to run beep. The example file shipped by the beep package contains those two simple examples which you can uncomment and adapt: @@ -78,23 +80,55 @@ For more information on setting up sudo, read the `sudoers(5)` man page. When you have finished setting up the `sudoers` file, you can check whether `sudo beep` works with commands run as non-root users like - [jane@home ~]$ id + [jane@host ~]$ id uid=1000(jane) gid=1000(jane) groups=1000(jane) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 - [jane@home ~]$ sudo beep + [jane@host ~]$ sudo -n beep + [jane@host ~]$ - [bill@home ~]$ id + [bill@host ~]$ id uid=1066(bill) gid=1066(bill) groups=1066(bill),135(mock) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 - [bill@home ~]$ sudo beep + [bill@host ~]$ sudo -n beep + [bill@host ~]$ + +Now you can source the alias definitions for `beep` in your shell (if +you are running a `csh` variant, replace `.sh` with `.csh`): + + [jane@host ~]$ source /etc/profile.d/beep.sh + [jane@host ~]$ beep + [jane@host ~]$ + +The sourcing of the `/etc/profile.d/beep.(csh|sh)` file will be done +automatically when you start a new (login?) shell. + +In case you have *not* configured `sudo` for a non-password execution +of `beep`, `beep` will still work normally for the `root` user, and all +other users see a `sudo` error message + + [jane@host ~]$ alias beep + alias beep='sudo -n /usr/bin/beep' + [jane@host ~]$ beep + sudo: a password is required + [jane@host ~]$ + +instead of the `beep` error message they see without the sudo based +alias for `beep`: + + [jane@host ~]$ alias beep + -bash: alias: beep: not found + [jane@host ~]$ beep + Could not open /dev/tty0 or /dev/vc/0 for writing + open: No such file or directory + [jane@host ~]$ 3. Example Usage ---------------- -An acoustic notification when a compile job finishes (whether the -build was successful or not) could be done with +An acoustic notification when a long running compile job finishes +(whether the build was successful or not) could be done with - [jane@home ~/src/foobar]$ ./configure && make && make check && make install; sudo -n beep + [jane@host ~/src/foobar]$ ./configure --prefix=$HOME/.local && make && make check && make install; beep or - [bill@home ~/rpms/foobar]$ fedpkg mockbuild; sudo -n beep + [bill@host ~/rpms/foobar]$ fedpkg mockbuild; beep diff --git a/beep.csh b/beep.csh new file mode 100644 index 0000000..31ded7b --- /dev/null +++ b/beep.csh @@ -0,0 +1,6 @@ +# Allow non-root users to call beep as root via sudo +# when configured without password in `/etc/sudoers.d/beep`. + +if (($euid != 0) && (-x /usr/bin/beep) && (-x /usr/bin/sudo)) then + alias beep 'sudo -n /usr/bin/beep' +endif diff --git a/beep.sh b/beep.sh new file mode 100644 index 0000000..978d024 --- /dev/null +++ b/beep.sh @@ -0,0 +1,6 @@ +# Allow non-root users to call beep as root via sudo +# when configured without password in `/etc/sudoers.d/beep`. + +if [ "${EUID:-}" != 0 ] && [ -x /usr/bin/beep ] && [ -x /usr/bin/sudo ]; then + alias beep='sudo -n /usr/bin/beep' +fi diff --git a/beep.spec b/beep.spec index 19fd0b2..e994c5e 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.3 -Release: 14%{?dist} +Release: 15%{?dist} Group: Applications/System License: GPLv2+ @@ -21,6 +21,8 @@ Source0: http://www.johnath.com/beep/%{name}-%{version}.tar.gz Source1: %{name}-README.fedora Source2: %{name}-modprobe.conf Source3: %{name}.sudoers +Source4: %{name}.csh +Source5: %{name}.sh # Fix from upstream github repo @@ -79,6 +81,9 @@ install -p -m 0644 %{SOURCE2} "$RPM_BUILD_ROOT/%{_sysconfdir}/modprobe.d/beep.co install -d -m 0700 "$RPM_BUILD_ROOT/%{_sysconfdir}/sudoers.d/" install -p -m 0600 %{SOURCE3} "$RPM_BUILD_ROOT/%{_sysconfdir}/sudoers.d/beep" +install -d -m 0755 "$RPM_BUILD_ROOT/%{_sysconfdir}/profile.d/" +install -p -m 0644 %{SOURCE4} %{SOURCE5} "$RPM_BUILD_ROOT/%{_sysconfdir}/profile.d/" + %clean rm -rf $RPM_BUILD_ROOT @@ -91,10 +96,16 @@ rm -rf $RPM_BUILD_ROOT %doc README.fedora %config(noreplace) %attr(0644,root,root) %{_sysconfdir}/modprobe.d/beep.conf %config(noreplace) %attr(0600,root,root) %{_sysconfdir}/sudoers.d/beep +%config %{_sysconfdir}/profile.d/beep.csh +%config %{_sysconfdir}/profile.d/beep.sh %changelog -* Tue May 31 2016 Hans Ulrich Niedermann - 1.3-14 +* Tue May 31 2016 Hans Ulrich Niedermann - 1.3-15 +- Add shell aliases to allow non-root users to run beep from the shell +- Fix mail address in %%changelog + +* Tue May 31 2016 Hans Ulrich Niedermann - 1.3-14 - Document how non-root users can run beep via sudo (#1133231) - Remove spec file conditional required in Fedora 12 times From e468bae2eb28f5b8ac988373c72fc73e26ca8432 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 31 May 2016 22:23:48 +0200 Subject: [PATCH 10/80] Use more appropriate sox play example in README.fedora --- beep-README.fedora | 23 +++++++++++------------ beep.spec | 6 +++++- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/beep-README.fedora b/beep-README.fedora index bb669d6..5c6099f 100644 --- a/beep-README.fedora +++ b/beep-README.fedora @@ -14,7 +14,7 @@ kernel driver module `pcspkr.ko` first. You can do this manually as root as follows: - # modprobe pcspkr + [root@host ~]# modprobe pcspkr If you want the system to automatically load the pcspkr driver the next time it boots, uncomment the @@ -25,13 +25,13 @@ line in the `/etc/modprobe.d/beep.conf` config file. You can check whether pcspkr.ko is loaded by running - # lsmod | grep pcspkr + [root@host ~]# lsmod | grep pcspkr as root. When pcspkr is loaded, you can run - # beep + [root@host ~]# beep as root and verify that you hear the beep coming from the PC speaker. @@ -51,17 +51,16 @@ implications if the `beep` executable and/or the `pcspkr.ko` kernel driver contain exploitable flaws. An alternative way to get sound output for non-root users without -becoming root works if the system has a sound card set up and a -speaker connected. The example chime from the `sox(1)` man page from -the `sox` package could be a nice sounding alternative to the harsh -rectangle wave beep from the common PC piezo buzzer: +becoming root works if the system has a sound card set up with a +speaker connected to it. The standard 440Hz square wave which `beep` +emits can be played through the standard sound infrastructure with the +command `play` from the `sox` package (more pleasant examples are in +the `sox(1)` man page): - $ play -q -n synth -j 3 sin %3 sin %-2 sin %-5 sin %-9 \ - sin %-14 sin %-21 fade h .01 2 1.5 delay \ - 1.3 1 .76 .54 .27 remix - fade h 0 2.7 2.5 norm -1 + [jane@host ~]$ play -q -n synth 0.3 square 440 -So, if you still insist on making non-root users run beep as root, -then do read on. +So, if you still insist on making non-root users run `beep` as root, +do read on. First, make sure the `sudo` package is installed. diff --git a/beep.spec b/beep.spec index e994c5e..4dc225f 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.3 -Release: 15%{?dist} +Release: 16%{?dist} Group: Applications/System License: GPLv2+ @@ -101,6 +101,10 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Tue May 31 2016 Hans Ulrich Niedermann - 1.3-16 +- Use more appropriate sox play example in README.fedora +- Make command line examples more readable in README.fedora + * Tue May 31 2016 Hans Ulrich Niedermann - 1.3-15 - Add shell aliases to allow non-root users to run beep from the shell - Fix mail address in %%changelog From 61194acfe1ca1c71a18004d52b8917633246e9ea Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 10 Feb 2017 06:48:16 +0000 Subject: [PATCH 11/80] - Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild --- beep.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beep.spec b/beep.spec index 4dc225f..952a1a2 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.3 -Release: 16%{?dist} +Release: 17%{?dist} Group: Applications/System License: GPLv2+ @@ -101,6 +101,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Fri Feb 10 2017 Fedora Release Engineering - 1.3-17 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + * Tue May 31 2016 Hans Ulrich Niedermann - 1.3-16 - Use more appropriate sox play example in README.fedora - Make command line examples more readable in README.fedora From 322ce2bffe70b167d0d55ab6702f6c83d52955f6 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 26 Jul 2017 03:52:32 +0000 Subject: [PATCH 12/80] - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild --- beep.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beep.spec b/beep.spec index 952a1a2..75260a2 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.3 -Release: 17%{?dist} +Release: 18%{?dist} Group: Applications/System License: GPLv2+ @@ -101,6 +101,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Wed Jul 26 2017 Fedora Release Engineering - 1.3-18 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + * Fri Feb 10 2017 Fedora Release Engineering - 1.3-17 - Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild From b1e095d97ab250a809837597cb8ef2e0327dcfa2 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 2 Aug 2017 18:10:34 +0000 Subject: [PATCH 13/80] - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild --- beep.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beep.spec b/beep.spec index 75260a2..cb52ac7 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.3 -Release: 18%{?dist} +Release: 19%{?dist} Group: Applications/System License: GPLv2+ @@ -101,6 +101,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Wed Aug 02 2017 Fedora Release Engineering - 1.3-19 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + * Wed Jul 26 2017 Fedora Release Engineering - 1.3-18 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild From 9b3f1d9c025cb6346100cb5906e457e42d192d8c Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 7 Feb 2018 03:43:26 +0000 Subject: [PATCH 14/80] - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- beep.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beep.spec b/beep.spec index cb52ac7..89a6575 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.3 -Release: 19%{?dist} +Release: 20%{?dist} Group: Applications/System License: GPLv2+ @@ -101,6 +101,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Wed Feb 07 2018 Fedora Release Engineering - 1.3-20 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + * Wed Aug 02 2017 Fedora Release Engineering - 1.3-19 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild From 12cbd28107e20ffb1cfbecf56b9d8171d0bf8ecf Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Wed, 14 Feb 2018 07:53:07 +0100 Subject: [PATCH 15/80] Remove %clean section None of currently supported distributions need that. Last one was EL5 which is EOL for a while. Signed-off-by: Igor Gnatenko --- beep.spec | 3 --- 1 file changed, 3 deletions(-) diff --git a/beep.spec b/beep.spec index 89a6575..1d83ee0 100644 --- a/beep.spec +++ b/beep.spec @@ -85,9 +85,6 @@ install -d -m 0755 "$RPM_BUILD_ROOT/%{_sysconfdir}/profile.d/" install -p -m 0644 %{SOURCE4} %{SOURCE5} "$RPM_BUILD_ROOT/%{_sysconfdir}/profile.d/" -%clean -rm -rf $RPM_BUILD_ROOT - %files %doc CHANGELOG COPYING CREDITS README From 654e5d8887c89fb7dda89c8011cdb3ac4b20e61e Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 3 Jun 2016 16:13:09 +0200 Subject: [PATCH 16/80] Improve comment explaining beep.{sh,csh} profile files --- beep.csh | 6 ++++-- beep.sh | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/beep.csh b/beep.csh index 31ded7b..d8cc30a 100644 --- a/beep.csh +++ b/beep.csh @@ -1,5 +1,7 @@ -# Allow non-root users to call beep as root via sudo -# when configured without password in `/etc/sudoers.d/beep`. +# If `/etc/sudoers.d/beep` is configured to allow the non-root user +# access to beep without entering a password, alias `beep` to do that. +# If sudo does require a password, the non-root users will see a sudo +# error message instead of a beep error message. if (($euid != 0) && (-x /usr/bin/beep) && (-x /usr/bin/sudo)) then alias beep 'sudo -n /usr/bin/beep' diff --git a/beep.sh b/beep.sh index 978d024..1825537 100644 --- a/beep.sh +++ b/beep.sh @@ -1,5 +1,7 @@ -# Allow non-root users to call beep as root via sudo -# when configured without password in `/etc/sudoers.d/beep`. +# If `/etc/sudoers.d/beep` is configured to allow the non-root user +# access to beep without entering a password, alias `beep` to do that. +# If sudo does require a password, the non-root users will see a sudo +# error message instead of a beep error message. if [ "${EUID:-}" != 0 ] && [ -x /usr/bin/beep ] && [ -x /usr/bin/sudo ]; then alias beep='sudo -n /usr/bin/beep' From c60697200414ccf4625c4bd403bff2a1544a824b Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sat, 4 Jun 2016 04:31:27 +0200 Subject: [PATCH 17/80] Make effect of multiple -f parameters match documentation --- 0007-Fix-indentation-if-brace-error.patch | 38 +++++++++++++++++++++++ beep.spec | 4 +++ 2 files changed, 42 insertions(+) create mode 100644 0007-Fix-indentation-if-brace-error.patch diff --git a/0007-Fix-indentation-if-brace-error.patch b/0007-Fix-indentation-if-brace-error.patch new file mode 100644 index 0000000..00f485d --- /dev/null +++ b/0007-Fix-indentation-if-brace-error.patch @@ -0,0 +1,38 @@ +commit 07a33095b0c057373bce5f5bf66eb8c4d1c45c91 +Author: Hans Ulrich Niedermann +Date: Sat Jun 4 04:17:57 2016 +0200 + + Fix indentation/if brace error + + As beep.c is not Python, the code blocks must be defined by + using braces instead of just indenting them differently. + + Once we do that, the outcome of multiple -f parameters will + actually match what the warning message documents beep does: + Only the last -f value will be used. + + Many projects proscribe using braces everywhere, but this + change keeps the beep.c coding style of using braces only + when absolutely necessary. + + This issue was discovered by compiling with gcc 6. + +diff --git a/beep.c b/beep.c +index 7da2e70..250be56 100644 +--- a/beep.c ++++ b/beep.c +@@ -194,11 +194,12 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) { + if(!sscanf(optarg, "%f", &argfreq) || (argfreq >= 20000 /* ack! */) || + (argfreq <= 0)) + usage_bail(argv[0]); +- else ++ else { + if (result->freq != 0) + fprintf(stderr, "WARNING: multiple -f values given, only last " + "one is used.\n"); +- result->freq = argfreq; ++ result->freq = argfreq; ++ } + break; + case 'l' : /* length */ + if(!sscanf(optarg, "%d", &argval) || (argval < 0)) diff --git a/beep.spec b/beep.spec index 1d83ee0..f96f8a1 100644 --- a/beep.spec +++ b/beep.spec @@ -45,6 +45,9 @@ Patch5: 0005-Make-build-install-more-user-and-packaging-friendly.patch # https://github.com/johnath/beep/pull/6 Patch6: 0006-Preserve-file-modification-time-on-install.patch +# Fix indentation/if brace error +Patch7: 0007-Fix-indentation-if-brace-error.patch + BuildRequires: glibc-kernheaders @@ -64,6 +67,7 @@ what's interesting, but it's real good at that notifying part. %patch4 -p1 -b 0004 %patch5 -p1 -b 0005 %patch6 -p1 -b 0006 +%patch7 -p1 -b 0007 cp -p %{SOURCE1} README.fedora From bafa252a73556eaba1d496d69b3cb32261dec78b Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 3 Apr 2018 19:26:12 +0200 Subject: [PATCH 18/80] beep-1.3-21: Apply CVE-2018-0492 patch. Bump release to beep-1.3-21: Apply CVE-2018-0492 patch. --- ...-2018-0492.patch-from-Debian-package.patch | 118 ++++++++++++++++++ beep.spec | 9 +- 2 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 0008-Apply-CVE-2018-0492.patch-from-Debian-package.patch diff --git a/0008-Apply-CVE-2018-0492.patch-from-Debian-package.patch b/0008-Apply-CVE-2018-0492.patch-from-Debian-package.patch new file mode 100644 index 0000000..29aa9f6 --- /dev/null +++ b/0008-Apply-CVE-2018-0492.patch-from-Debian-package.patch @@ -0,0 +1,118 @@ +From 3b67473e16aaf2f83cb8ac18c13c9183a8e3c7b2 Mon Sep 17 00:00:00 2001 +From: Hans Ulrich Niedermann +Date: Tue, 3 Apr 2018 18:37:33 +0200 +Subject: [PATCH] Apply CVE-2018-0492.patch from Debian package + +--- + beep.c | 53 ++++++++++++++++++++++++----------------------------- + 1 file changed, 24 insertions(+), 29 deletions(-) + +diff --git a/beep.c b/beep.c +index d46adc8..f6781e8 100644 +--- a/beep.c ++++ b/beep.c +@@ -109,6 +109,7 @@ void do_beep(int freq) { + /* BEEP_TYPE_EVDEV */ + struct input_event e; + ++ memset(&e, 0, sizeof(e)); + e.type = EV_SND; + e.code = SND_TONE; + e.value = freq; +@@ -124,10 +125,6 @@ void do_beep(int freq) { + /* If we get interrupted, it would be nice to not leave the speaker beeping in + perpetuity. */ + void handle_signal(int signum) { +- +- if(console_device) +- free(console_device); +- + switch(signum) { + case SIGINT: + case SIGTERM: +@@ -258,7 +255,7 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) { + result->verbose = 1; + break; + case 'e' : /* also --device */ +- console_device = strdup(optarg); ++ console_device = optarg; + break; + case 'h' : /* notice that this is also --help */ + default : +@@ -277,26 +274,6 @@ void play_beep(beep_parms_t parms) { + "%d delay after) @ %.2f Hz\n", + parms.reps, parms.length, parms.delay, parms.end_delay, parms.freq); + +- /* try to snag the console */ +- if(console_device) +- console_fd = open(console_device, O_WRONLY); +- else +- if((console_fd = open("/dev/tty0", O_WRONLY)) == -1) +- console_fd = open("/dev/vc/0", O_WRONLY); +- +- if(console_fd == -1) { +- fprintf(stderr, "Could not open %s for writing\n", +- console_device != NULL ? console_device : "/dev/tty0 or /dev/vc/0"); +- printf("\a"); /* Output the only beep we can, in an effort to fall back on usefulness */ +- perror("open"); +- exit(1); +- } +- +- if (ioctl(console_fd, EVIOCGSND(0)) != -1) +- console_type = BEEP_TYPE_EVDEV; +- else +- console_type = BEEP_TYPE_CONSOLE; +- + /* Beep */ + for (i = 0; i < parms.reps; i++) { /* start beep */ + do_beep(parms.freq); +@@ -306,8 +283,6 @@ void play_beep(beep_parms_t parms) { + if(parms.end_delay || (i+1 < parms.reps)) + usleep(1000*parms.delay); /* wait... */ + } /* repeat. */ +- +- close(console_fd); + } + + +@@ -329,6 +304,26 @@ int main(int argc, char **argv) { + signal(SIGTERM, handle_signal); + parse_command_line(argc, argv, parms); + ++ /* try to snag the console */ ++ if(console_device) ++ console_fd = open(console_device, O_WRONLY); ++ else ++ if((console_fd = open("/dev/tty0", O_WRONLY)) == -1) ++ console_fd = open("/dev/vc/0", O_WRONLY); ++ ++ if(console_fd == -1) { ++ fprintf(stderr, "Could not open %s for writing\n", ++ console_device != NULL ? console_device : "/dev/tty0 or /dev/vc/0"); ++ printf("\a"); /* Output the only beep we can, in an effort to fall back on usefulness */ ++ perror("open"); ++ exit(1); ++ } ++ ++ if (ioctl(console_fd, EVIOCGSND(0)) != -1) ++ console_type = BEEP_TYPE_EVDEV; ++ else ++ console_type = BEEP_TYPE_CONSOLE; ++ + /* this outermost while loop handles the possibility that -n/--new has been + used, i.e. that we have multiple beeps specified. Each iteration will + play, then free() one parms instance. */ +@@ -366,8 +361,8 @@ int main(int argc, char **argv) { + parms = next; + } + +- if(console_device) +- free(console_device); ++ close(console_fd); ++ console_fd = -1; + + return EXIT_SUCCESS; + } +-- +2.7.5 + diff --git a/beep.spec b/beep.spec index f96f8a1..e43fd86 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.3 -Release: 20%{?dist} +Release: 21%{?dist} Group: Applications/System License: GPLv2+ @@ -48,6 +48,9 @@ Patch6: 0006-Preserve-file-modification-time-on-install.patch # Fix indentation/if brace error Patch7: 0007-Fix-indentation-if-brace-error.patch +# Apply CVE-2018-0492.patch from Debian package +Patch8: 0008-Apply-CVE-2018-0492.patch-from-Debian-package.patch + BuildRequires: glibc-kernheaders @@ -68,6 +71,7 @@ what's interesting, but it's real good at that notifying part. %patch5 -p1 -b 0005 %patch6 -p1 -b 0006 %patch7 -p1 -b 0007 +%patch8 -p1 -b 0008 cp -p %{SOURCE1} README.fedora @@ -102,6 +106,9 @@ install -p -m 0644 %{SOURCE4} %{SOURCE5} "$RPM_BUILD_ROOT/%{_sysconfdir}/profile %changelog +* Tue Apr 3 2018 Hans Ulrich Niedermann - 1.3-21 +- Add CVE-2018-0492 fix + * Wed Feb 07 2018 Fedora Release Engineering - 1.3-20 - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild From d37578b06ad366a4b4873afe027fe1c06c9782df Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 3 Apr 2018 19:28:35 +0200 Subject: [PATCH 19/80] patch cleanup and re-update from git This cleans up the 00*-*.patch a bit which are generated by `git format-patch -o .. -N beep-1.3-release`. --- 0001-Fixed-Makefile.patch | 4 +- 0002-Add-more-error-detection.patch | 4 +- ...-catch-SIGTERM-for-stopping-the-beep.patch | 4 +- ...all-more-user-and-packaging-friendly.patch | 4 +- ...ve-file-modification-time-on-install.patch | 4 +- 0007-Fix-indentation-if-brace-error.patch | 44 ++++++++++--------- 6 files changed, 34 insertions(+), 30 deletions(-) diff --git a/0001-Fixed-Makefile.patch b/0001-Fixed-Makefile.patch index 0a8d7c3..7342560 100644 --- a/0001-Fixed-Makefile.patch +++ b/0001-Fixed-Makefile.patch @@ -1,7 +1,7 @@ From 8b32b8b088be1f29e8bfea57a97b9bfaa76ec8ee Mon Sep 17 00:00:00 2001 From: Chris Wong Date: Wed, 23 Nov 2011 10:39:53 +1300 -Subject: [PATCH 1/6] Fixed Makefile +Subject: [PATCH] Fixed Makefile * Use /usr/share/man (see http://www.pathname.com/fhs/2.2/fhs-4.11.html#4.11.5) @@ -41,5 +41,5 @@ index cc359c4..0f4f810 100644 # rm -f /usr/man/man1/beep.1.bz2 cp ${MAN_FILE} ${MAN_DIR} -- -1.8.4.2 +2.7.5 diff --git a/0002-Add-more-error-detection.patch b/0002-Add-more-error-detection.patch index a4f0ca3..6a229e0 100644 --- a/0002-Add-more-error-detection.patch +++ b/0002-Add-more-error-detection.patch @@ -1,7 +1,7 @@ From d3aee6c489852108c91dc22abcacff364e9429f2 Mon Sep 17 00:00:00 2001 From: Chris Wong Date: Wed, 23 Nov 2011 11:34:55 +1300 -Subject: [PATCH 2/6] Add more error detection +Subject: [PATCH] Add more error detection --- beep.c | 15 +++++++++------ @@ -41,5 +41,5 @@ index 452fc08..14fac3e 100644 } -- -1.8.4.2 +2.7.5 diff --git a/0004-also-catch-SIGTERM-for-stopping-the-beep.patch b/0004-also-catch-SIGTERM-for-stopping-the-beep.patch index 89187b9..8574b32 100644 --- a/0004-also-catch-SIGTERM-for-stopping-the-beep.patch +++ b/0004-also-catch-SIGTERM-for-stopping-the-beep.patch @@ -1,7 +1,7 @@ From e1320c1da52ca92aa68b4224f9532982184fbe00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me?= Date: Thu, 7 Feb 2013 12:54:53 +0100 -Subject: [PATCH 4/6] also catch SIGTERM for stopping the beep +Subject: [PATCH] also catch SIGTERM for stopping the beep Signed-off-by: Gerfried Fuchs --- @@ -29,5 +29,5 @@ index 452fc08..9cb63bf 100644 /* this outermost while loop handles the possibility that -n/--new has been -- -1.8.4.2 +2.7.5 diff --git a/0005-Make-build-install-more-user-and-packaging-friendly.patch b/0005-Make-build-install-more-user-and-packaging-friendly.patch index b6a84e4..9e2b481 100644 --- a/0005-Make-build-install-more-user-and-packaging-friendly.patch +++ b/0005-Make-build-install-more-user-and-packaging-friendly.patch @@ -1,7 +1,7 @@ From 947a7e332908dcba1c7e523fbdc927d39ee6adb1 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 19 Nov 2013 23:40:50 +0100 -Subject: [PATCH 5/6] Make build/install more user and packaging friendly +Subject: [PATCH] Make build/install more user and packaging friendly Make the build and install more user and packaging friendly by introducing the following features in the Makefile: @@ -81,5 +81,5 @@ index 0f4f810..942a7a5 100644 + rm -f $(DESTDIR)$(bindir)/$(EXEC_NAME) + rm -f $(DESTDIR)$(man1dir)/$(MAN_FILE) -- -1.8.4.2 +2.7.5 diff --git a/0006-Preserve-file-modification-time-on-install.patch b/0006-Preserve-file-modification-time-on-install.patch index 4db0272..8a32405 100644 --- a/0006-Preserve-file-modification-time-on-install.patch +++ b/0006-Preserve-file-modification-time-on-install.patch @@ -1,7 +1,7 @@ From 4622dd15dc12dab47a0381a8a7188f0f0421e01d Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 20 Nov 2013 00:00:54 +0100 -Subject: [PATCH 6/6] Preserve file modification time on install +Subject: [PATCH] Preserve file modification time on install Add -p option to install(1) invocation in order to preserve the timestamps of the files being installed. @@ -29,5 +29,5 @@ index 942a7a5..290b8a4 100644 uninstall: rm -f $(DESTDIR)$(bindir)/$(EXEC_NAME) -- -1.8.4.2 +2.7.5 diff --git a/0007-Fix-indentation-if-brace-error.patch b/0007-Fix-indentation-if-brace-error.patch index 00f485d..b318247 100644 --- a/0007-Fix-indentation-if-brace-error.patch +++ b/0007-Fix-indentation-if-brace-error.patch @@ -1,24 +1,26 @@ -commit 07a33095b0c057373bce5f5bf66eb8c4d1c45c91 -Author: Hans Ulrich Niedermann -Date: Sat Jun 4 04:17:57 2016 +0200 +From 35ba84dccb8fc8dc43cb3f575904a33ffa27e7b7 Mon Sep 17 00:00:00 2001 +From: Hans Ulrich Niedermann +Date: Tue, 3 Apr 2018 19:11:07 +0200 +Subject: [PATCH] Fix indentation/if brace error - Fix indentation/if brace error - - As beep.c is not Python, the code blocks must be defined by - using braces instead of just indenting them differently. - - Once we do that, the outcome of multiple -f parameters will - actually match what the warning message documents beep does: - Only the last -f value will be used. - - Many projects proscribe using braces everywhere, but this - change keeps the beep.c coding style of using braces only - when absolutely necessary. - - This issue was discovered by compiling with gcc 6. +As beep.c is not Python, the code blocks must be defined by +using braces instead of just indenting them differently. + +Once we do that, the outcome of multiple -f parameters will +actually match what the warning message documents beep does: +Only the last -f value will be used. + +Many projects proscribe using braces everywhere, but this +change keeps the beep.c coding style of using braces only +when absolutely necessary. + +This issue was discovered by compiling with gcc 6. +--- + beep.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/beep.c b/beep.c -index 7da2e70..250be56 100644 +index 7da2e70..d46adc8 100644 --- a/beep.c +++ b/beep.c @@ -194,11 +194,12 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) { @@ -30,9 +32,11 @@ index 7da2e70..250be56 100644 if (result->freq != 0) fprintf(stderr, "WARNING: multiple -f values given, only last " "one is used.\n"); -- result->freq = argfreq; -+ result->freq = argfreq; + result->freq = argfreq; + } break; case 'l' : /* length */ if(!sscanf(optarg, "%d", &argval) || (argval < 0)) +-- +2.7.5 + From 6ffab0a44ccbb5945ebcb3768b4713123c94846a Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 3 Apr 2018 19:34:09 +0200 Subject: [PATCH 20/80] Add fix for multiple -f params to rpm changelog --- beep.spec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/beep.spec b/beep.spec index e43fd86..d68825d 100644 --- a/beep.spec +++ b/beep.spec @@ -107,7 +107,8 @@ install -p -m 0644 %{SOURCE4} %{SOURCE5} "$RPM_BUILD_ROOT/%{_sysconfdir}/profile %changelog * Tue Apr 3 2018 Hans Ulrich Niedermann - 1.3-21 -- Add CVE-2018-0492 fix +- Add CVE-2018-0492 fix. +- Behaviour of multiple -f parameters matches documentation now. * Wed Feb 07 2018 Fedora Release Engineering - 1.3-20 - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild From e88478864bcd888514729ab572fde2662e7b14c0 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 12 Jul 2018 21:01:08 +0000 Subject: [PATCH 21/80] - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- beep.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beep.spec b/beep.spec index d68825d..a584daf 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.3 -Release: 21%{?dist} +Release: 22%{?dist} Group: Applications/System License: GPLv2+ @@ -106,6 +106,9 @@ install -p -m 0644 %{SOURCE4} %{SOURCE5} "$RPM_BUILD_ROOT/%{_sysconfdir}/profile %changelog +* Thu Jul 12 2018 Fedora Release Engineering - 1.3-22 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + * Tue Apr 3 2018 Hans Ulrich Niedermann - 1.3-21 - Add CVE-2018-0492 fix. - Behaviour of multiple -f parameters matches documentation now. From 160daf3efb3a8afb2498d09ec9593eb67d2175db Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Tue, 24 Jul 2018 17:01:06 +0200 Subject: [PATCH 22/80] Add missing BuildRequires on gcc make: gcc: Command not found References: https://bugzilla.redhat.com/show_bug.cgi?id=1603473 Signed-off-by: Igor Gnatenko --- beep.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/beep.spec b/beep.spec index a584daf..8f0329d 100644 --- a/beep.spec +++ b/beep.spec @@ -51,6 +51,7 @@ Patch7: 0007-Fix-indentation-if-brace-error.patch # Apply CVE-2018-0492.patch from Debian package Patch8: 0008-Apply-CVE-2018-0492.patch-from-Debian-package.patch +BuildRequires: gcc BuildRequires: glibc-kernheaders From 8ddc3d5483914b7ebf1bad6c3eb78e33ac5fa64f Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 28 Dec 2018 01:38:21 +0100 Subject: [PATCH 23/80] Replace beep's default compiler flags with ours --- beep.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beep.spec b/beep.spec index 8f0329d..22aedb8 100644 --- a/beep.spec +++ b/beep.spec @@ -77,7 +77,7 @@ cp -p %{SOURCE1} README.fedora %build -make %{?_smp_mflags} CFLAGS="${RPM_OPT_FLAGS}" +make %{?_smp_mflags} FLAGS="" CFLAGS="-Wall -Wextra -Werror -std=gnu99 -pedantic ${RPM_OPT_FLAGS}" %install From 4cec4a8fa47e0e48252b15876bb007681b10d9d5 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 28 Dec 2018 04:09:01 +0100 Subject: [PATCH 24/80] 1.3-23: Fix CVE-2018-1000532 and other things --- ...sed-beep.1-file-in-source-repository.patch | 284 +++++++++++++++++ 0011-constrain-freq-and-period-values.patch | 108 +++++++ ...-signed-int-and-unchecked-input-valu.patch | 84 +++++ ...0532-and-mitigate-against-related-is.patch | 298 ++++++++++++++++++ beep.spec | 22 +- 5 files changed, 795 insertions(+), 1 deletion(-) create mode 100644 0009-store-uncompressed-beep.1-file-in-source-repository.patch create mode 100644 0011-constrain-freq-and-period-values.patch create mode 100644 0012-get-rid-of-a-few-signed-int-and-unchecked-input-valu.patch create mode 100644 0013-Fix-CVE-2018-1000532-and-mitigate-against-related-is.patch diff --git a/0009-store-uncompressed-beep.1-file-in-source-repository.patch b/0009-store-uncompressed-beep.1-file-in-source-repository.patch new file mode 100644 index 0000000..e417ca6 --- /dev/null +++ b/0009-store-uncompressed-beep.1-file-in-source-repository.patch @@ -0,0 +1,284 @@ +From 0d386dbdbf6f5dcb4079b07aef0a905c2ebda532 Mon Sep 17 00:00:00 2001 +From: Hans Ulrich Niedermann +Date: Thu, 27 Dec 2018 22:18:37 +0100 +Subject: [PATCH] store uncompressed beep.1 file in source repository + +--- + .gitignore | 3 ++ + Makefile | 17 +++++-- + beep.1 | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++++ + beep.1.gz | Bin 3327 -> 0 bytes + 4 files changed, 155 insertions(+), 4 deletions(-) + create mode 100644 beep.1 + delete mode 100644 beep.1.gz + +diff --git a/.gitignore b/.gitignore +index 4dcdd91..519d235 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -2,3 +2,6 @@ + + # The compiled executable + /beep ++ ++# The compressed man page ++/beep.1.gz +diff --git a/Makefile b/Makefile +index 290b8a4..44035e5 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,7 @@ + CC=gcc + FLAGS=-Wall -O2 + ++GZIP = gzip + INSTALL=install + + EXEC_NAME=beep +@@ -17,15 +18,23 @@ mandir=$(datarootdir)/man + man1dir=$(mandir)/man1 + + .PHONY: all +-all: $(EXEC_NAME) ++all: all-local + +-.PHONY: clean +-clean: +- rm -f $(EXEC_NAME) + ++TARGETS += $(EXEC_NAME) + $(EXEC_NAME): beep.c + $(CC) $(FLAGS) $(CFLAGS) -o $(EXEC_NAME) beep.c + ++TARGETS += $(MAN_FILE) ++$(MAN_FILE): beep.1 ++ $(GZIP) --best -c < $< > $@ ++ ++all-local: $(TARGETS) ++ ++.PHONY: clean ++clean: ++ rm -f $(TARGETS) ++ + install: all + $(INSTALL) -m 0755 -d $(DESTDIR)$(bindir) + $(INSTALL) -m 0755 -p $(EXEC_NAME) $(DESTDIR)$(bindir)/ +diff --git a/beep.1 b/beep.1 +new file mode 100644 +index 0000000..3de05ec +--- /dev/null ++++ b/beep.1 +@@ -0,0 +1,139 @@ ++.TH BEEP 1 "March 2002" ++.SH NAME ++beep \- beep the pc speaker any number of ways ++.SH SYNOPSIS ++.B beep ++[\-f N] [\-l N] [\-r N] [\-d N] [\-D N] [\-s] [\-c] ++.HP ++.B beep ++[ OPTIONS ] [-n] [--new] [ OPTIONS ] ++.HP ++.B beep ++[\-h] [\-\-help] ++.HP ++.B beep ++[\-v] [\-V] [\-\-version] ++.SH DESCRIPTION ++.PP ++\fBbeep\fR allows the user to control the pc-speaker with precision, allowing different sounds to indicate different events. While it can be run quite happily on the command line, it's intended place of residence is within shell/perl scripts, notifying the user when something interesting occurs. Of course, it has no notion of what's interesting, but it's real good at that notifying part. ++.PP ++All options have default values, meaning that just typing '\fBbeep\fR' will work. If an option is specified more than once on the command line, subsequent options override their predecessors. So '\fBbeep\fR \-f 200 \-f 300' will beep at 300Hz. ++.SH OPTIONS ++.TP ++\fB\-f\fR N ++beep at N Hz, where 0 < N < 20000. As a general ballpark, the regular terminal beep is around 750Hz. N is not, incidentally, restricted to whole numbers. ++.TP ++\fB\-l\fR N ++beep for N milliseconds. ++.TP ++\fB\-r\fR N ++specify the number of repetitions (defaults to 1). ++.TP ++\fB\-d\fR N, \fB\-D\fR N ++specify a delay of N milliseconds between repetitions. Use of \-d specifies that this delay should only occur \fIbetween\fR beeps, that is, it should not occur after the last repetition. \-D indicates that the delay should occur after every repetition, including the last. Normally, \-d is what you want, but if, for example, you are stringing several \fBbeep\fR commands together to play the star wars anthem, you may want control over every delay. ++.TP ++\fB\-n\fR, \fB\-\-new\fR ++this option allows you to break the command line up into specifying multiple beeps. Each time this option is used, beep starts treating all further arguments as though they were for a new beep. So for example: ++ ++\fBbeep\fR -f 1000 -n -f 2000 -n -f 1500 ++ ++would produce a sequence of three beeps, the first with a frequency of 1000Hz (and otherwise default values), then a second beep with a frequency of 2000Hz (again, with things like delay and reps being set to their defaults), then a third beep, at 1500Hz. This is different from specifying a -r value, since -r repeats the same beep multiple times, whereas -n allows you to specify different beeps. After a -n, the new beep is created with all the default values, and any of these can be specified without altering values for preceeding (or later) beeps. See the \fBEXAMPLES\fR section if this managed to confuse you. ++.TP ++\fB\-s\fR, \fB\-c\fR ++these options put \fBbeep\fR into input-processing mode. -s tells \fBbeep\fR to read from stdin, and beep after each newline, and -c tells it to do so after every character. In both cases, the program will also echo the input back out to stdout, which makes it easy to slip \fBbeep\fR into a text-processing pipeline, see the \fBEXAMPLES\fR section. ++.TP ++\fB\-h\fR, \fB\-\-help\fR ++display usage info and exit ++.TP ++\fB\-v\fR, \fB\-V\fR, \fB\-\-version\fR ++display version information and exit ++.SH EXAMPLES ++.TP ++At its simplest (yet still effective) ++ ++\fBbeep\fR ++.TP ++A more interesting standalone setup ++ ++\fBbeep\fR -f 300.7 -r 2 -d 100 -l 400 ++.TP ++As part of a log-watching pipeline ++ ++tail -f /var/log/xferlog | grep 'passwd' | \fBbeep\fR -f 1000 -r 5 -s ++.TP ++When using -c mode, I recommend using a short -D, and a shorter -l, so that the beeps don't blur together. Something like this will get you a cheesy 1970's style beep-as-you-type-each-letter effect ++ ++cat file | \fBbeep\fR -c -f 400 -D 50 -l 10 ++ ++.TP ++A highly contrived example of -n/--new usage ++ ++\fBbeep\fR -f 1000 -r 2 -n -r 5 -l 10 --new ++ ++will produce first two 1000Hz beeps, then 5 beeps at the default tone, but only 10ms long each, followed by a third beep using all the default settings (since none are specified). ++.PP See also the \fBFREQUENCY TABLE\fR below. ++ ++.SH IOCTL WACKINESS ++.PP ++Some users will encounter a situation where beep dies with a complaint from ioctl(). The reason for this, as Peter Tirsek was nice enough to point out to me, stems from how the kernel handles beep's attempt to poke at (for non-programmers: ioctl is a sort of catch-all function that lets you poke at things that have no other predefined poking-at mechanism) the tty, which is how it beeps. The short story is, the kernel checks that either: ++.PP ++- you are the superuser ++.PP ++- you own the current tty ++.PP ++What this means is that root can always make beep work (to the best of my knowledge!), and that any local user can make beep work, BUT a non-root remote user cannot use beep in it's natural state. What's worse, an xterm, or other x-session counts, as far as the kernel is concerned, as 'remote', so beep won't work from a non-priviledged xterm either. I had originally chalked this up to a bug, but there's actually nothing I can do about it, and it really is a Good Thing that the kernel does things this way. There is also a solution. ++.PP ++By default beep is not installed with the suid bit set, because that would just be zany. On the other hand, if you do make it suid root, all your problems with beep bailing on ioctl calls will magically vanish, which is pleasant, and the only reason not to is that any suid program is a potential security hole. Conveniently, beep is very short, so auditing it is pretty straightforward. ++.PP ++Decide for yourself, of course, but it looks safe to me - there's only one buffer and fgets doesn't let it overflow, there's only one file opening, and while there is a potential race condition there, it's with /dev/console. If someone can exploit this race by replacing /dev/console, you've got bigger problems. :) ++.PP ++So the quick, only, and likely safe solution if beep is not beeping when you want it to is (as root): ++.PP ++# chmod 4755 /usr/bin/beep ++.PP ++(or wherever you put it) ++.PP ++The one snag is that this will give any little nitwit the ability to run beep successfully - make sure this is what you want. If it isn't, a slightly more complex fix would be something like: ++.PP ++# chgrp beep /usr/bin/beep ++ ++# chmod 4750 /usr/bin/beep ++ ++.PP ++and then add only beep-worthy users to the 'beep' group. ++.SH FREQUENCY TABLE ++.PP ++Several people have asked for some basic help translating music notes to frequencies. There are a lot of music notes, and several tables online will give you translations, but here are \fIapproximate\fR numbers for the octave of middle C, to get you started. ++.PP ++Note Frequency ++.ft CW ++.nf ++C 261.6 ++C# 277.2 ++D 293.7 ++D# 311.1 ++E 329.6 ++F 349.2 ++F# 370.0 ++G 392.0 ++G# 415.3 ++A 440.0 ++A# 466.2 ++B 493.9 ++C 523.2 ++.ft R ++.SH BUGS ++.PP ++None that I'm aware of, though see the \fBIOCTL WACKINESS\fR section. ++.SH REPORTING BUGS ++Report bugs to ++.SH AUTHOR ++.PP ++This program was written by Johnathan Nightingale (johnath@johnath.com) and is distributed under the GNU General Public License. For more contributing information, check the source, and past contributors can be found in CREDITS. ++ ++ ++ ++ ++ ++ ++ +diff --git a/beep.1.gz b/beep.1.gz +deleted file mode 100644 +index 800f92cb6af5c5d41f087e7866a1274dfe21d76c..0000000000000000000000000000000000000000 +GIT binary patch +literal 0 +HcmV?d00001 + +literal 3327 +zcmVViwFo@v7|f#17c-ma4s-*YZNiFPv0gGGtJ#l^knp8JvU{iQm+xVTXV>Zf0H +zlP%QYWODe^V0?F}u1elU&F)ml~Ua)w7&sFhxO*?0Hb +z)%DHY^lmUdm2HFnd>s|)>UV|DGJQ7bGf$uA>C?;K?DxU=@@BhVUEkbKudnVD-i|8% +z8C7P5&+Uun8@`SfA_$+RtiOBtC@+6aOCC+*t*d?)<0o*<%_IK$u~J_awlvBHmFWuFtER2gpRL8>g|2H`u9d6g@XRfjy2@2)D>KA~9S^y| +zRJqAjUFyuxLyhq^Hx<5EFFM*vc^IhNuT4`bpEb4)eyA!JY_X=ko4c+S25a5YaMN65 +zLt5ao%d)niveyOFz@sPt1w90bEa*slEOe(<+B#ITHbi9`qf0e+E>}9>RQ%a0QR^m* +z#Th4Msa#Eg9`YYyGE?Zb4C+yrt%2rCqpPSlB>d5O$XeI@VQ1^d9b6r9R<3z~($fMk +zPC{uGxG=MYh1r&_F%*QiG}#Xg?c13*f41~lrl335}SA%ZpmAd>kq?e%cME#8KKU45zf-_IN +z(rRuh)4;|vU=ap=7|LxLGjB@`D4S+!E1iyp8FWK@s^cSSpdilDn*pA!GGZt|%z8*f +zg~nz9<^qye3kS4DM)2dUu4PZx!Xfn464$ieAbj%v!X_?^K3I!}TYhOwZGw$P-c62| +z06N&~iO5C7P|26`=khf0QtCB@Jy!wO4l4tM_s+nrKYIxqvQ!5PAEAXP@JX0oxVFpz +z4+bMc0Y^`hJRZ+m`(fN>y@W>E0(+(%x(MVGT({J~>{bgXL2m3QVspBAad=M(xT9J3 +zM2O4EHt)ijC(xs=SwtL?KQQ +zGQ{DkXdAh+@GDi1! +za5R|=1}i~9-MG93Q)v}BDUyCzG{$UEh=Xkdj7f^ps%YX;2?`!@`AzN8N{&}pAwXVm +z?4Agz@+5&~LM6!p63m!TI^DKasAsF!#=(Wh5U660j#Qr88IV9`x +z_QFs1bPz*wlR}HeE&JZp3N?pZ0jzCl8+>P!=nzx7*UM<8EfDB?pI8+x9KFO=$1B@Y +zJLsH9DB{d2+Prf!bH~ISiF2M~0jj(jDFs)iFR} +z+L(*^a+D=OR$!FFNA4LfW((bDk^wywh%Z*-H|@C +z2Su~f{UOH_@nNCI5|y8v3#hE+b!qGGEC2|br)MUpZEaF9@qhi&GyI~@fGlun{oHyX +z+1A5rIIM7D5%XljcIV@E=dXPssRZuJNk54sq>4zb8-XZEIvqv&3F|miPnO&Tdf8ng +zkWu8pj0VAh8$6o5KBdK7vB>IIlOWV8*QEnTgA3aFB@Ln`8Xq%u4;Av(0g13wZ$N?~ +z&r7k$sL`r)^U+F&Y|*#!U=Xw|DQN#uH~Uz#|Ag4Zr~0p&gAdeBt-W96JNW)10&dh1 +z;3}tmAt$xsMBt849;zuo%S409JH66O($Hyio}xN_2O>x1knr53bcs)3w%P&C%C^}g +zP)QD5=`GwT0V*KHikOxGZDWAEgLlUh6x2SfQz{#2Kf;O;Dq%BX$c#!8BqGEyg8?cF +zBn7N~e&dXne#1MTt0OV<0a8tL+rrKlsCOh=!?SspwP^WKwJ+^iMB)}&w+ +zw;+}AQe7sCsVb~omzuU|tisM{uuVY}88kS?63Z7U$qpt<g+dle{%ZiB36Ppc|4Hd +znO>jWe^Osg&i*;Qy12WO?uI^=ZY#MKi4;Y6OeEfhHpXDA@kQmF^=L}H03E{CcA3w* +zER?%@k{Vg&Ymco=4Mfh61<8$}> +z+!MWSWlFSSRgS0^rFQ5LtgJ&60EBmm{f0}c~!fyP{J=>Y`0vihsv!=lh4gx_9EMe92OF#%TT6EFHecj +zMGe*I=X+M8@Q@tZn57G5vz(m@^M5R1s@SquIkpy=cA~{3UaXAbipKWgBFG +zQLZDHKXQ(7zt{{SdY8+cG;s;LBysdM0=Y(}GD0B?hq6scANV+3Z}_MyBIyxZdA8wQ +zDH%~`L1$KYiyca)={8X!_6RZ)K^^%GnBd4J0y6rCVLW8{N37zGf)UE1P{Kk6S$xYN +zbF-3sAV-T<982wCgDBL1^VjTg +zHL_d)bD>?$qbJS{ryoM3YZ-NwXp!A^?iJ@*2sQ_X@VYROJk@9esW>M<5}CDZ8syT& +zoa{zu5Z0hN%3udvAYlx@-zv%4)uxge8YQe`P8c>Q>Y1eB@QBxaX+kKz+t1D8 +zKHmFiv1uV=J|07;o2R;THnEe4n#pjX)EO<--z=T{4w!fjpUv!iZniLi;P-ne$%&8u +zY;6YG;g#YISk~ZrVzUnY#9|-teCDY#jO<1gsno}kU2p|qx)=HQuLyD!W$MlG(UID3 +zeX~Ea)xL~?`I?Q97qYlpv&^ONHA5k7;nbK0>RT +zQ3X9?m4e%F0eYvCP%;=7L7jaWjH_aB_UhH)+k^4j!P#H&bbLHM9Gv6f-Rtr3 +z;2b}_J~$X33@-3+_ztT+;Ni_XEc(EA$CL47@DUI14*7te-W(i_Uk^_3@P_YB_|x0B +zSbvHK2z|!`j}Bks7bqw@h<6ErNlAaL4sY;60R6_bF5yk`l6J5-m*gE?ZwUY +z?fvxXV-$XCYL-^Wwc^g7|8NUb5{tj5&oSWrH`#ac`Tp|yHie_`a_Y?y<|~jq2##d* +zkGKz9b;T$FVl+Ik`vb9iF;{a+!~rIp4D_{Co<^@9uRg1fX-a<6&Pssj6H4OBlNLX~ +z)hYU_xHtYc$fh?Q#=0 +Date: Fri, 28 Dec 2018 02:49:01 +0100 +Subject: [PATCH] constrain freq and period values + +We have made sure the freq range was between 0 and 20000 before, +but we now explicitly consider freq and period to be unsigned +integers and thus avoid some integer overflows. + +Also, we avoid giving floating point accuracy for the freq even +while we have always used integer values. For compatibility reasons, +we still accept floating point values for freq, but we now actually +round those floating point values to integers using rintf(3). +--- + Makefile | 2 +- + beep.c | 25 ++++++++++++++----------- + 2 files changed, 15 insertions(+), 12 deletions(-) + +diff --git a/Makefile b/Makefile +index 44035e5..75390e0 100644 +--- a/Makefile ++++ b/Makefile +@@ -23,7 +23,7 @@ all: all-local + + TARGETS += $(EXEC_NAME) + $(EXEC_NAME): beep.c +- $(CC) $(FLAGS) $(CFLAGS) -o $(EXEC_NAME) beep.c ++ $(CC) $(FLAGS) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $(EXEC_NAME) -lm $(LIBADD) beep.c + + TARGETS += $(MAN_FILE) + $(MAN_FILE): beep.1 +diff --git a/beep.c b/beep.c +index f6781e8..2bea6cd 100644 +--- a/beep.c ++++ b/beep.c +@@ -18,7 +18,9 @@ + + #include + #include ++#include + #include ++#include + #include + #include + #include +@@ -45,7 +47,7 @@ + result of this is a tone at approximately the desired frequency. :) + */ + #ifndef CLOCK_TICK_RATE +-#define CLOCK_TICK_RATE 1193180 ++#define CLOCK_TICK_RATE 1193180U + #endif + + #define VERSION_STRING "beep-1.3" +@@ -71,7 +73,7 @@ char *copyright = + #define CHAR_STDIN_BEEP 2 + + typedef struct beep_parms_t { +- float freq; /* tone frequency (Hz) */ ++ unsigned int freq; /* tone frequency (Hz) */ + int length; /* tone length (ms) */ + int reps; /* # of repetitions */ + int delay; /* delay between reps (ms) */ +@@ -97,11 +99,11 @@ int console_type = BEEP_TYPE_CONSOLE; + char *console_device = NULL; + + +-void do_beep(int freq) { +- int period = (freq != 0 ? (int)(CLOCK_TICK_RATE/freq) : freq); ++void do_beep(unsigned int freq) { ++ const uintptr_t argp = (freq != 0 ? (CLOCK_TICK_RATE/freq) : freq) & 0xffff; + + if(console_type == BEEP_TYPE_CONSOLE) { +- if(ioctl(console_fd, KIOCSOUND, period) < 0) { ++ if(ioctl(console_fd, KIOCSOUND, argp) < 0) { + putchar('\a'); /* Output the only beep we can, in an effort to fall back on usefulness */ + perror("ioctl"); + } +@@ -188,14 +190,15 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) { + float argfreq = -1; + switch(c) { + case 'f': /* freq */ +- if(!sscanf(optarg, "%f", &argfreq) || (argfreq >= 20000 /* ack! */) || +- (argfreq <= 0)) ++ if(!sscanf(optarg, "%f", &argfreq) || (argfreq >= 20000.0f /* ack! */) || ++ (argfreq <= 0.0f)) { + usage_bail(argv[0]); +- else { +- if (result->freq != 0) ++ } else { ++ if (result->freq != 0) { + fprintf(stderr, "WARNING: multiple -f values given, only last " + "one is used.\n"); +- result->freq = argfreq; ++ } ++ result->freq = ((unsigned int)rintf(argfreq)); + } + break; + case 'l' : /* length */ +@@ -271,7 +274,7 @@ void play_beep(beep_parms_t parms) { + + if(parms.verbose == 1) + fprintf(stderr, "[DEBUG] %d times %d ms beeps (%d delay between, " +- "%d delay after) @ %.2f Hz\n", ++ "%d delay after) @ %d Hz\n", + parms.reps, parms.length, parms.delay, parms.end_delay, parms.freq); + + /* Beep */ diff --git a/0012-get-rid-of-a-few-signed-int-and-unchecked-input-valu.patch b/0012-get-rid-of-a-few-signed-int-and-unchecked-input-valu.patch new file mode 100644 index 0000000..2fe5143 --- /dev/null +++ b/0012-get-rid-of-a-few-signed-int-and-unchecked-input-valu.patch @@ -0,0 +1,84 @@ +From 60a0d26ba7dc9e6c9456c37dbd892cd56d4a2ddb Mon Sep 17 00:00:00 2001 +From: Hans Ulrich Niedermann +Date: Fri, 28 Dec 2018 03:20:59 +0100 +Subject: [PATCH] get rid of a few signed int and unchecked input value ranges + +--- + beep.c | 25 +++++++++++++------------ + 1 file changed, 13 insertions(+), 12 deletions(-) + +diff --git a/beep.c b/beep.c +index 2bea6cd..b838b85 100644 +--- a/beep.c ++++ b/beep.c +@@ -74,10 +74,10 @@ char *copyright = + + typedef struct beep_parms_t { + unsigned int freq; /* tone frequency (Hz) */ +- int length; /* tone length (ms) */ +- int reps; /* # of repetitions */ +- int delay; /* delay between reps (ms) */ +- int end_delay; /* do we delay after last rep? */ ++ unsigned int length; /* tone length (ms) */ ++ unsigned int reps; /* # of repetitions */ ++ unsigned int delay; /* delay between reps (ms) */ ++ unsigned int end_delay; /* do we delay after last rep? */ + int stdin_beep; /* are we using stdin triggers? We have three options: + - just beep and terminate (default) + - beep after a line of input +@@ -202,19 +202,19 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) { + } + break; + case 'l' : /* length */ +- if(!sscanf(optarg, "%d", &argval) || (argval < 0)) ++ if(!sscanf(optarg, "%d", &argval) || (argval < 0) || (argval > 2100000)) + usage_bail(argv[0]); + else + result->length = argval; + break; + case 'r' : /* repetitions */ +- if(!sscanf(optarg, "%d", &argval) || (argval < 0)) ++ if(!sscanf(optarg, "%d", &argval) || (argval < 0) || (argval > 2100000)) + usage_bail(argv[0]); + else + result->reps = argval; + break; + case 'd' : /* delay between reps - WITHOUT delay after last beep*/ +- if(!sscanf(optarg, "%d", &argval) || (argval < 0)) ++ if(!sscanf(optarg, "%d", &argval) || (argval < 0) || (argval > 2100000)) + usage_bail(argv[0]); + else { + result->delay = argval; +@@ -222,7 +222,7 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) { + } + break; + case 'D' : /* delay between reps - WITH delay after last beep */ +- if(!sscanf(optarg, "%d", &argval) || (argval < 0)) ++ if(!sscanf(optarg, "%d", &argval) || (argval < 0) || (argval > 2100000)) + usage_bail(argv[0]); + else { + result->delay = argval; +@@ -270,7 +270,7 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) { + } + + void play_beep(beep_parms_t parms) { +- int i; /* loop counter */ ++ unsigned int i; /* loop counter */ + + if(parms.verbose == 1) + fprintf(stderr, "[DEBUG] %d times %d ms beeps (%d delay between, " +@@ -281,10 +281,11 @@ void play_beep(beep_parms_t parms) { + for (i = 0; i < parms.reps; i++) { /* start beep */ + do_beep(parms.freq); + /* Look ma, I'm not ansi C compatible! */ +- usleep(1000*parms.length); /* wait... */ ++ usleep(1000U*parms.length); /* wait... */ + do_beep(0); /* stop beep */ +- if(parms.end_delay || (i+1 < parms.reps)) +- usleep(1000*parms.delay); /* wait... */ ++ if (parms.end_delay || ((i+1) < parms.reps)) { ++ usleep(1000U*parms.delay); /* wait... */ ++ } + } /* repeat. */ + } + diff --git a/0013-Fix-CVE-2018-1000532-and-mitigate-against-related-is.patch b/0013-Fix-CVE-2018-1000532-and-mitigate-against-related-is.patch new file mode 100644 index 0000000..03522d3 --- /dev/null +++ b/0013-Fix-CVE-2018-1000532-and-mitigate-against-related-is.patch @@ -0,0 +1,298 @@ +From 10cd5126f320154dccf344e19248c5589d9c20bb Mon Sep 17 00:00:00 2001 +From: Hans Ulrich Niedermann +Date: Fri, 28 Dec 2018 00:10:33 +0100 +Subject: [PATCH] Fix CVE-2018-1000532 and mitigate against related issues + + * Separate initialization including checking for supported APIs + and the main program which just uses the detected API without + any further checks. This helps avoid code paths where code + one API is actually run after initialization for the API. + + * If a device name is given as a command line argument, + only allow device names starting with "/dev/input/". + + * Verify before open(2) that the device name actually refers + to a character device special file by using stat(2). + + * After open(2), verify that console_fd actually + points to a character device special file using fstat(2). + + * Check for API to use on console_fd only once during + initialization using ioctl(2). The two APIs are + + * The console API which uses ioctl(2) KIOCSOUND on console_fd + + * The evdev API which uses write(2) on console_fd + + Then the actual do_beep() function can just do the proper + thing without having to decide between APIs or falling back + or anything. + + * Add "/dev/input/by-path/platform-pcspkr-event-spkr" to + list of console devices to probe by default, so we have + both console API type and evdev API type devices in that + list to help with testing the code for both APIs. +--- + beep.c | 195 +++++++++++++++++++++++++++++++++++++++++++++------------ + 1 file changed, 155 insertions(+), 40 deletions(-) + +diff --git a/beep.c b/beep.c +index b838b85..2a7404e 100644 +--- a/beep.c ++++ b/beep.c +@@ -16,6 +16,7 @@ + * Bug me, I like it: http://johnath.com/ or johnath@johnath.com + */ + ++#include + #include + #include + #include +@@ -26,6 +27,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -90,36 +92,45 @@ typedef struct beep_parms_t { + struct beep_parms_t *next; /* in case -n/--new is used. */ + } beep_parms_t; + +-enum { BEEP_TYPE_CONSOLE, BEEP_TYPE_EVDEV }; +- +-/* Momma taught me never to use globals, but we need something the signal ++/* Use an enum and switch statements to have compiler warn us about ++ * unhandled cases. */ ++typedef enum { ++ /* When the beep_type has not been set yet, do nothing */ ++ BEEP_TYPE_UNSET = 0, ++ /* Use the console API */ ++ BEEP_TYPE_CONSOLE = 1, ++ /* Use the evdev API */ ++ BEEP_TYPE_EVDEV = 2, ++} beep_type_E; ++ ++/* Momma taught me never to use globals, but we need something the signal + handlers can get at.*/ + int console_fd = -1; +-int console_type = BEEP_TYPE_CONSOLE; ++beep_type_E console_type = BEEP_TYPE_UNSET; + char *console_device = NULL; + + + void do_beep(unsigned int freq) { +- const uintptr_t argp = (freq != 0 ? (CLOCK_TICK_RATE/freq) : freq) & 0xffff; ++ switch (console_type) { ++ case BEEP_TYPE_CONSOLE: if (1) { ++ const uintptr_t argp = ((freq != 0) ? (CLOCK_TICK_RATE/freq) : freq) & 0xffff; ++ (void) ioctl(console_fd, KIOCSOUND, argp); ++ } ++ break; ++ case BEEP_TYPE_EVDEV: if (1) { ++ struct input_event e; ++ ++ memset(&e, 0, sizeof(e)); ++ e.type = EV_SND; ++ e.code = SND_TONE; ++ e.value = freq; + +- if(console_type == BEEP_TYPE_CONSOLE) { +- if(ioctl(console_fd, KIOCSOUND, argp) < 0) { +- putchar('\a'); /* Output the only beep we can, in an effort to fall back on usefulness */ +- perror("ioctl"); ++ (void) write(console_fd, &e, sizeof(struct input_event)); + } +- } else { +- /* BEEP_TYPE_EVDEV */ +- struct input_event e; +- +- memset(&e, 0, sizeof(e)); +- e.type = EV_SND; +- e.code = SND_TONE; +- e.value = freq; +- +- if(write(console_fd, &e, sizeof(struct input_event)) < 0) { +- putchar('\a'); /* See above */ +- perror("write"); +- } ++ break; ++ case BEEP_TYPE_UNSET: ++ /* Do nothing, if this case should ever happen which it should not. */ ++ break; + } + } + +@@ -258,7 +269,19 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) { + result->verbose = 1; + break; + case 'e' : /* also --device */ +- console_device = optarg; ++ if (strncmp("/dev/input/", optarg, strlen("/dev/input/")) == 0) { ++ /* If device name starts with /dev/input/, we can assume evdev ++ * input device beeping is wished for and the corresponding ++ * device is somewhere in /dev/input/. Otherwise, the default ++ * console beeper will be used with its default name(s). */ ++ console_device = optarg; ++ } else { ++ fprintf(stderr, "%s: " ++ "Not opening device '%s'. If you do need this device, please " ++ "report that fact to .\n", ++ argv[0], optarg); ++ exit(EXIT_FAILURE); ++ } + break; + case 'h' : /* notice that this is also --help */ + default : +@@ -290,11 +313,42 @@ void play_beep(beep_parms_t parms) { + } + + ++/* Open only character device special file (with race condition). ++ * ++ * We check whether this is a character device special file before ++ * opening as for some devices, opening has an effect and we can avoid ++ * this effect for those devices here. ++ * ++ * We still need to make sure that the file we have actually opened ++ * actually is a character device special file after we have actually ++ * opened it. ++ */ ++int open_chr(const char *const argv0, const char *filename, int flags) ++{ ++ struct stat sb; ++ if (-1 == stat(filename, &sb)) { ++ return -1; ++ } ++ if (S_ISCHR(sb.st_mode)) { ++ return open(filename, flags); ++ } else { ++ fprintf(stderr, "%s: " ++ "console file '%s' is not a character device special file\n", ++ argv0, filename); ++ exit(1); ++ } ++} ++ + + int main(int argc, char **argv) { + char sin[4096], *ptr; +- ++ ++ /* Parse command line */ + beep_parms_t *parms = (beep_parms_t *)malloc(sizeof(beep_parms_t)); ++ if (NULL == parms) { ++ perror("malloc"); ++ exit(1); ++ } + parms->freq = 0; + parms->length = DEFAULT_LENGTH; + parms->reps = DEFAULT_REPS; +@@ -304,29 +358,90 @@ int main(int argc, char **argv) { + parms->verbose = 0; + parms->next = NULL; + +- signal(SIGINT, handle_signal); +- signal(SIGTERM, handle_signal); + parse_command_line(argc, argv, parms); + +- /* try to snag the console */ +- if(console_device) +- console_fd = open(console_device, O_WRONLY); +- else +- if((console_fd = open("/dev/tty0", O_WRONLY)) == -1) +- console_fd = open("/dev/vc/0", O_WRONLY); +- +- if(console_fd == -1) { +- fprintf(stderr, "Could not open %s for writing\n", +- console_device != NULL ? console_device : "/dev/tty0 or /dev/vc/0"); +- printf("\a"); /* Output the only beep we can, in an effort to fall back on usefulness */ +- perror("open"); ++ /* Try opening a console device */ ++ if (console_device) { ++ console_fd = open_chr(argv[0], console_device, O_WRONLY); ++ } else { ++ static char *console_device_list[] = ++ { "/dev/tty0", ++ "/dev/vc/0", ++ "/dev/input/by-path/platform-pcspkr-event-spkr", ++ }; ++ for (size_t i=0; i<(sizeof(console_device_list)/sizeof(console_device_list[0])); ++i) { ++ if ((console_fd = open_chr(argv[0], console_device_list[i], O_WRONLY)) != -1) { ++ console_device = console_device_list[i]; ++ break; ++ } ++ } ++ } ++ ++ if (console_fd == -1) { ++ const int saved_errno = errno; ++ fprintf(stderr, "%s: Could not open %s for writing: %s\n", ++ argv[0], ++ ((console_device != NULL) ? console_device : ++ "console device"), ++ strerror(saved_errno)); ++ /* Output the only beep we can, in an effort to fall back on usefulness */ ++ printf("\a"); + exit(1); + } + +- if (ioctl(console_fd, EVIOCGSND(0)) != -1) ++ /* Verify that console_fd is actually a character device special file */ ++ if (1) { ++ struct stat sb; ++ if (-1 == fstat(console_fd, &sb)) { ++ perror("fstat"); ++ exit(1); ++ } ++ if (S_ISCHR(sb.st_mode)) { ++ /* GOOD: console_fd is a character device special file. Use it. */ ++ } else { ++ /* BAD: console_fd is not a character device special file. Do ++ * not use it any further, and certainly DO NOT WRITE to it. ++ */ ++ fprintf(stderr, ++ "%s: opened console '%s' is not a character special device\n", ++ argv[0], console_device); ++ exit(1); ++ } ++ } ++ ++ /* Determine the API supported by the opened console device */ ++ if (ioctl(console_fd, EVIOCGSND(0)) != -1) { ++ if (parms->verbose) { ++ printf("Using BEEP_TYPE_EVDEV\n"); ++ } + console_type = BEEP_TYPE_EVDEV; +- else ++ } else if (ioctl(console_fd, KIOCSOUND, 0) >= 0) { ++ /* turning off the beeps should be a safe way to check for API support */ ++ if (parms->verbose) { ++ printf("Using BEEP_TYPE_CONSOLE\n"); ++ } + console_type = BEEP_TYPE_CONSOLE; ++ } else { ++ fprintf(stderr, ++ "%s: console device '%s' does not support either API\n", ++ argv[0], console_device); ++ /* Output the only beep we can, in an effort to fall back on usefulness */ ++ printf("\a"); ++ exit(1); ++ } ++ ++ /* At this time, we know what API to use on which device, and we do ++ * not have to fall back onto printing '\a' any more. ++ */ ++ ++ /* After all the initialization has happened and the global ++ * variables used to communicate with the signal handlers have ++ * actually been set up properly, we can finally install the signal ++ * handlers. As we do not start making any noises, there is no need ++ * to install the signal handlers any earlier. ++ */ ++ signal(SIGINT, handle_signal); ++ signal(SIGTERM, handle_signal); + + /* this outermost while loop handles the possibility that -n/--new has been + used, i.e. that we have multiple beeps specified. Each iteration will diff --git a/beep.spec b/beep.spec index 22aedb8..b5857bd 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.3 -Release: 22%{?dist} +Release: 23%{?dist} Group: Applications/System License: GPLv2+ @@ -51,6 +51,22 @@ Patch7: 0007-Fix-indentation-if-brace-error.patch # Apply CVE-2018-0492.patch from Debian package Patch8: 0008-Apply-CVE-2018-0492.patch-from-Debian-package.patch +# store uncompressed beep.1 file in source repository +Patch9: 0009-store-uncompressed-beep.1-file-in-source-repository.patch + +# No sense to add stuff to .gitignore in our source dir +# gitignore: intermediate build results +# Patch10: 0010-gitignore-intermediate-build-results.patch + +# constrain freq and period values +Patch11: 0011-constrain-freq-and-period-values.patch + +# get rid of a few signed int and unchecked input value ranges +Patch12: 0012-get-rid-of-a-few-signed-int-and-unchecked-input-valu.patch + +# Fix CVE-2018-1000532 and mitigate against related issues +Patch13: 0013-Fix-CVE-2018-1000532-and-mitigate-against-related-is.patch + BuildRequires: gcc BuildRequires: glibc-kernheaders @@ -107,6 +123,10 @@ install -p -m 0644 %{SOURCE4} %{SOURCE5} "$RPM_BUILD_ROOT/%{_sysconfdir}/profile %changelog +* Fri Dec 28 2018 Hans Ulrich Niedermann - 1.3-23 +- Fix CVE-2018-1000532 and mitigate against related issues (#1595592) +- Fix a number of potential integer overflows + * Thu Jul 12 2018 Fedora Release Engineering - 1.3-22 - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild From 3159d4c4cd4de91fa400701acde325c416aed520 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 28 Dec 2018 04:13:39 +0100 Subject: [PATCH 25/80] add package.cfg --- package.cfg | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 package.cfg diff --git a/package.cfg b/package.cfg new file mode 100644 index 0000000..6b189b9 --- /dev/null +++ b/package.cfg @@ -0,0 +1,2 @@ +[koji] +targets = master fedora From 46854cdff2dcc4dac97505fa3f789a3abad02661 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 28 Dec 2018 05:42:40 +0100 Subject: [PATCH 26/80] Actually apply the patches, update FSF address --- ...-Update-COPYING-with-new-FSF-address.patch | 138 ++++++++++++++++++ beep.spec | 16 +- 2 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 0014-Update-COPYING-with-new-FSF-address.patch diff --git a/0014-Update-COPYING-with-new-FSF-address.patch b/0014-Update-COPYING-with-new-FSF-address.patch new file mode 100644 index 0000000..d314c4d --- /dev/null +++ b/0014-Update-COPYING-with-new-FSF-address.patch @@ -0,0 +1,138 @@ +From fbadf12841399cce6c218091adc032ad897256de Mon Sep 17 00:00:00 2001 +From: Hans Ulrich Niedermann +Date: Fri, 28 Dec 2018 05:34:54 +0100 +Subject: [PATCH] Update COPYING with new FSF address + +--- + COPYING | 43 +++++++++++++++++++++---------------------- + 1 file changed, 21 insertions(+), 22 deletions(-) + +diff --git a/COPYING b/COPYING +index 60549be..d159169 100644 +--- a/COPYING ++++ b/COPYING +@@ -1,12 +1,12 @@ +- GNU GENERAL PUBLIC LICENSE +- Version 2, June 1991 ++ GNU GENERAL PUBLIC LICENSE ++ Version 2, June 1991 + +- Copyright (C) 1989, 1991 Free Software Foundation, Inc. +- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ Copyright (C) 1989, 1991 Free Software Foundation, Inc., ++ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +- Preamble ++ Preamble + + The licenses for most software are designed to take away your + freedom to share and change it. By contrast, the GNU General Public +@@ -15,7 +15,7 @@ software--to make sure the software is free for all its users. This + General Public License applies to most of the Free Software + Foundation's software and to any other program whose authors commit to + using it. (Some other Free Software Foundation software is covered by +-the GNU Library General Public License instead.) You can apply it to ++the GNU Lesser General Public License instead.) You can apply it to + your programs, too. + + When we speak of free software, we are referring to freedom, not +@@ -55,8 +55,8 @@ patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and + modification follow. +- +- GNU GENERAL PUBLIC LICENSE ++ ++ GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +@@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions: + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) +- ++ + These requirements apply to the modified work as a whole. If + identifiable sections of that work are not derived from the Program, + and can be reasonably considered independent and separate works in +@@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent + access to copy the source code from the same place counts as + distribution of the source code, even though third parties are not + compelled to copy the source along with the object code. +- ++ + 4. You may not copy, modify, sublicense, or distribute the Program + except as expressly provided under this License. Any attempt + otherwise to copy, modify, sublicense or distribute the Program is +@@ -225,7 +225,7 @@ impose that choice. + + This section is intended to make thoroughly clear what is believed to + be a consequence of the rest of this License. +- ++ + 8. If the distribution and/or use of the Program is restricted in + certain countries either by patents or by copyrighted interfaces, the + original copyright holder who places the Program under this License +@@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals + of preserving the free status of all derivatives of our free software and + of promoting the sharing and reuse of software generally. + +- NO WARRANTY ++ NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY + FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +@@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER + PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGES. + +- END OF TERMS AND CONDITIONS +- +- How to Apply These Terms to Your New Programs ++ END OF TERMS AND CONDITIONS ++ ++ How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest + possible use to the public, the best way to achieve this is to make it +@@ -291,7 +291,7 @@ convey the exclusion of warranty; and each file should have at least + the "copyright" line and a pointer to where the full notice is found. + + +- Copyright (C) 19yy ++ Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by +@@ -303,17 +303,16 @@ the "copyright" line and a pointer to where the full notice is found. + 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, write to the Free Software +- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +- ++ You should have received a copy of the GNU General Public License along ++ with this program; if not, write to the Free Software Foundation, Inc., ++ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + Also add information on how to contact you by electronic and paper mail. + + If the program is interactive, make it output a short notice like this + when it starts in an interactive mode: + +- Gnomovision version 69, Copyright (C) 19yy name of author ++ Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. +@@ -336,5 +335,5 @@ necessary. Here is a sample; alter the names: + This General Public License does not permit incorporating your program into + proprietary programs. If your program is a subroutine library, you may + consider it more useful to permit linking proprietary applications with the +-library. If this is what you want to do, use the GNU Library General ++library. If this is what you want to do, use the GNU Lesser General + Public License instead of this License. diff --git a/beep.spec b/beep.spec index b5857bd..ce5fa43 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.3 -Release: 23%{?dist} +Release: 24%{?dist} Group: Applications/System License: GPLv2+ @@ -67,6 +67,9 @@ Patch12: 0012-get-rid-of-a-few-signed-int-and-unchecked-input-valu.patch # Fix CVE-2018-1000532 and mitigate against related issues Patch13: 0013-Fix-CVE-2018-1000532-and-mitigate-against-related-is.patch +# Update COPYING with new FSF address +Patch: 0014-Update-COPYING-with-new-FSF-address.patch + BuildRequires: gcc BuildRequires: glibc-kernheaders @@ -74,7 +77,7 @@ BuildRequires: glibc-kernheaders %description Beep allows the user to control the PC speaker with precision, allowing different sounds to indicate different events. While it -can be run quite happily on the commandline, its intended place +can be run quite happily on the command line, its intended place of residence is within shell/perl scripts, notifying the user when something interesting occurs. Of course, it has no notion of what's interesting, but it's real good at that notifying part. @@ -89,6 +92,11 @@ what's interesting, but it's real good at that notifying part. %patch6 -p1 -b 0006 %patch7 -p1 -b 0007 %patch8 -p1 -b 0008 +%patch9 -p1 -b 0009 +%patch11 -p1 -b 0011 +%patch12 -p1 -b 0012 +%patch13 -p1 -b 0013 +%patch14 -p1 -b 0014 cp -p %{SOURCE1} README.fedora @@ -123,6 +131,10 @@ install -p -m 0644 %{SOURCE4} %{SOURCE5} "$RPM_BUILD_ROOT/%{_sysconfdir}/profile %changelog +* Fri Dec 28 2018 Hans Ulrich Niedermann - 1.3-24 +- Actually apply the patches +- Update COPYING with new FSF address + * Fri Dec 28 2018 Hans Ulrich Niedermann - 1.3-23 - Fix CVE-2018-1000532 and mitigate against related issues (#1595592) - Fix a number of potential integer overflows From 3e20e82c0ee667e9e4d2a625a3cc0821aa6afea4 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 28 Dec 2018 06:07:17 +0100 Subject: [PATCH 27/80] Fix Patch9 to work as non-git patch (do the rest with shell) --- ...sed-beep.1-file-in-source-repository.patch | 88 ------------------- beep.spec | 2 + 2 files changed, 2 insertions(+), 88 deletions(-) diff --git a/0009-store-uncompressed-beep.1-file-in-source-repository.patch b/0009-store-uncompressed-beep.1-file-in-source-repository.patch index e417ca6..d65355f 100644 --- a/0009-store-uncompressed-beep.1-file-in-source-repository.patch +++ b/0009-store-uncompressed-beep.1-file-in-source-repository.patch @@ -4,25 +4,11 @@ Date: Thu, 27 Dec 2018 22:18:37 +0100 Subject: [PATCH] store uncompressed beep.1 file in source repository --- - .gitignore | 3 ++ Makefile | 17 +++++-- beep.1 | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++++ - beep.1.gz | Bin 3327 -> 0 bytes 4 files changed, 155 insertions(+), 4 deletions(-) create mode 100644 beep.1 - delete mode 100644 beep.1.gz -diff --git a/.gitignore b/.gitignore -index 4dcdd91..519d235 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -2,3 +2,6 @@ - - # The compiled executable - /beep -+ -+# The compressed man page -+/beep.1.gz diff --git a/Makefile b/Makefile index 290b8a4..44035e5 100644 --- a/Makefile @@ -208,77 +194,3 @@ index 0000000..3de05ec + + + -diff --git a/beep.1.gz b/beep.1.gz -deleted file mode 100644 -index 800f92cb6af5c5d41f087e7866a1274dfe21d76c..0000000000000000000000000000000000000000 -GIT binary patch -literal 0 -HcmV?d00001 - -literal 3327 -zcmVViwFo@v7|f#17c-ma4s-*YZNiFPv0gGGtJ#l^knp8JvU{iQm+xVTXV>Zf0H -zlP%QYWODe^V0?F}u1elU&F)ml~Ua)w7&sFhxO*?0Hb -z)%DHY^lmUdm2HFnd>s|)>UV|DGJQ7bGf$uA>C?;K?DxU=@@BhVUEkbKudnVD-i|8% -z8C7P5&+Uun8@`SfA_$+RtiOBtC@+6aOCC+*t*d?)<0o*<%_IK$u~J_awlvBHmFWuFtER2gpRL8>g|2H`u9d6g@XRfjy2@2)D>KA~9S^y| -zRJqAjUFyuxLyhq^Hx<5EFFM*vc^IhNuT4`bpEb4)eyA!JY_X=ko4c+S25a5YaMN65 -zLt5ao%d)niveyOFz@sPt1w90bEa*slEOe(<+B#ITHbi9`qf0e+E>}9>RQ%a0QR^m* -z#Th4Msa#Eg9`YYyGE?Zb4C+yrt%2rCqpPSlB>d5O$XeI@VQ1^d9b6r9R<3z~($fMk -zPC{uGxG=MYh1r&_F%*QiG}#Xg?c13*f41~lrl335}SA%ZpmAd>kq?e%cME#8KKU45zf-_IN -z(rRuh)4;|vU=ap=7|LxLGjB@`D4S+!E1iyp8FWK@s^cSSpdilDn*pA!GGZt|%z8*f -zg~nz9<^qye3kS4DM)2dUu4PZx!Xfn464$ieAbj%v!X_?^K3I!}TYhOwZGw$P-c62| -z06N&~iO5C7P|26`=khf0QtCB@Jy!wO4l4tM_s+nrKYIxqvQ!5PAEAXP@JX0oxVFpz -z4+bMc0Y^`hJRZ+m`(fN>y@W>E0(+(%x(MVGT({J~>{bgXL2m3QVspBAad=M(xT9J3 -zM2O4EHt)ijC(xs=SwtL?KQQ -zGQ{DkXdAh+@GDi1! -za5R|=1}i~9-MG93Q)v}BDUyCzG{$UEh=Xkdj7f^ps%YX;2?`!@`AzN8N{&}pAwXVm -z?4Agz@+5&~LM6!p63m!TI^DKasAsF!#=(Wh5U660j#Qr88IV9`x -z_QFs1bPz*wlR}HeE&JZp3N?pZ0jzCl8+>P!=nzx7*UM<8EfDB?pI8+x9KFO=$1B@Y -zJLsH9DB{d2+Prf!bH~ISiF2M~0jj(jDFs)iFR} -z+L(*^a+D=OR$!FFNA4LfW((bDk^wywh%Z*-H|@C -z2Su~f{UOH_@nNCI5|y8v3#hE+b!qGGEC2|br)MUpZEaF9@qhi&GyI~@fGlun{oHyX -z+1A5rIIM7D5%XljcIV@E=dXPssRZuJNk54sq>4zb8-XZEIvqv&3F|miPnO&Tdf8ng -zkWu8pj0VAh8$6o5KBdK7vB>IIlOWV8*QEnTgA3aFB@Ln`8Xq%u4;Av(0g13wZ$N?~ -z&r7k$sL`r)^U+F&Y|*#!U=Xw|DQN#uH~Uz#|Ag4Zr~0p&gAdeBt-W96JNW)10&dh1 -z;3}tmAt$xsMBt849;zuo%S409JH66O($Hyio}xN_2O>x1knr53bcs)3w%P&C%C^}g -zP)QD5=`GwT0V*KHikOxGZDWAEgLlUh6x2SfQz{#2Kf;O;Dq%BX$c#!8BqGEyg8?cF -zBn7N~e&dXne#1MTt0OV<0a8tL+rrKlsCOh=!?SspwP^WKwJ+^iMB)}&w+ -zw;+}AQe7sCsVb~omzuU|tisM{uuVY}88kS?63Z7U$qpt<g+dle{%ZiB36Ppc|4Hd -znO>jWe^Osg&i*;Qy12WO?uI^=ZY#MKi4;Y6OeEfhHpXDA@kQmF^=L}H03E{CcA3w* -zER?%@k{Vg&Ymco=4Mfh61<8$}> -z+!MWSWlFSSRgS0^rFQ5LtgJ&60EBmm{f0}c~!fyP{J=>Y`0vihsv!=lh4gx_9EMe92OF#%TT6EFHecj -zMGe*I=X+M8@Q@tZn57G5vz(m@^M5R1s@SquIkpy=cA~{3UaXAbipKWgBFG -zQLZDHKXQ(7zt{{SdY8+cG;s;LBysdM0=Y(}GD0B?hq6scANV+3Z}_MyBIyxZdA8wQ -zDH%~`L1$KYiyca)={8X!_6RZ)K^^%GnBd4J0y6rCVLW8{N37zGf)UE1P{Kk6S$xYN -zbF-3sAV-T<982wCgDBL1^VjTg -zHL_d)bD>?$qbJS{ryoM3YZ-NwXp!A^?iJ@*2sQ_X@VYROJk@9esW>M<5}CDZ8syT& -zoa{zu5Z0hN%3udvAYlx@-zv%4)uxge8YQe`P8c>Q>Y1eB@QBxaX+kKz+t1D8 -zKHmFiv1uV=J|07;o2R;THnEe4n#pjX)EO<--z=T{4w!fjpUv!iZniLi;P-ne$%&8u -zY;6YG;g#YISk~ZrVzUnY#9|-teCDY#jO<1gsno}kU2p|qx)=HQuLyD!W$MlG(UID3 -zeX~Ea)xL~?`I?Q97qYlpv&^ONHA5k7;nbK0>RT -zQ3X9?m4e%F0eYvCP%;=7L7jaWjH_aB_UhH)+k^4j!P#H&bbLHM9Gv6f-Rtr3 -z;2b}_J~$X33@-3+_ztT+;Ni_XEc(EA$CL47@DUI14*7te-W(i_Uk^_3@P_YB_|x0B -zSbvHK2z|!`j}Bks7bqw@h<6ErNlAaL4sY;60R6_bF5yk`l6J5-m*gE?ZwUY -z?fvxXV-$XCYL-^Wwc^g7|8NUb5{tj5&oSWrH`#ac`Tp|yHie_`a_Y?y<|~jq2##d* -zkGKz9b;T$FVl+Ik`vb9iF;{a+!~rIp4D_{Co<^@9uRg1fX-a<6&Pssj6H4OBlNLX~ -z)hYU_xHtYc$fh?Q#=0 - 1.3-24 - Actually apply the patches - Update COPYING with new FSF address +- Fix Patch9 to work as non-git patch (do the rest with shell) * Fri Dec 28 2018 Hans Ulrich Niedermann - 1.3-23 - Fix CVE-2018-1000532 and mitigate against related issues (#1595592) From f52e0c5d042f8e761af9da5666e2063b150c8040 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 28 Dec 2018 06:08:24 +0100 Subject: [PATCH 28/80] Proper naming of Patch14 --- beep.spec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/beep.spec b/beep.spec index adb71fd..2570038 100644 --- a/beep.spec +++ b/beep.spec @@ -68,7 +68,7 @@ Patch12: 0012-get-rid-of-a-few-signed-int-and-unchecked-input-valu.patch Patch13: 0013-Fix-CVE-2018-1000532-and-mitigate-against-related-is.patch # Update COPYING with new FSF address -Patch: 0014-Update-COPYING-with-new-FSF-address.patch +Patch14: 0014-Update-COPYING-with-new-FSF-address.patch BuildRequires: gcc BuildRequires: glibc-kernheaders @@ -136,6 +136,7 @@ install -p -m 0644 %{SOURCE4} %{SOURCE5} "$RPM_BUILD_ROOT/%{_sysconfdir}/profile - Actually apply the patches - Update COPYING with new FSF address - Fix Patch9 to work as non-git patch (do the rest with shell) +- Proper naming of Patch14 * Fri Dec 28 2018 Hans Ulrich Niedermann - 1.3-23 - Fix CVE-2018-1000532 and mitigate against related issues (#1595592) From 83ca10bffe87755d295b8335be7e73dcddabd703 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 28 Dec 2018 06:08:50 +0100 Subject: [PATCH 29/80] Exit beep when error accessing API --- ...eep-sees-error-from-API-exit-program.patch | 39 +++++++++++++++++++ beep.spec | 6 +++ 2 files changed, 45 insertions(+) create mode 100644 0015-If-do_beep-sees-error-from-API-exit-program.patch diff --git a/0015-If-do_beep-sees-error-from-API-exit-program.patch b/0015-If-do_beep-sees-error-from-API-exit-program.patch new file mode 100644 index 0000000..a91c4aa --- /dev/null +++ b/0015-If-do_beep-sees-error-from-API-exit-program.patch @@ -0,0 +1,39 @@ +From d419a0daa59a3afbbc14354feed2701ed2109afb Mon Sep 17 00:00:00 2001 +From: Hans Ulrich Niedermann +Date: Fri, 28 Dec 2018 06:01:10 +0100 +Subject: [PATCH] If do_beep() sees error from API, exit program + +--- + beep.c | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +diff --git a/beep.c b/beep.c +index 2a7404e..1b9d8ca 100644 +--- a/beep.c ++++ b/beep.c +@@ -114,7 +114,11 @@ void do_beep(unsigned int freq) { + switch (console_type) { + case BEEP_TYPE_CONSOLE: if (1) { + const uintptr_t argp = ((freq != 0) ? (CLOCK_TICK_RATE/freq) : freq) & 0xffff; +- (void) ioctl(console_fd, KIOCSOUND, argp); ++ if (-1 == ioctl(console_fd, KIOCSOUND, argp)) { ++ /* If we cannot use the sound API, we cannot silence the sound either */ ++ perror("ioctl KIOCSOUND"); ++ exit(1); ++ } + } + break; + case BEEP_TYPE_EVDEV: if (1) { +@@ -125,7 +129,11 @@ void do_beep(unsigned int freq) { + e.code = SND_TONE; + e.value = freq; + +- (void) write(console_fd, &e, sizeof(struct input_event)); ++ if (sizeof(e) != write(console_fd, &e, sizeof(e))) { ++ /* If we cannot use the sound API, we cannot silence the sound either */ ++ perror("write EV_SND"); ++ exit(1); ++ } + } + break; + case BEEP_TYPE_UNSET: diff --git a/beep.spec b/beep.spec index 2570038..a31d1d5 100644 --- a/beep.spec +++ b/beep.spec @@ -70,6 +70,10 @@ Patch13: 0013-Fix-CVE-2018-1000532-and-mitigate-against-related-is.patch # Update COPYING with new FSF address Patch14: 0014-Update-COPYING-with-new-FSF-address.patch +# If do_beep() sees error from API, exit program +Patch15: 0015-If-do_beep-sees-error-from-API-exit-program.patch + + BuildRequires: gcc BuildRequires: glibc-kernheaders @@ -98,6 +102,7 @@ rm -f beep.1.gz %patch12 -p1 -b 0012 %patch13 -p1 -b 0013 %patch14 -p1 -b 0014 +%patch15 -p1 -b 0015 cp -p %{SOURCE1} README.fedora @@ -137,6 +142,7 @@ install -p -m 0644 %{SOURCE4} %{SOURCE5} "$RPM_BUILD_ROOT/%{_sysconfdir}/profile - Update COPYING with new FSF address - Fix Patch9 to work as non-git patch (do the rest with shell) - Proper naming of Patch14 +- Exit beep when error accessing API * Fri Dec 28 2018 Hans Ulrich Niedermann - 1.3-23 - Fix CVE-2018-1000532 and mitigate against related issues (#1595592) From 9e5d2cb25f760ab116f33a797cea8d2f7e4308ff Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 28 Dec 2018 06:46:42 +0100 Subject: [PATCH 30/80] clean up and ignore some rpmlint issues --- beep.rpmlintrc | 9 +++++++++ beep.spec | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 beep.rpmlintrc diff --git a/beep.rpmlintrc b/beep.rpmlintrc new file mode 100644 index 0000000..8b88d58 --- /dev/null +++ b/beep.rpmlintrc @@ -0,0 +1,9 @@ +# -*- python -*- + +addFilter(r'name-repeated-in-summary C Beep') +addFilter(r'non-readable /etc/sudoers.d/beep 600') + +# Not sure what to do about those +# addFilter(r'conffile-without-noreplace-flag /etc/profile.d/beep.csh') +# addFilter(r'conffile-without-noreplace-flag /etc/profile.d/beep.csh') + diff --git a/beep.spec b/beep.spec index a31d1d5..50b4ef7 100644 --- a/beep.spec +++ b/beep.spec @@ -82,7 +82,7 @@ BuildRequires: glibc-kernheaders Beep allows the user to control the PC speaker with precision, allowing different sounds to indicate different events. While it can be run quite happily on the command line, its intended place -of residence is within shell/perl scripts, notifying the user when +of residence is within shell/Perl scripts, notifying the user when something interesting occurs. Of course, it has no notion of what's interesting, but it's real good at that notifying part. From 1ddc1b225087405e62e4e11ebe4b754a6f085578 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sat, 29 Dec 2018 05:29:26 +0100 Subject: [PATCH 31/80] 1.3-26: Use new beep group evdev device based permissions Also refuse to run via setuid or sudo to avoid security risks. --- ...e-evdev-device-the-first-to-look-for.patch | 28 ++++ 0017-Use-realpath-3-on-device-name.patch | 75 ++++++++++ ...when-setuid-or-setgid-usage-detected.patch | 37 +++++ ...d-setuid-setgid-check-output-newline.patch | 39 +++++ 0020-refuse-to-run-under-sudo.patch | 29 ++++ ...vice-in-verbose-message-on-BEEP_TYPE.patch | 29 ++++ ...restructure-device-whitelisting-code.patch | 98 +++++++++++++ ...DME-beep.1-remove-setuid-suggestions.patch | 136 ++++++++++++++++++ 90-pcspkr-beep.rules | 2 + README-packaging.md | 9 ++ beep-README.fedora | 119 ++++++--------- beep.rpmlintrc | 6 - beep.spec | 67 +++++++-- 13 files changed, 584 insertions(+), 90 deletions(-) create mode 100644 0016-Make-the-evdev-device-the-first-to-look-for.patch create mode 100644 0017-Use-realpath-3-on-device-name.patch create mode 100644 0018-refuse-to-run-when-setuid-or-setgid-usage-detected.patch create mode 100644 0019-add-setuid-setgid-check-output-newline.patch create mode 100644 0020-refuse-to-run-under-sudo.patch create mode 100644 0021-print-console_device-in-verbose-message-on-BEEP_TYPE.patch create mode 100644 0022-restructure-device-whitelisting-code.patch create mode 100644 0023-README-beep.1-remove-setuid-suggestions.patch create mode 100644 90-pcspkr-beep.rules create mode 100644 README-packaging.md diff --git a/0016-Make-the-evdev-device-the-first-to-look-for.patch b/0016-Make-the-evdev-device-the-first-to-look-for.patch new file mode 100644 index 0000000..ec8ceb2 --- /dev/null +++ b/0016-Make-the-evdev-device-the-first-to-look-for.patch @@ -0,0 +1,28 @@ +From fabfacd13d915c9b4f062b0ad08066d8e5119701 Mon Sep 17 00:00:00 2001 +From: Hans Ulrich Niedermann +Date: Fri, 28 Dec 2018 22:27:12 +0100 +Subject: [PATCH] Make the evdev device the first to look for + +If the evdev device has been set user writable, that will +make beep beep without trying any other devices and root-only +APIs. +--- + beep.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/beep.c b/beep.c +index 1b9d8ca..29f0941 100644 +--- a/beep.c ++++ b/beep.c +@@ -373,9 +373,9 @@ int main(int argc, char **argv) { + console_fd = open_chr(argv[0], console_device, O_WRONLY); + } else { + static char *console_device_list[] = +- { "/dev/tty0", ++ { "/dev/input/by-path/platform-pcspkr-event-spkr", ++ "/dev/tty0", + "/dev/vc/0", +- "/dev/input/by-path/platform-pcspkr-event-spkr", + }; + for (size_t i=0; i<(sizeof(console_device_list)/sizeof(console_device_list[0])); ++i) { + if ((console_fd = open_chr(argv[0], console_device_list[i], O_WRONLY)) != -1) { diff --git a/0017-Use-realpath-3-on-device-name.patch b/0017-Use-realpath-3-on-device-name.patch new file mode 100644 index 0000000..3914e36 --- /dev/null +++ b/0017-Use-realpath-3-on-device-name.patch @@ -0,0 +1,75 @@ +From 9d2d0c1ac754a39711143ba85ac451d989ef0517 Mon Sep 17 00:00:00 2001 +From: Hans Ulrich Niedermann +Date: Fri, 28 Dec 2018 22:28:20 +0100 +Subject: [PATCH] Use realpath(3) on device name + +Also allow the standard devices + + /dev/console + /dev/tty0 + /dev/vc/0 + +when given explicitly on the command line. +--- + beep.c | 41 +++++++++++++++++++++++++++++------------ + 1 file changed, 29 insertions(+), 12 deletions(-) + +diff --git a/beep.c b/beep.c +index 29f0941..17115f7 100644 +--- a/beep.c ++++ b/beep.c +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -277,18 +278,34 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) { + result->verbose = 1; + break; + case 'e' : /* also --device */ +- if (strncmp("/dev/input/", optarg, strlen("/dev/input/")) == 0) { +- /* If device name starts with /dev/input/, we can assume evdev +- * input device beeping is wished for and the corresponding +- * device is somewhere in /dev/input/. Otherwise, the default +- * console beeper will be used with its default name(s). */ +- console_device = optarg; +- } else { +- fprintf(stderr, "%s: " +- "Not opening device '%s'. If you do need this device, please " +- "report that fact to .\n", +- argv[0], optarg); +- exit(EXIT_FAILURE); ++ if (1) { ++ static char realpath_optarg[PATH_MAX+1]; ++ if (realpath(optarg, realpath_optarg) == NULL) { ++ const int saved_errno = errno; ++ fprintf(stderr, "%s: " ++ "could not run realpath(3) on '%s': %s\n", ++ argv[0], optarg, strerror(saved_errno)); ++ exit(EXIT_FAILURE); ++ } ++ if (strncmp("/dev/input/", realpath_optarg, strlen("/dev/input/")) == 0) { ++ /* If device name starts with /dev/input/, we can assume evdev ++ * input device beeping is wished for and the corresponding ++ * device is somewhere in /dev/input/. Otherwise, the default ++ * console beeper will be used with its default name(s). */ ++ console_device = realpath_optarg; ++ } else if (strcmp("/dev/console", realpath_optarg) == 0) { ++ console_device = realpath_optarg; ++ } else if (strcmp("/dev/tty0", realpath_optarg) == 0) { ++ console_device = realpath_optarg; ++ } else if (strcmp("/dev/vc/0", realpath_optarg) == 0) { ++ console_device = realpath_optarg; ++ } else { ++ fprintf(stderr, "%s: " ++ "Not using device '%s'. If you do need this device, please " ++ "report that fact to .\n", ++ argv[0], optarg); ++ exit(EXIT_FAILURE); ++ } + } + break; + case 'h' : /* notice that this is also --help */ diff --git a/0018-refuse-to-run-when-setuid-or-setgid-usage-detected.patch b/0018-refuse-to-run-when-setuid-or-setgid-usage-detected.patch new file mode 100644 index 0000000..18ac9c2 --- /dev/null +++ b/0018-refuse-to-run-when-setuid-or-setgid-usage-detected.patch @@ -0,0 +1,37 @@ +From 67ab66e3201c35b37c2fcabb6b4faeecfee27806 Mon Sep 17 00:00:00 2001 +From: Hans Ulrich Niedermann +Date: Fri, 28 Dec 2018 22:26:05 +0100 +Subject: [PATCH] refuse to run when setuid or setgid usage detected + +Bail out without doing anything when + + getuid() != geteuid() + +or + + getgit() != getegid() + +hoping this catches all setuid-root or setgid-root invocations. +--- + beep.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/beep.c b/beep.c +index 17115f7..64512b6 100644 +--- a/beep.c ++++ b/beep.c +@@ -368,6 +368,14 @@ int open_chr(const char *const argv0, const char *filename, int flags) + int main(int argc, char **argv) { + char sin[4096], *ptr; + ++ /* bail out if running setuid or setgid */ ++ if ((getuid() != geteuid()) || (getgid() != getegid())) { ++ fprintf(stderr, "%s: " ++ "running setuid or setgid, which is not supported for security reasons", ++ argv[0]); ++ exit(1); ++ } ++ + /* Parse command line */ + beep_parms_t *parms = (beep_parms_t *)malloc(sizeof(beep_parms_t)); + if (NULL == parms) { diff --git a/0019-add-setuid-setgid-check-output-newline.patch b/0019-add-setuid-setgid-check-output-newline.patch new file mode 100644 index 0000000..819d16f --- /dev/null +++ b/0019-add-setuid-setgid-check-output-newline.patch @@ -0,0 +1,39 @@ +From f30015eb60f83359f3caef95ef1484410a7bd138 Mon Sep 17 00:00:00 2001 +From: Hans Ulrich Niedermann +Date: Sat, 29 Dec 2018 01:48:29 +0100 +Subject: [PATCH] add setuid/setgid check output newline + +Also adds a few comments about that check and prints +the UIDs and GIDs involved in the issue. +--- + beep.c | 15 +++++++++++++-- + 1 file changed, 13 insertions(+), 2 deletions(-) + +diff --git a/beep.c b/beep.c +index 64512b6..a72b4e1 100644 +--- a/beep.c ++++ b/beep.c +@@ -368,10 +368,21 @@ int open_chr(const char *const argv0, const char *filename, int flags) + int main(int argc, char **argv) { + char sin[4096], *ptr; + +- /* bail out if running setuid or setgid */ ++ /* Bail out if running setuid or setgid. ++ * ++ * It is near impossible to make beep setuid-safe: ++ * ++ * * We open files for writing, and may even write to them. ++ * ++ * * Checking the device file with realpath leaks information. ++ * ++ * So we refuse running setuid or setgid. ++ */ + if ((getuid() != geteuid()) || (getgid() != getegid())) { ++ fprintf(stderr, "%s: uid=%d euid=%d gid=%d egid=%d\n", ++ argv[0], getuid(), geteuid(), getgid(), getegid()); + fprintf(stderr, "%s: " +- "running setuid or setgid, which is not supported for security reasons", ++ "running setuid or setgid, which is not supported for security reasons\n", + argv[0]); + exit(1); + } diff --git a/0020-refuse-to-run-under-sudo.patch b/0020-refuse-to-run-under-sudo.patch new file mode 100644 index 0000000..37265d2 --- /dev/null +++ b/0020-refuse-to-run-under-sudo.patch @@ -0,0 +1,29 @@ +From 8f1faeee39864d2d147df52b8519a5ae4d2320b0 Mon Sep 17 00:00:00 2001 +From: Hans Ulrich Niedermann +Date: Sat, 29 Dec 2018 03:39:48 +0100 +Subject: [PATCH] refuse to run under sudo + +--- + beep.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/beep.c b/beep.c +index a72b4e1..17eeaa5 100644 +--- a/beep.c ++++ b/beep.c +@@ -387,6 +387,15 @@ int main(int argc, char **argv) { + exit(1); + } + ++ /* Bail out if running under sudo. ++ * ++ * For the reasoning, see the setuid comment above. ++ */ ++ if (getenv("SUDO_COMMAND") || getenv("SUDO_USER") || getenv("SUDO_UID") || getenv("SUDO_GID")) { ++ fprintf(stderr, "%s: Running under sudo. Set up permissions for /dev/input/by-path/platform-pcspkr-event-spkr instead.\n", argv[0]); ++ exit(1); ++ } ++ + /* Parse command line */ + beep_parms_t *parms = (beep_parms_t *)malloc(sizeof(beep_parms_t)); + if (NULL == parms) { diff --git a/0021-print-console_device-in-verbose-message-on-BEEP_TYPE.patch b/0021-print-console_device-in-verbose-message-on-BEEP_TYPE.patch new file mode 100644 index 0000000..255bebb --- /dev/null +++ b/0021-print-console_device-in-verbose-message-on-BEEP_TYPE.patch @@ -0,0 +1,29 @@ +From e04c6badef5c71c5a1d17f87928990e7e5130533 Mon Sep 17 00:00:00 2001 +From: Hans Ulrich Niedermann +Date: Sat, 29 Dec 2018 00:49:14 +0100 +Subject: [PATCH] print console_device in verbose message on BEEP_TYPE_ + +--- + beep.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/beep.c b/beep.c +index 17eeaa5..3be5f0b 100644 +--- a/beep.c ++++ b/beep.c +@@ -465,13 +465,13 @@ int main(int argc, char **argv) { + /* Determine the API supported by the opened console device */ + if (ioctl(console_fd, EVIOCGSND(0)) != -1) { + if (parms->verbose) { +- printf("Using BEEP_TYPE_EVDEV\n"); ++ printf("Using BEEP_TYPE_EVDEV on '%s'\n", console_device); + } + console_type = BEEP_TYPE_EVDEV; + } else if (ioctl(console_fd, KIOCSOUND, 0) >= 0) { + /* turning off the beeps should be a safe way to check for API support */ + if (parms->verbose) { +- printf("Using BEEP_TYPE_CONSOLE\n"); ++ printf("Using BEEP_TYPE_CONSOLE on '%s'\n", console_device); + } + console_type = BEEP_TYPE_CONSOLE; + } else { diff --git a/0022-restructure-device-whitelisting-code.patch b/0022-restructure-device-whitelisting-code.patch new file mode 100644 index 0000000..4c3f923 --- /dev/null +++ b/0022-restructure-device-whitelisting-code.patch @@ -0,0 +1,98 @@ +From 0542134f05df18219ec575026e9e6c31ae98fbee Mon Sep 17 00:00:00 2001 +From: Hans Ulrich Niedermann +Date: Sat, 29 Dec 2018 01:11:59 +0100 +Subject: [PATCH] restructure device whitelisting code + +We now allow + + /dev/input/** + /dev/console + /dev/tty + /dev/vc/ + +where is an arbitrary sequence of decimal digits. +--- + beep.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++------------ + 1 file changed, 46 insertions(+), 12 deletions(-) + +diff --git a/beep.c b/beep.c +index 3be5f0b..10a3349 100644 +--- a/beep.c ++++ b/beep.c +@@ -174,6 +174,50 @@ void usage_bail(const char *executable_name) { + } + + ++/* whether character is a digit */ ++int is_digit(char c) ++{ ++ return (('0' <= c) && (c <= '9')); ++} ++ ++ ++/* whether string consists of at least one digit, and only digits */ ++int is_number(const char *const str) ++{ ++ if (str[0] == '\0') { ++ return 0; ++ } ++ for (size_t i=0; str[i] != '\0'; ++i) { ++ if (!is_digit(str[i])) { ++ return 0; ++ } ++ } ++ return 1; ++} ++ ++ ++/* whether device is on whitelist */ ++int is_device_whitelisted(const char *const dev) ++{ ++ if (strncmp("/dev/input/", dev, strlen("/dev/input/")) == 0) { ++ /* If device name starts with /dev/input/, we can assume evdev ++ * input device beeping is wished for and the corresponding ++ * device is somewhere in /dev/input/. ++ */ ++ return 1; ++ } else if (strcmp("/dev/console", dev) == 0) { ++ return 1; ++ } else if ((strncmp("/dev/tty", dev, 8) == 0) && is_number(&dev[8])) { ++ /* match numbered /dev/tty devices */ ++ return 1; ++ } else if ((strncmp("/dev/vc/", dev, 8) == 0) && is_number(&dev[8])) { ++ /* match numbered /dev/vc/ devices */ ++ return 1; ++ } ++ return 0; ++} ++ ++ + /* Parse the command line. argv should be untampered, as passed to main. + * Beep parameters returned in result, subsequent parameters in argv will over- + * ride previous ones. +@@ -287,23 +331,13 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) { + argv[0], optarg, strerror(saved_errno)); + exit(EXIT_FAILURE); + } +- if (strncmp("/dev/input/", realpath_optarg, strlen("/dev/input/")) == 0) { +- /* If device name starts with /dev/input/, we can assume evdev +- * input device beeping is wished for and the corresponding +- * device is somewhere in /dev/input/. Otherwise, the default +- * console beeper will be used with its default name(s). */ +- console_device = realpath_optarg; +- } else if (strcmp("/dev/console", realpath_optarg) == 0) { +- console_device = realpath_optarg; +- } else if (strcmp("/dev/tty0", realpath_optarg) == 0) { +- console_device = realpath_optarg; +- } else if (strcmp("/dev/vc/0", realpath_optarg) == 0) { ++ if (is_device_whitelisted(realpath_optarg)) { + console_device = realpath_optarg; + } else { + fprintf(stderr, "%s: " + "Not using device '%s'. If you do need this device, please " + "report that fact to .\n", +- argv[0], optarg); ++ argv[0], realpath_optarg); + exit(EXIT_FAILURE); + } + } diff --git a/0023-README-beep.1-remove-setuid-suggestions.patch b/0023-README-beep.1-remove-setuid-suggestions.patch new file mode 100644 index 0000000..663cb1e --- /dev/null +++ b/0023-README-beep.1-remove-setuid-suggestions.patch @@ -0,0 +1,136 @@ +From f8c6cbbceb3776aa64397cdf856e50f3bc4d8332 Mon Sep 17 00:00:00 2001 +From: Hans Ulrich Niedermann +Date: Sat, 29 Dec 2018 05:07:30 +0100 +Subject: [PATCH] README, beep.1; remove setuid suggestions + +--- + README | 54 ++++++------------------------------------------------ + beep.1 | 35 ++--------------------------------- + 2 files changed, 8 insertions(+), 81 deletions(-) + +diff --git a/README b/README +index f4db57b..7a97a0c 100644 +--- a/README ++++ b/README +@@ -1,6 +1,8 @@ + Intro + ----- + ++ [ This file partially contains outdated information ] ++ + I just got so tired of being limited to printf("\a"); when I wanted a terminal + beep. This program isn't supposed to be anything stupendous, it's just + supposed to get the job done. Its intended purpose in life is to live inside +@@ -25,54 +27,10 @@ There is a github repository of this code at: git://github.com/johnath/beep.git + A note about ioctl + ------------------ + +-As noted in the man page, some users are running into a situation where beep +-dies with a complaint from ioctl(). The reason for this, as Peter Tirsek was +-nice enough to point out to me, stems from how the kernel handles beep's +-attempt to poke at (for non-programmers: ioctl is a sort of catch-all function +-that lets you poke at things that have no other predefined poking-at mechanism) +-the tty, which is how it beeps. The short story is, the kernel checks that +-either: +- +-- you are the superuser +-- you own the current tty +- +-What this means is that root can always make beep work (to the best of my +-knowledge!), and that any local user can make beep work, BUT a non-root remote +-user cannot use beep in it's natural state. What's worse, an xterm, or other +-x-session counts, as far as the kernel is concerned, as 'remote', so beep +-won't work from a non-priviledged xterm either. I had originally chalked this +-up to a bug, but there's actually nothing I can do about it, and it really is +-a Good Thing that the kernel does things this way. There is also a solution. +- +-By default beep is not installed with the suid bit set, because that would +-just be zany. On the other hand, if you do make it suid root, all your +-problems with beep bailing on ioctl calls will magically vanish, which is +-pleasant, and the only reason not to is that any suid program is a potential +-security hole. Conveniently, beep is very short, so auditing it is pretty +-straightforward. +- +-Decide for yourself, of course, but it looks safe to me - there's only one +-buffer and fgets doesn't let it overflow, there's only one file opening, and +-while there is a potential race condition there, it's with /dev/console. If +-someone can exploit this race by replacing /dev/console, you've got bigger +-problems. :) +- +-So the quick solution is beep is not beeping when you want it to is: +- +-$ su +-Password: +-# chmod 4755 /usr/bin/beep +- +-(or wherever you put it) +- +-The one snag is that this will give any little nitwit the ability to run beep +-successfully - make sure this is what you want. If it isn't, a slightly more +-complex fix would be something like: +- +-# chgrp beep /usr/bin/beep +-# chmod 4750 /usr/bin/beep +- +-and then add only beep-worthy users to the 'beep' group. ++ [ Section removed for suggesting making `beep` suid root. A new ++ section on `beep` and permissions will be added soon -- ++ without any setuid or sudo priviledge escalation risks. ] ++ + + Playing Songs + ------------- +diff --git a/beep.1 b/beep.1 +index 3de05ec..5b19409 100644 +--- a/beep.1 ++++ b/beep.1 +@@ -75,32 +75,8 @@ will produce first two 1000Hz beeps, then 5 beeps at the default tone, but only + + .SH IOCTL WACKINESS + .PP +-Some users will encounter a situation where beep dies with a complaint from ioctl(). The reason for this, as Peter Tirsek was nice enough to point out to me, stems from how the kernel handles beep's attempt to poke at (for non-programmers: ioctl is a sort of catch-all function that lets you poke at things that have no other predefined poking-at mechanism) the tty, which is how it beeps. The short story is, the kernel checks that either: +-.PP +-- you are the superuser +-.PP +-- you own the current tty +-.PP +-What this means is that root can always make beep work (to the best of my knowledge!), and that any local user can make beep work, BUT a non-root remote user cannot use beep in it's natural state. What's worse, an xterm, or other x-session counts, as far as the kernel is concerned, as 'remote', so beep won't work from a non-priviledged xterm either. I had originally chalked this up to a bug, but there's actually nothing I can do about it, and it really is a Good Thing that the kernel does things this way. There is also a solution. +-.PP +-By default beep is not installed with the suid bit set, because that would just be zany. On the other hand, if you do make it suid root, all your problems with beep bailing on ioctl calls will magically vanish, which is pleasant, and the only reason not to is that any suid program is a potential security hole. Conveniently, beep is very short, so auditing it is pretty straightforward. +-.PP +-Decide for yourself, of course, but it looks safe to me - there's only one buffer and fgets doesn't let it overflow, there's only one file opening, and while there is a potential race condition there, it's with /dev/console. If someone can exploit this race by replacing /dev/console, you've got bigger problems. :) +-.PP +-So the quick, only, and likely safe solution if beep is not beeping when you want it to is (as root): +-.PP +-# chmod 4755 /usr/bin/beep +-.PP +-(or wherever you put it) +-.PP +-The one snag is that this will give any little nitwit the ability to run beep successfully - make sure this is what you want. If it isn't, a slightly more complex fix would be something like: +-.PP +-# chgrp beep /usr/bin/beep ++Section removed for suggesting making \fBbeep\fR suid root. A new section on \fBbeep\fR and permissions will be added soon \-\- without any setuid or sudo priviledge escalation risks. + +-# chmod 4750 /usr/bin/beep +- +-.PP +-and then add only beep-worthy users to the 'beep' group. + .SH FREQUENCY TABLE + .PP + Several people have asked for some basic help translating music notes to frequencies. There are a lot of music notes, and several tables online will give you translations, but here are \fIapproximate\fR numbers for the octave of middle C, to get you started. +@@ -126,14 +102,7 @@ C 523.2 + .PP + None that I'm aware of, though see the \fBIOCTL WACKINESS\fR section. + .SH REPORTING BUGS +-Report bugs to ++Report bugs to https://github.com/johnath/beep/issues + .SH AUTHOR + .PP + This program was written by Johnathan Nightingale (johnath@johnath.com) and is distributed under the GNU General Public License. For more contributing information, check the source, and past contributors can be found in CREDITS. +- +- +- +- +- +- +- diff --git a/90-pcspkr-beep.rules b/90-pcspkr-beep.rules new file mode 100644 index 0000000..c250f8d --- /dev/null +++ b/90-pcspkr-beep.rules @@ -0,0 +1,2 @@ +# Give write access to the PC speaker to "beep" group so they can run "beep" +ACTION=="add", SUBSYSTEM=="input", ATTRS{name}=="PC Speaker", ENV{DEVNAME}!="", RUN+="/usr/bin/setfacl -m g:beep:w '$env{DEVNAME}'" diff --git a/README-packaging.md b/README-packaging.md new file mode 100644 index 0000000..7b6b280 --- /dev/null +++ b/README-packaging.md @@ -0,0 +1,9 @@ +Some commands to help the packager: + + [user@host ndim-beep.git]$ git format-patch --no-signature -N -o ../ beep-1.3-release + [user@host ndim-beep.git]$ cd .. + [user@host beep]$ git checkout 000[124-9]-*.patch + [user@host beep]$ for p in 00*.patch; do sed -n 's/^Subject: \[PATCH\] /# /p' "$p"; printf "%-15s %s\n" "Patch$(echo "$p" | sed 's/^0\{1,3\}\([0-9]\{1,3\}\).*/\1/'):" "$p"; echo; done | xsel + +(rpm would complain about the '%' characters were we to put this into +a comment in the spec file). diff --git a/beep-README.fedora b/beep-README.fedora index 5c6099f..972a0d5 100644 --- a/beep-README.fedora +++ b/beep-README.fedora @@ -2,8 +2,9 @@ Content ======= 1. Load the pkspkr.ko Kernel Driver Module (required) - 2. Set Up `beep` For Use As non-root Users Via `sudo` (optional) - 3. Example Usage + 2. Add non-root users to the "beep" group + 3. Avoid using `beep` + 4. Example Usage 1. Load the pkspkr.ko Kernel Driver Module (required) @@ -35,20 +36,48 @@ When pcspkr is loaded, you can run as root and verify that you hear the beep coming from the PC speaker. -CAUTION: There (used to?) appear to be some issues with access to the -`/dev/console` device which beep uses, possibly related to -`ConsoleKit`. This means that sometimes, just having `pcspkr.ko` -loaded is not enough for beep to actually beep. This issue is being -investigated. + +2. Add non-root users to the "beep" group +----------------------------------------- + +To add user `jane` to the `beep` group, have root run + + [root@host ~]# usermod jane -a -G beep + +You can check which users are members of the `beep` group by running + + [user@host ~]$ getent group beep + beep:x:951:jane,bill + [user@host ~]$ + +However, any user newly added to the `beep` group must re-login so +their processes can pick up the group membership. A user can check +their group membership as follows: + + [jane@host ~]$ id + uid=1000(jane) gid=1000(jane) groups=1000(jane),10(wheel),951(beep) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 + [jane@host ~]$ + +To check the permission of the PC speaker device file, run + + [user@host ~]$ ls -lH /dev/input/by-path/platform-pcspkr-event-spkr + crw-rw----+ 1 root input 13, 85 29. Dez 02:52 /dev/input/by-path/platform-pcspkr-event-spkr + [user@host ~]$ getfacl /dev/input/by-path/platform-pcspkr-event-spkr + getfacl: Removing leading '/' from absolute path names + # file: dev/input/by-path/platform-pcspkr-event-spkr + # owner: root + # group: input + user::rw- + group:beep:-w- + group::rw- + mask::rw- + other::--- + + [user@host ~]$ -2. Set Up `beep` For Use As non-root Users Via `sudo` (optional) ----------------------------------------------------------------- - -If you want non-root users can run the `beep` command, you can set up -`sudo` such that non-root users can run beep. This might have security -implications if the `beep` executable and/or the `pcspkr.ko` kernel -driver contain exploitable flaws. +3. Avoid using `beep` +--------------------- An alternative way to get sound output for non-root users without becoming root works if the system has a sound card set up with a @@ -59,68 +88,8 @@ the `sox(1)` man page): [jane@host ~]$ play -q -n synth 0.3 square 440 -So, if you still insist on making non-root users run `beep` as root, -do read on. -First, make sure the `sudo` package is installed. - -As root, edit the `/etc/sudoers.d/beep` file to allow certain users or -groups to run beep. The example file shipped by the beep package -contains those two simple examples which you can uncomment and adapt: - - # Allow user 'jane' to run beep as root (if uncommented) - # jane NOPASSWD: /usr/bin/beep - - # Allow all members of the group 'mock' to run beep as root (if uncommented) - # %mock NOPASSWD: /usr/bin/beep - -For more information on setting up sudo, read the `sudoers(5)` man page. - -When you have finished setting up the `sudoers` file, you can check -whether `sudo beep` works with commands run as non-root users like - - [jane@host ~]$ id - uid=1000(jane) gid=1000(jane) groups=1000(jane) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 - [jane@host ~]$ sudo -n beep - [jane@host ~]$ - - [bill@host ~]$ id - uid=1066(bill) gid=1066(bill) groups=1066(bill),135(mock) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 - [bill@host ~]$ sudo -n beep - [bill@host ~]$ - -Now you can source the alias definitions for `beep` in your shell (if -you are running a `csh` variant, replace `.sh` with `.csh`): - - [jane@host ~]$ source /etc/profile.d/beep.sh - [jane@host ~]$ beep - [jane@host ~]$ - -The sourcing of the `/etc/profile.d/beep.(csh|sh)` file will be done -automatically when you start a new (login?) shell. - -In case you have *not* configured `sudo` for a non-password execution -of `beep`, `beep` will still work normally for the `root` user, and all -other users see a `sudo` error message - - [jane@host ~]$ alias beep - alias beep='sudo -n /usr/bin/beep' - [jane@host ~]$ beep - sudo: a password is required - [jane@host ~]$ - -instead of the `beep` error message they see without the sudo based -alias for `beep`: - - [jane@host ~]$ alias beep - -bash: alias: beep: not found - [jane@host ~]$ beep - Could not open /dev/tty0 or /dev/vc/0 for writing - open: No such file or directory - [jane@host ~]$ - - -3. Example Usage +4. Example Usage ---------------- An acoustic notification when a long running compile job finishes diff --git a/beep.rpmlintrc b/beep.rpmlintrc index 8b88d58..7985f91 100644 --- a/beep.rpmlintrc +++ b/beep.rpmlintrc @@ -1,9 +1,3 @@ # -*- python -*- addFilter(r'name-repeated-in-summary C Beep') -addFilter(r'non-readable /etc/sudoers.d/beep 600') - -# Not sure what to do about those -# addFilter(r'conffile-without-noreplace-flag /etc/profile.d/beep.csh') -# addFilter(r'conffile-without-noreplace-flag /etc/profile.d/beep.csh') - diff --git a/beep.spec b/beep.spec index 50b4ef7..142d738 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.3 -Release: 24%{?dist} +Release: 26%{?dist} Group: Applications/System License: GPLv2+ @@ -23,8 +23,11 @@ Source2: %{name}-modprobe.conf Source3: %{name}.sudoers Source4: %{name}.csh Source5: %{name}.sh +Source6: 90-pcspkr-beep.rules +# Helping commands see README-packaging.md + # Fix from upstream github repo Patch1: 0001-Fixed-Makefile.patch @@ -73,9 +76,37 @@ Patch14: 0014-Update-COPYING-with-new-FSF-address.patch # If do_beep() sees error from API, exit program Patch15: 0015-If-do_beep-sees-error-from-API-exit-program.patch +# Make the evdev device the first to look for +Patch16: 0016-Make-the-evdev-device-the-first-to-look-for.patch + +# Use realpath(3) on device name +Patch17: 0017-Use-realpath-3-on-device-name.patch + +# refuse to run when setuid or setgid usage detected +Patch18: 0018-refuse-to-run-when-setuid-or-setgid-usage-detected.patch + +# add setuid/setgid check output newline +Patch19: 0019-add-setuid-setgid-check-output-newline.patch + +# refuse to run under sudo +Patch20: 0020-refuse-to-run-under-sudo.patch + +# print console_device in verbose message on BEEP_TYPE_ +Patch21: 0021-print-console_device-in-verbose-message-on-BEEP_TYPE.patch + +# restructure device whitelisting code +Patch22: 0022-restructure-device-whitelisting-code.patch + +# README, beep.1; remove setuid suggestions +Patch23: 0023-README-beep.1-remove-setuid-suggestions.patch + BuildRequires: gcc BuildRequires: glibc-kernheaders +# for the udev macros +BuildRequires: systemd + +Requires(pre): shadow-utils %description @@ -103,6 +134,14 @@ rm -f beep.1.gz %patch13 -p1 -b 0013 %patch14 -p1 -b 0014 %patch15 -p1 -b 0015 +%patch16 -p1 -b 0016 +%patch17 -p1 -b 0017 +%patch18 -p1 -b 0018 +%patch19 -p1 -b 0019 +%patch20 -p1 -b 0020 +%patch21 -p1 -b 0021 +%patch22 -p1 -b 0022 +%patch23 -p1 -b 0023 cp -p %{SOURCE1} README.fedora @@ -114,15 +153,16 @@ make %{?_smp_mflags} FLAGS="" CFLAGS="-Wall -Wextra -Werror -std=gnu99 -pedantic rm -rf "$RPM_BUILD_ROOT" make install DESTDIR="$RPM_BUILD_ROOT" -install -d -m 0755 "$RPM_BUILD_ROOT/%{_sysconfdir}/modprobe.d/" +install -d -m 0755 "$RPM_BUILD_ROOT/%{_sysconfdir}/modprobe.d/" install -p -m 0644 %{SOURCE2} "$RPM_BUILD_ROOT/%{_sysconfdir}/modprobe.d/beep.conf" -install -d -m 0700 "$RPM_BUILD_ROOT/%{_sysconfdir}/sudoers.d/" -install -p -m 0600 %{SOURCE3} "$RPM_BUILD_ROOT/%{_sysconfdir}/sudoers.d/beep" +install -d -m 0755 "$RPM_BUILD_ROOT/%{_udevrulesdir}/" +install -p -m 0644 %{SOURCE6} "$RPM_BUILD_ROOT/%{_udevrulesdir}/" -install -d -m 0755 "$RPM_BUILD_ROOT/%{_sysconfdir}/profile.d/" -install -p -m 0644 %{SOURCE4} %{SOURCE5} "$RPM_BUILD_ROOT/%{_sysconfdir}/profile.d/" +%pre +getent group beep >/dev/null || groupadd -r beep +exit 0 %files @@ -131,12 +171,21 @@ install -p -m 0644 %{SOURCE4} %{SOURCE5} "$RPM_BUILD_ROOT/%{_sysconfdir}/profile %{_mandir}/man1/beep.1.gz %doc README.fedora %config(noreplace) %attr(0644,root,root) %{_sysconfdir}/modprobe.d/beep.conf -%config(noreplace) %attr(0600,root,root) %{_sysconfdir}/sudoers.d/beep -%config %{_sysconfdir}/profile.d/beep.csh -%config %{_sysconfdir}/profile.d/beep.sh +%{_udevrulesdir}/90-pcspkr-beep.rules %changelog +* Sat Dec 29 2018 Hans Ulrich Niedermann - 1.3-26 +- Stop shipping old sudo related config files +- Refuse to run when run via sudo +- Set up group 'beep' for write access to evdev device with new udev rule +- Update README.fedora to reflect new group permission setup on evdev device + +* Fri Dec 28 2018 Hans Ulrich Niedermann - 1.3-25 +- guard against directory traversal in /dev/input/ check +- refuse to run if setuid or setgid root +- make the evdev device the first device to look for (does not require root) + * Fri Dec 28 2018 Hans Ulrich Niedermann - 1.3-24 - Actually apply the patches - Update COPYING with new FSF address From 5d7189e984f26dfd5da750eda2595585e6df3110 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 4 Jan 2019 13:19:31 +0100 Subject: [PATCH 32/80] beep-1.4.0-1 Update to beep-1.4.0. --- .gitignore | 3 +- 0001-Fixed-Makefile.patch | 45 --- 0002-Add-more-error-detection.patch | 45 --- ...-catch-SIGTERM-for-stopping-the-beep.patch | 33 -- ...all-more-user-and-packaging-friendly.patch | 85 ----- ...ve-file-modification-time-on-install.patch | 33 -- 0007-Fix-indentation-if-brace-error.patch | 42 --- ...-2018-0492.patch-from-Debian-package.patch | 118 ------- ...sed-beep.1-file-in-source-repository.patch | 196 ------------ 0011-constrain-freq-and-period-values.patch | 108 ------- ...-signed-int-and-unchecked-input-valu.patch | 84 ----- ...0532-and-mitigate-against-related-is.patch | 298 ------------------ ...-Update-COPYING-with-new-FSF-address.patch | 138 -------- ...eep-sees-error-from-API-exit-program.patch | 39 --- ...e-evdev-device-the-first-to-look-for.patch | 28 -- 0017-Use-realpath-3-on-device-name.patch | 75 ----- ...when-setuid-or-setgid-usage-detected.patch | 37 --- ...d-setuid-setgid-check-output-newline.patch | 39 --- 0020-refuse-to-run-under-sudo.patch | 29 -- ...vice-in-verbose-message-on-BEEP_TYPE.patch | 29 -- ...restructure-device-whitelisting-code.patch | 98 ------ ...DME-beep.1-remove-setuid-suggestions.patch | 136 -------- 90-pcspkr-beep.rules | 2 - README-packaging.md | 11 +- beep-README.fedora => README.fedora | 0 beep-modprobe.conf | 3 - beep.csh | 8 - beep.sh | 8 - beep.spec | 139 ++------ beep.sudoers | 5 - sources | 2 +- 31 files changed, 26 insertions(+), 1890 deletions(-) delete mode 100644 0001-Fixed-Makefile.patch delete mode 100644 0002-Add-more-error-detection.patch delete mode 100644 0004-also-catch-SIGTERM-for-stopping-the-beep.patch delete mode 100644 0005-Make-build-install-more-user-and-packaging-friendly.patch delete mode 100644 0006-Preserve-file-modification-time-on-install.patch delete mode 100644 0007-Fix-indentation-if-brace-error.patch delete mode 100644 0008-Apply-CVE-2018-0492.patch-from-Debian-package.patch delete mode 100644 0009-store-uncompressed-beep.1-file-in-source-repository.patch delete mode 100644 0011-constrain-freq-and-period-values.patch delete mode 100644 0012-get-rid-of-a-few-signed-int-and-unchecked-input-valu.patch delete mode 100644 0013-Fix-CVE-2018-1000532-and-mitigate-against-related-is.patch delete mode 100644 0014-Update-COPYING-with-new-FSF-address.patch delete mode 100644 0015-If-do_beep-sees-error-from-API-exit-program.patch delete mode 100644 0016-Make-the-evdev-device-the-first-to-look-for.patch delete mode 100644 0017-Use-realpath-3-on-device-name.patch delete mode 100644 0018-refuse-to-run-when-setuid-or-setgid-usage-detected.patch delete mode 100644 0019-add-setuid-setgid-check-output-newline.patch delete mode 100644 0020-refuse-to-run-under-sudo.patch delete mode 100644 0021-print-console_device-in-verbose-message-on-BEEP_TYPE.patch delete mode 100644 0022-restructure-device-whitelisting-code.patch delete mode 100644 0023-README-beep.1-remove-setuid-suggestions.patch delete mode 100644 90-pcspkr-beep.rules rename beep-README.fedora => README.fedora (100%) delete mode 100644 beep-modprobe.conf delete mode 100644 beep.csh delete mode 100644 beep.sh delete mode 100644 beep.sudoers diff --git a/.gitignore b/.gitignore index 5fd812a..c6dfe3b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -beep-1.3.tar.gz +/beep-1.*/ +/beep-1.*.tar.gz diff --git a/0001-Fixed-Makefile.patch b/0001-Fixed-Makefile.patch deleted file mode 100644 index 7342560..0000000 --- a/0001-Fixed-Makefile.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 8b32b8b088be1f29e8bfea57a97b9bfaa76ec8ee Mon Sep 17 00:00:00 2001 -From: Chris Wong -Date: Wed, 23 Nov 2011 10:39:53 +1300 -Subject: [PATCH] Fixed Makefile - -* Use /usr/share/man (see http://www.pathname.com/fhs/2.2/fhs-4.11.html#4.11.5) - -* Removed trailing spaces - -* Added optimization flag (must beep FAST!!!) ---- - Makefile | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/Makefile b/Makefile -index cc359c4..0f4f810 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,19 +1,19 @@ - CC=gcc --FLAGS=-Wall -+FLAGS=-Wall -O2 - EXEC_NAME=beep - INSTALL_DIR=/usr/bin - MAN_FILE=beep.1.gz --MAN_DIR=/usr/man/man1 -+MAN_DIR=/usr/share/man/man1 - - default : beep - --clean : -+clean : - rm ${EXEC_NAME} - - beep : beep.c - ${CC} ${FLAGS} -o ${EXEC_NAME} beep.c - --install : -+install : - cp ${EXEC_NAME} ${INSTALL_DIR} - # rm -f /usr/man/man1/beep.1.bz2 - cp ${MAN_FILE} ${MAN_DIR} --- -2.7.5 - diff --git a/0002-Add-more-error-detection.patch b/0002-Add-more-error-detection.patch deleted file mode 100644 index 6a229e0..0000000 --- a/0002-Add-more-error-detection.patch +++ /dev/null @@ -1,45 +0,0 @@ -From d3aee6c489852108c91dc22abcacff364e9429f2 Mon Sep 17 00:00:00 2001 -From: Chris Wong -Date: Wed, 23 Nov 2011 11:34:55 +1300 -Subject: [PATCH] Add more error detection - ---- - beep.c | 15 +++++++++------ - 1 file changed, 9 insertions(+), 6 deletions(-) - -diff --git a/beep.c b/beep.c -index 452fc08..14fac3e 100644 ---- a/beep.c -+++ b/beep.c -@@ -98,11 +98,11 @@ char *console_device = NULL; - - - void do_beep(int freq) { -- if (console_type == BEEP_TYPE_CONSOLE) { -- if(ioctl(console_fd, KIOCSOUND, freq != 0 -- ? (int)(CLOCK_TICK_RATE/freq) -- : freq) < 0) { -- printf("\a"); /* Output the only beep we can, in an effort to fall back on usefulness */ -+ int period = (freq != 0 ? (int)(CLOCK_TICK_RATE/freq) : freq); -+ -+ if(console_type == BEEP_TYPE_CONSOLE) { -+ if(ioctl(console_fd, KIOCSOUND, period) < 0) { -+ putchar('\a'); /* Output the only beep we can, in an effort to fall back on usefulness */ - perror("ioctl"); - } - } else { -@@ -113,7 +113,10 @@ void do_beep(int freq) { - e.code = SND_TONE; - e.value = freq; - -- write(console_fd, &e, sizeof(struct input_event)); -+ if(write(console_fd, &e, sizeof(struct input_event)) < 0) { -+ putchar('\a'); /* See above */ -+ perror("write"); -+ } - } - } - --- -2.7.5 - diff --git a/0004-also-catch-SIGTERM-for-stopping-the-beep.patch b/0004-also-catch-SIGTERM-for-stopping-the-beep.patch deleted file mode 100644 index 8574b32..0000000 --- a/0004-also-catch-SIGTERM-for-stopping-the-beep.patch +++ /dev/null @@ -1,33 +0,0 @@ -From e1320c1da52ca92aa68b4224f9532982184fbe00 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?J=C3=A9r=C3=B4me?= -Date: Thu, 7 Feb 2013 12:54:53 +0100 -Subject: [PATCH] also catch SIGTERM for stopping the beep - -Signed-off-by: Gerfried Fuchs ---- - beep.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/beep.c b/beep.c -index 452fc08..9cb63bf 100644 ---- a/beep.c -+++ b/beep.c -@@ -127,6 +127,7 @@ void handle_signal(int signum) { - - switch(signum) { - case SIGINT: -+ case SIGTERM: - if(console_fd >= 0) { - /* Kill the sound, quit gracefully */ - do_beep(0); -@@ -321,6 +322,7 @@ int main(int argc, char **argv) { - parms->next = NULL; - - signal(SIGINT, handle_signal); -+ signal(SIGTERM, handle_signal); - parse_command_line(argc, argv, parms); - - /* this outermost while loop handles the possibility that -n/--new has been --- -2.7.5 - diff --git a/0005-Make-build-install-more-user-and-packaging-friendly.patch b/0005-Make-build-install-more-user-and-packaging-friendly.patch deleted file mode 100644 index 9e2b481..0000000 --- a/0005-Make-build-install-more-user-and-packaging-friendly.patch +++ /dev/null @@ -1,85 +0,0 @@ -From 947a7e332908dcba1c7e523fbdc927d39ee6adb1 Mon Sep 17 00:00:00 2001 -From: Hans Ulrich Niedermann -Date: Tue, 19 Nov 2013 23:40:50 +0100 -Subject: [PATCH] Make build/install more user and packaging friendly - -Make the build and install more user and packaging friendly -by introducing the following features in the Makefile: - - * Honor the $(CFLAGS) set when calling make. - - * Prefix all install locations with $(DESTDIR) for - easy package building. - - * Use GNU Makefile conventions for defining installation - directories. This means $(bindir) and $(man1dir) - instead of the former $(INSTALL_DIR) and $(MAN_DIR). - - * Use install(1) for installing files and directories - so that permissions can be set properly. - - * Stop "make clean" failing when it has nothing to do. - - * Add 'uninstall' make target. - - * Make 'install' target build executable if necessary. ---- - Makefile | 40 +++++++++++++++++++++++++++++----------- - 1 file changed, 29 insertions(+), 11 deletions(-) - -diff --git a/Makefile b/Makefile -index 0f4f810..942a7a5 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,19 +1,37 @@ - CC=gcc - FLAGS=-Wall -O2 -+ -+INSTALL=install -+ - EXEC_NAME=beep --INSTALL_DIR=/usr/bin - MAN_FILE=beep.1.gz --MAN_DIR=/usr/share/man/man1 - --default : beep -+# Use GNU makefile conventions for directory names with one notable -+# exception: prefix is not /usr/local in order to keep the default -+# installation location for beep. -+prefix=/usr -+exec_prefix=$(prefix) -+bindir=$(exec_prefix)/bin -+datarootdir=$(prefix)/share -+mandir=$(datarootdir)/man -+man1dir=$(mandir)/man1 -+ -+.PHONY: all -+all: $(EXEC_NAME) -+ -+.PHONY: clean -+clean: -+ rm -f $(EXEC_NAME) - --clean : -- rm ${EXEC_NAME} -+$(EXEC_NAME): beep.c -+ $(CC) $(FLAGS) $(CFLAGS) -o $(EXEC_NAME) beep.c - --beep : beep.c -- ${CC} ${FLAGS} -o ${EXEC_NAME} beep.c -+install: all -+ $(INSTALL) -m 0755 -d $(DESTDIR)$(bindir) -+ $(INSTALL) -m 0755 $(EXEC_NAME) $(DESTDIR)$(bindir)/ -+ $(INSTALL) -m 0755 -d $(DESTDIR)$(man1dir) -+ $(INSTALL) -m 0644 $(MAN_FILE) $(DESTDIR)$(man1dir)/ - --install : -- cp ${EXEC_NAME} ${INSTALL_DIR} -- # rm -f /usr/man/man1/beep.1.bz2 -- cp ${MAN_FILE} ${MAN_DIR} -+uninstall: -+ rm -f $(DESTDIR)$(bindir)/$(EXEC_NAME) -+ rm -f $(DESTDIR)$(man1dir)/$(MAN_FILE) --- -2.7.5 - diff --git a/0006-Preserve-file-modification-time-on-install.patch b/0006-Preserve-file-modification-time-on-install.patch deleted file mode 100644 index 8a32405..0000000 --- a/0006-Preserve-file-modification-time-on-install.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 4622dd15dc12dab47a0381a8a7188f0f0421e01d Mon Sep 17 00:00:00 2001 -From: Hans Ulrich Niedermann -Date: Wed, 20 Nov 2013 00:00:54 +0100 -Subject: [PATCH] Preserve file modification time on install - -Add -p option to install(1) invocation in order to preserve -the timestamps of the files being installed. ---- - Makefile | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/Makefile b/Makefile -index 942a7a5..290b8a4 100644 ---- a/Makefile -+++ b/Makefile -@@ -27,10 +27,10 @@ $(EXEC_NAME): beep.c - $(CC) $(FLAGS) $(CFLAGS) -o $(EXEC_NAME) beep.c - - install: all -- $(INSTALL) -m 0755 -d $(DESTDIR)$(bindir) -- $(INSTALL) -m 0755 $(EXEC_NAME) $(DESTDIR)$(bindir)/ -- $(INSTALL) -m 0755 -d $(DESTDIR)$(man1dir) -- $(INSTALL) -m 0644 $(MAN_FILE) $(DESTDIR)$(man1dir)/ -+ $(INSTALL) -m 0755 -d $(DESTDIR)$(bindir) -+ $(INSTALL) -m 0755 -p $(EXEC_NAME) $(DESTDIR)$(bindir)/ -+ $(INSTALL) -m 0755 -d $(DESTDIR)$(man1dir) -+ $(INSTALL) -m 0644 -p $(MAN_FILE) $(DESTDIR)$(man1dir)/ - - uninstall: - rm -f $(DESTDIR)$(bindir)/$(EXEC_NAME) --- -2.7.5 - diff --git a/0007-Fix-indentation-if-brace-error.patch b/0007-Fix-indentation-if-brace-error.patch deleted file mode 100644 index b318247..0000000 --- a/0007-Fix-indentation-if-brace-error.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 35ba84dccb8fc8dc43cb3f575904a33ffa27e7b7 Mon Sep 17 00:00:00 2001 -From: Hans Ulrich Niedermann -Date: Tue, 3 Apr 2018 19:11:07 +0200 -Subject: [PATCH] Fix indentation/if brace error - -As beep.c is not Python, the code blocks must be defined by -using braces instead of just indenting them differently. - -Once we do that, the outcome of multiple -f parameters will -actually match what the warning message documents beep does: -Only the last -f value will be used. - -Many projects proscribe using braces everywhere, but this -change keeps the beep.c coding style of using braces only -when absolutely necessary. - -This issue was discovered by compiling with gcc 6. ---- - beep.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/beep.c b/beep.c -index 7da2e70..d46adc8 100644 ---- a/beep.c -+++ b/beep.c -@@ -194,11 +194,12 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) { - if(!sscanf(optarg, "%f", &argfreq) || (argfreq >= 20000 /* ack! */) || - (argfreq <= 0)) - usage_bail(argv[0]); -- else -+ else { - if (result->freq != 0) - fprintf(stderr, "WARNING: multiple -f values given, only last " - "one is used.\n"); - result->freq = argfreq; -+ } - break; - case 'l' : /* length */ - if(!sscanf(optarg, "%d", &argval) || (argval < 0)) --- -2.7.5 - diff --git a/0008-Apply-CVE-2018-0492.patch-from-Debian-package.patch b/0008-Apply-CVE-2018-0492.patch-from-Debian-package.patch deleted file mode 100644 index 29aa9f6..0000000 --- a/0008-Apply-CVE-2018-0492.patch-from-Debian-package.patch +++ /dev/null @@ -1,118 +0,0 @@ -From 3b67473e16aaf2f83cb8ac18c13c9183a8e3c7b2 Mon Sep 17 00:00:00 2001 -From: Hans Ulrich Niedermann -Date: Tue, 3 Apr 2018 18:37:33 +0200 -Subject: [PATCH] Apply CVE-2018-0492.patch from Debian package - ---- - beep.c | 53 ++++++++++++++++++++++++----------------------------- - 1 file changed, 24 insertions(+), 29 deletions(-) - -diff --git a/beep.c b/beep.c -index d46adc8..f6781e8 100644 ---- a/beep.c -+++ b/beep.c -@@ -109,6 +109,7 @@ void do_beep(int freq) { - /* BEEP_TYPE_EVDEV */ - struct input_event e; - -+ memset(&e, 0, sizeof(e)); - e.type = EV_SND; - e.code = SND_TONE; - e.value = freq; -@@ -124,10 +125,6 @@ void do_beep(int freq) { - /* If we get interrupted, it would be nice to not leave the speaker beeping in - perpetuity. */ - void handle_signal(int signum) { -- -- if(console_device) -- free(console_device); -- - switch(signum) { - case SIGINT: - case SIGTERM: -@@ -258,7 +255,7 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) { - result->verbose = 1; - break; - case 'e' : /* also --device */ -- console_device = strdup(optarg); -+ console_device = optarg; - break; - case 'h' : /* notice that this is also --help */ - default : -@@ -277,26 +274,6 @@ void play_beep(beep_parms_t parms) { - "%d delay after) @ %.2f Hz\n", - parms.reps, parms.length, parms.delay, parms.end_delay, parms.freq); - -- /* try to snag the console */ -- if(console_device) -- console_fd = open(console_device, O_WRONLY); -- else -- if((console_fd = open("/dev/tty0", O_WRONLY)) == -1) -- console_fd = open("/dev/vc/0", O_WRONLY); -- -- if(console_fd == -1) { -- fprintf(stderr, "Could not open %s for writing\n", -- console_device != NULL ? console_device : "/dev/tty0 or /dev/vc/0"); -- printf("\a"); /* Output the only beep we can, in an effort to fall back on usefulness */ -- perror("open"); -- exit(1); -- } -- -- if (ioctl(console_fd, EVIOCGSND(0)) != -1) -- console_type = BEEP_TYPE_EVDEV; -- else -- console_type = BEEP_TYPE_CONSOLE; -- - /* Beep */ - for (i = 0; i < parms.reps; i++) { /* start beep */ - do_beep(parms.freq); -@@ -306,8 +283,6 @@ void play_beep(beep_parms_t parms) { - if(parms.end_delay || (i+1 < parms.reps)) - usleep(1000*parms.delay); /* wait... */ - } /* repeat. */ -- -- close(console_fd); - } - - -@@ -329,6 +304,26 @@ int main(int argc, char **argv) { - signal(SIGTERM, handle_signal); - parse_command_line(argc, argv, parms); - -+ /* try to snag the console */ -+ if(console_device) -+ console_fd = open(console_device, O_WRONLY); -+ else -+ if((console_fd = open("/dev/tty0", O_WRONLY)) == -1) -+ console_fd = open("/dev/vc/0", O_WRONLY); -+ -+ if(console_fd == -1) { -+ fprintf(stderr, "Could not open %s for writing\n", -+ console_device != NULL ? console_device : "/dev/tty0 or /dev/vc/0"); -+ printf("\a"); /* Output the only beep we can, in an effort to fall back on usefulness */ -+ perror("open"); -+ exit(1); -+ } -+ -+ if (ioctl(console_fd, EVIOCGSND(0)) != -1) -+ console_type = BEEP_TYPE_EVDEV; -+ else -+ console_type = BEEP_TYPE_CONSOLE; -+ - /* this outermost while loop handles the possibility that -n/--new has been - used, i.e. that we have multiple beeps specified. Each iteration will - play, then free() one parms instance. */ -@@ -366,8 +361,8 @@ int main(int argc, char **argv) { - parms = next; - } - -- if(console_device) -- free(console_device); -+ close(console_fd); -+ console_fd = -1; - - return EXIT_SUCCESS; - } --- -2.7.5 - diff --git a/0009-store-uncompressed-beep.1-file-in-source-repository.patch b/0009-store-uncompressed-beep.1-file-in-source-repository.patch deleted file mode 100644 index d65355f..0000000 --- a/0009-store-uncompressed-beep.1-file-in-source-repository.patch +++ /dev/null @@ -1,196 +0,0 @@ -From 0d386dbdbf6f5dcb4079b07aef0a905c2ebda532 Mon Sep 17 00:00:00 2001 -From: Hans Ulrich Niedermann -Date: Thu, 27 Dec 2018 22:18:37 +0100 -Subject: [PATCH] store uncompressed beep.1 file in source repository - ---- - Makefile | 17 +++++-- - beep.1 | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++++ - 4 files changed, 155 insertions(+), 4 deletions(-) - create mode 100644 beep.1 - -diff --git a/Makefile b/Makefile -index 290b8a4..44035e5 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,6 +1,7 @@ - CC=gcc - FLAGS=-Wall -O2 - -+GZIP = gzip - INSTALL=install - - EXEC_NAME=beep -@@ -17,15 +18,23 @@ mandir=$(datarootdir)/man - man1dir=$(mandir)/man1 - - .PHONY: all --all: $(EXEC_NAME) -+all: all-local - --.PHONY: clean --clean: -- rm -f $(EXEC_NAME) - -+TARGETS += $(EXEC_NAME) - $(EXEC_NAME): beep.c - $(CC) $(FLAGS) $(CFLAGS) -o $(EXEC_NAME) beep.c - -+TARGETS += $(MAN_FILE) -+$(MAN_FILE): beep.1 -+ $(GZIP) --best -c < $< > $@ -+ -+all-local: $(TARGETS) -+ -+.PHONY: clean -+clean: -+ rm -f $(TARGETS) -+ - install: all - $(INSTALL) -m 0755 -d $(DESTDIR)$(bindir) - $(INSTALL) -m 0755 -p $(EXEC_NAME) $(DESTDIR)$(bindir)/ -diff --git a/beep.1 b/beep.1 -new file mode 100644 -index 0000000..3de05ec ---- /dev/null -+++ b/beep.1 -@@ -0,0 +1,139 @@ -+.TH BEEP 1 "March 2002" -+.SH NAME -+beep \- beep the pc speaker any number of ways -+.SH SYNOPSIS -+.B beep -+[\-f N] [\-l N] [\-r N] [\-d N] [\-D N] [\-s] [\-c] -+.HP -+.B beep -+[ OPTIONS ] [-n] [--new] [ OPTIONS ] -+.HP -+.B beep -+[\-h] [\-\-help] -+.HP -+.B beep -+[\-v] [\-V] [\-\-version] -+.SH DESCRIPTION -+.PP -+\fBbeep\fR allows the user to control the pc-speaker with precision, allowing different sounds to indicate different events. While it can be run quite happily on the command line, it's intended place of residence is within shell/perl scripts, notifying the user when something interesting occurs. Of course, it has no notion of what's interesting, but it's real good at that notifying part. -+.PP -+All options have default values, meaning that just typing '\fBbeep\fR' will work. If an option is specified more than once on the command line, subsequent options override their predecessors. So '\fBbeep\fR \-f 200 \-f 300' will beep at 300Hz. -+.SH OPTIONS -+.TP -+\fB\-f\fR N -+beep at N Hz, where 0 < N < 20000. As a general ballpark, the regular terminal beep is around 750Hz. N is not, incidentally, restricted to whole numbers. -+.TP -+\fB\-l\fR N -+beep for N milliseconds. -+.TP -+\fB\-r\fR N -+specify the number of repetitions (defaults to 1). -+.TP -+\fB\-d\fR N, \fB\-D\fR N -+specify a delay of N milliseconds between repetitions. Use of \-d specifies that this delay should only occur \fIbetween\fR beeps, that is, it should not occur after the last repetition. \-D indicates that the delay should occur after every repetition, including the last. Normally, \-d is what you want, but if, for example, you are stringing several \fBbeep\fR commands together to play the star wars anthem, you may want control over every delay. -+.TP -+\fB\-n\fR, \fB\-\-new\fR -+this option allows you to break the command line up into specifying multiple beeps. Each time this option is used, beep starts treating all further arguments as though they were for a new beep. So for example: -+ -+\fBbeep\fR -f 1000 -n -f 2000 -n -f 1500 -+ -+would produce a sequence of three beeps, the first with a frequency of 1000Hz (and otherwise default values), then a second beep with a frequency of 2000Hz (again, with things like delay and reps being set to their defaults), then a third beep, at 1500Hz. This is different from specifying a -r value, since -r repeats the same beep multiple times, whereas -n allows you to specify different beeps. After a -n, the new beep is created with all the default values, and any of these can be specified without altering values for preceeding (or later) beeps. See the \fBEXAMPLES\fR section if this managed to confuse you. -+.TP -+\fB\-s\fR, \fB\-c\fR -+these options put \fBbeep\fR into input-processing mode. -s tells \fBbeep\fR to read from stdin, and beep after each newline, and -c tells it to do so after every character. In both cases, the program will also echo the input back out to stdout, which makes it easy to slip \fBbeep\fR into a text-processing pipeline, see the \fBEXAMPLES\fR section. -+.TP -+\fB\-h\fR, \fB\-\-help\fR -+display usage info and exit -+.TP -+\fB\-v\fR, \fB\-V\fR, \fB\-\-version\fR -+display version information and exit -+.SH EXAMPLES -+.TP -+At its simplest (yet still effective) -+ -+\fBbeep\fR -+.TP -+A more interesting standalone setup -+ -+\fBbeep\fR -f 300.7 -r 2 -d 100 -l 400 -+.TP -+As part of a log-watching pipeline -+ -+tail -f /var/log/xferlog | grep 'passwd' | \fBbeep\fR -f 1000 -r 5 -s -+.TP -+When using -c mode, I recommend using a short -D, and a shorter -l, so that the beeps don't blur together. Something like this will get you a cheesy 1970's style beep-as-you-type-each-letter effect -+ -+cat file | \fBbeep\fR -c -f 400 -D 50 -l 10 -+ -+.TP -+A highly contrived example of -n/--new usage -+ -+\fBbeep\fR -f 1000 -r 2 -n -r 5 -l 10 --new -+ -+will produce first two 1000Hz beeps, then 5 beeps at the default tone, but only 10ms long each, followed by a third beep using all the default settings (since none are specified). -+.PP See also the \fBFREQUENCY TABLE\fR below. -+ -+.SH IOCTL WACKINESS -+.PP -+Some users will encounter a situation where beep dies with a complaint from ioctl(). The reason for this, as Peter Tirsek was nice enough to point out to me, stems from how the kernel handles beep's attempt to poke at (for non-programmers: ioctl is a sort of catch-all function that lets you poke at things that have no other predefined poking-at mechanism) the tty, which is how it beeps. The short story is, the kernel checks that either: -+.PP -+- you are the superuser -+.PP -+- you own the current tty -+.PP -+What this means is that root can always make beep work (to the best of my knowledge!), and that any local user can make beep work, BUT a non-root remote user cannot use beep in it's natural state. What's worse, an xterm, or other x-session counts, as far as the kernel is concerned, as 'remote', so beep won't work from a non-priviledged xterm either. I had originally chalked this up to a bug, but there's actually nothing I can do about it, and it really is a Good Thing that the kernel does things this way. There is also a solution. -+.PP -+By default beep is not installed with the suid bit set, because that would just be zany. On the other hand, if you do make it suid root, all your problems with beep bailing on ioctl calls will magically vanish, which is pleasant, and the only reason not to is that any suid program is a potential security hole. Conveniently, beep is very short, so auditing it is pretty straightforward. -+.PP -+Decide for yourself, of course, but it looks safe to me - there's only one buffer and fgets doesn't let it overflow, there's only one file opening, and while there is a potential race condition there, it's with /dev/console. If someone can exploit this race by replacing /dev/console, you've got bigger problems. :) -+.PP -+So the quick, only, and likely safe solution if beep is not beeping when you want it to is (as root): -+.PP -+# chmod 4755 /usr/bin/beep -+.PP -+(or wherever you put it) -+.PP -+The one snag is that this will give any little nitwit the ability to run beep successfully - make sure this is what you want. If it isn't, a slightly more complex fix would be something like: -+.PP -+# chgrp beep /usr/bin/beep -+ -+# chmod 4750 /usr/bin/beep -+ -+.PP -+and then add only beep-worthy users to the 'beep' group. -+.SH FREQUENCY TABLE -+.PP -+Several people have asked for some basic help translating music notes to frequencies. There are a lot of music notes, and several tables online will give you translations, but here are \fIapproximate\fR numbers for the octave of middle C, to get you started. -+.PP -+Note Frequency -+.ft CW -+.nf -+C 261.6 -+C# 277.2 -+D 293.7 -+D# 311.1 -+E 329.6 -+F 349.2 -+F# 370.0 -+G 392.0 -+G# 415.3 -+A 440.0 -+A# 466.2 -+B 493.9 -+C 523.2 -+.ft R -+.SH BUGS -+.PP -+None that I'm aware of, though see the \fBIOCTL WACKINESS\fR section. -+.SH REPORTING BUGS -+Report bugs to -+.SH AUTHOR -+.PP -+This program was written by Johnathan Nightingale (johnath@johnath.com) and is distributed under the GNU General Public License. For more contributing information, check the source, and past contributors can be found in CREDITS. -+ -+ -+ -+ -+ -+ -+ diff --git a/0011-constrain-freq-and-period-values.patch b/0011-constrain-freq-and-period-values.patch deleted file mode 100644 index 2238f9b..0000000 --- a/0011-constrain-freq-and-period-values.patch +++ /dev/null @@ -1,108 +0,0 @@ -From 358ec04ce636df50a30be04370bf7c622afbe3d5 Mon Sep 17 00:00:00 2001 -From: Hans Ulrich Niedermann -Date: Fri, 28 Dec 2018 02:49:01 +0100 -Subject: [PATCH] constrain freq and period values - -We have made sure the freq range was between 0 and 20000 before, -but we now explicitly consider freq and period to be unsigned -integers and thus avoid some integer overflows. - -Also, we avoid giving floating point accuracy for the freq even -while we have always used integer values. For compatibility reasons, -we still accept floating point values for freq, but we now actually -round those floating point values to integers using rintf(3). ---- - Makefile | 2 +- - beep.c | 25 ++++++++++++++----------- - 2 files changed, 15 insertions(+), 12 deletions(-) - -diff --git a/Makefile b/Makefile -index 44035e5..75390e0 100644 ---- a/Makefile -+++ b/Makefile -@@ -23,7 +23,7 @@ all: all-local - - TARGETS += $(EXEC_NAME) - $(EXEC_NAME): beep.c -- $(CC) $(FLAGS) $(CFLAGS) -o $(EXEC_NAME) beep.c -+ $(CC) $(FLAGS) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $(EXEC_NAME) -lm $(LIBADD) beep.c - - TARGETS += $(MAN_FILE) - $(MAN_FILE): beep.1 -diff --git a/beep.c b/beep.c -index f6781e8..2bea6cd 100644 ---- a/beep.c -+++ b/beep.c -@@ -18,7 +18,9 @@ - - #include - #include -+#include - #include -+#include - #include - #include - #include -@@ -45,7 +47,7 @@ - result of this is a tone at approximately the desired frequency. :) - */ - #ifndef CLOCK_TICK_RATE --#define CLOCK_TICK_RATE 1193180 -+#define CLOCK_TICK_RATE 1193180U - #endif - - #define VERSION_STRING "beep-1.3" -@@ -71,7 +73,7 @@ char *copyright = - #define CHAR_STDIN_BEEP 2 - - typedef struct beep_parms_t { -- float freq; /* tone frequency (Hz) */ -+ unsigned int freq; /* tone frequency (Hz) */ - int length; /* tone length (ms) */ - int reps; /* # of repetitions */ - int delay; /* delay between reps (ms) */ -@@ -97,11 +99,11 @@ int console_type = BEEP_TYPE_CONSOLE; - char *console_device = NULL; - - --void do_beep(int freq) { -- int period = (freq != 0 ? (int)(CLOCK_TICK_RATE/freq) : freq); -+void do_beep(unsigned int freq) { -+ const uintptr_t argp = (freq != 0 ? (CLOCK_TICK_RATE/freq) : freq) & 0xffff; - - if(console_type == BEEP_TYPE_CONSOLE) { -- if(ioctl(console_fd, KIOCSOUND, period) < 0) { -+ if(ioctl(console_fd, KIOCSOUND, argp) < 0) { - putchar('\a'); /* Output the only beep we can, in an effort to fall back on usefulness */ - perror("ioctl"); - } -@@ -188,14 +190,15 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) { - float argfreq = -1; - switch(c) { - case 'f': /* freq */ -- if(!sscanf(optarg, "%f", &argfreq) || (argfreq >= 20000 /* ack! */) || -- (argfreq <= 0)) -+ if(!sscanf(optarg, "%f", &argfreq) || (argfreq >= 20000.0f /* ack! */) || -+ (argfreq <= 0.0f)) { - usage_bail(argv[0]); -- else { -- if (result->freq != 0) -+ } else { -+ if (result->freq != 0) { - fprintf(stderr, "WARNING: multiple -f values given, only last " - "one is used.\n"); -- result->freq = argfreq; -+ } -+ result->freq = ((unsigned int)rintf(argfreq)); - } - break; - case 'l' : /* length */ -@@ -271,7 +274,7 @@ void play_beep(beep_parms_t parms) { - - if(parms.verbose == 1) - fprintf(stderr, "[DEBUG] %d times %d ms beeps (%d delay between, " -- "%d delay after) @ %.2f Hz\n", -+ "%d delay after) @ %d Hz\n", - parms.reps, parms.length, parms.delay, parms.end_delay, parms.freq); - - /* Beep */ diff --git a/0012-get-rid-of-a-few-signed-int-and-unchecked-input-valu.patch b/0012-get-rid-of-a-few-signed-int-and-unchecked-input-valu.patch deleted file mode 100644 index 2fe5143..0000000 --- a/0012-get-rid-of-a-few-signed-int-and-unchecked-input-valu.patch +++ /dev/null @@ -1,84 +0,0 @@ -From 60a0d26ba7dc9e6c9456c37dbd892cd56d4a2ddb Mon Sep 17 00:00:00 2001 -From: Hans Ulrich Niedermann -Date: Fri, 28 Dec 2018 03:20:59 +0100 -Subject: [PATCH] get rid of a few signed int and unchecked input value ranges - ---- - beep.c | 25 +++++++++++++------------ - 1 file changed, 13 insertions(+), 12 deletions(-) - -diff --git a/beep.c b/beep.c -index 2bea6cd..b838b85 100644 ---- a/beep.c -+++ b/beep.c -@@ -74,10 +74,10 @@ char *copyright = - - typedef struct beep_parms_t { - unsigned int freq; /* tone frequency (Hz) */ -- int length; /* tone length (ms) */ -- int reps; /* # of repetitions */ -- int delay; /* delay between reps (ms) */ -- int end_delay; /* do we delay after last rep? */ -+ unsigned int length; /* tone length (ms) */ -+ unsigned int reps; /* # of repetitions */ -+ unsigned int delay; /* delay between reps (ms) */ -+ unsigned int end_delay; /* do we delay after last rep? */ - int stdin_beep; /* are we using stdin triggers? We have three options: - - just beep and terminate (default) - - beep after a line of input -@@ -202,19 +202,19 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) { - } - break; - case 'l' : /* length */ -- if(!sscanf(optarg, "%d", &argval) || (argval < 0)) -+ if(!sscanf(optarg, "%d", &argval) || (argval < 0) || (argval > 2100000)) - usage_bail(argv[0]); - else - result->length = argval; - break; - case 'r' : /* repetitions */ -- if(!sscanf(optarg, "%d", &argval) || (argval < 0)) -+ if(!sscanf(optarg, "%d", &argval) || (argval < 0) || (argval > 2100000)) - usage_bail(argv[0]); - else - result->reps = argval; - break; - case 'd' : /* delay between reps - WITHOUT delay after last beep*/ -- if(!sscanf(optarg, "%d", &argval) || (argval < 0)) -+ if(!sscanf(optarg, "%d", &argval) || (argval < 0) || (argval > 2100000)) - usage_bail(argv[0]); - else { - result->delay = argval; -@@ -222,7 +222,7 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) { - } - break; - case 'D' : /* delay between reps - WITH delay after last beep */ -- if(!sscanf(optarg, "%d", &argval) || (argval < 0)) -+ if(!sscanf(optarg, "%d", &argval) || (argval < 0) || (argval > 2100000)) - usage_bail(argv[0]); - else { - result->delay = argval; -@@ -270,7 +270,7 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) { - } - - void play_beep(beep_parms_t parms) { -- int i; /* loop counter */ -+ unsigned int i; /* loop counter */ - - if(parms.verbose == 1) - fprintf(stderr, "[DEBUG] %d times %d ms beeps (%d delay between, " -@@ -281,10 +281,11 @@ void play_beep(beep_parms_t parms) { - for (i = 0; i < parms.reps; i++) { /* start beep */ - do_beep(parms.freq); - /* Look ma, I'm not ansi C compatible! */ -- usleep(1000*parms.length); /* wait... */ -+ usleep(1000U*parms.length); /* wait... */ - do_beep(0); /* stop beep */ -- if(parms.end_delay || (i+1 < parms.reps)) -- usleep(1000*parms.delay); /* wait... */ -+ if (parms.end_delay || ((i+1) < parms.reps)) { -+ usleep(1000U*parms.delay); /* wait... */ -+ } - } /* repeat. */ - } - diff --git a/0013-Fix-CVE-2018-1000532-and-mitigate-against-related-is.patch b/0013-Fix-CVE-2018-1000532-and-mitigate-against-related-is.patch deleted file mode 100644 index 03522d3..0000000 --- a/0013-Fix-CVE-2018-1000532-and-mitigate-against-related-is.patch +++ /dev/null @@ -1,298 +0,0 @@ -From 10cd5126f320154dccf344e19248c5589d9c20bb Mon Sep 17 00:00:00 2001 -From: Hans Ulrich Niedermann -Date: Fri, 28 Dec 2018 00:10:33 +0100 -Subject: [PATCH] Fix CVE-2018-1000532 and mitigate against related issues - - * Separate initialization including checking for supported APIs - and the main program which just uses the detected API without - any further checks. This helps avoid code paths where code - one API is actually run after initialization for the API. - - * If a device name is given as a command line argument, - only allow device names starting with "/dev/input/". - - * Verify before open(2) that the device name actually refers - to a character device special file by using stat(2). - - * After open(2), verify that console_fd actually - points to a character device special file using fstat(2). - - * Check for API to use on console_fd only once during - initialization using ioctl(2). The two APIs are - - * The console API which uses ioctl(2) KIOCSOUND on console_fd - - * The evdev API which uses write(2) on console_fd - - Then the actual do_beep() function can just do the proper - thing without having to decide between APIs or falling back - or anything. - - * Add "/dev/input/by-path/platform-pcspkr-event-spkr" to - list of console devices to probe by default, so we have - both console API type and evdev API type devices in that - list to help with testing the code for both APIs. ---- - beep.c | 195 +++++++++++++++++++++++++++++++++++++++++++++------------ - 1 file changed, 155 insertions(+), 40 deletions(-) - -diff --git a/beep.c b/beep.c -index b838b85..2a7404e 100644 ---- a/beep.c -+++ b/beep.c -@@ -16,6 +16,7 @@ - * Bug me, I like it: http://johnath.com/ or johnath@johnath.com - */ - -+#include - #include - #include - #include -@@ -26,6 +27,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -90,36 +92,45 @@ typedef struct beep_parms_t { - struct beep_parms_t *next; /* in case -n/--new is used. */ - } beep_parms_t; - --enum { BEEP_TYPE_CONSOLE, BEEP_TYPE_EVDEV }; -- --/* Momma taught me never to use globals, but we need something the signal -+/* Use an enum and switch statements to have compiler warn us about -+ * unhandled cases. */ -+typedef enum { -+ /* When the beep_type has not been set yet, do nothing */ -+ BEEP_TYPE_UNSET = 0, -+ /* Use the console API */ -+ BEEP_TYPE_CONSOLE = 1, -+ /* Use the evdev API */ -+ BEEP_TYPE_EVDEV = 2, -+} beep_type_E; -+ -+/* Momma taught me never to use globals, but we need something the signal - handlers can get at.*/ - int console_fd = -1; --int console_type = BEEP_TYPE_CONSOLE; -+beep_type_E console_type = BEEP_TYPE_UNSET; - char *console_device = NULL; - - - void do_beep(unsigned int freq) { -- const uintptr_t argp = (freq != 0 ? (CLOCK_TICK_RATE/freq) : freq) & 0xffff; -+ switch (console_type) { -+ case BEEP_TYPE_CONSOLE: if (1) { -+ const uintptr_t argp = ((freq != 0) ? (CLOCK_TICK_RATE/freq) : freq) & 0xffff; -+ (void) ioctl(console_fd, KIOCSOUND, argp); -+ } -+ break; -+ case BEEP_TYPE_EVDEV: if (1) { -+ struct input_event e; -+ -+ memset(&e, 0, sizeof(e)); -+ e.type = EV_SND; -+ e.code = SND_TONE; -+ e.value = freq; - -- if(console_type == BEEP_TYPE_CONSOLE) { -- if(ioctl(console_fd, KIOCSOUND, argp) < 0) { -- putchar('\a'); /* Output the only beep we can, in an effort to fall back on usefulness */ -- perror("ioctl"); -+ (void) write(console_fd, &e, sizeof(struct input_event)); - } -- } else { -- /* BEEP_TYPE_EVDEV */ -- struct input_event e; -- -- memset(&e, 0, sizeof(e)); -- e.type = EV_SND; -- e.code = SND_TONE; -- e.value = freq; -- -- if(write(console_fd, &e, sizeof(struct input_event)) < 0) { -- putchar('\a'); /* See above */ -- perror("write"); -- } -+ break; -+ case BEEP_TYPE_UNSET: -+ /* Do nothing, if this case should ever happen which it should not. */ -+ break; - } - } - -@@ -258,7 +269,19 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) { - result->verbose = 1; - break; - case 'e' : /* also --device */ -- console_device = optarg; -+ if (strncmp("/dev/input/", optarg, strlen("/dev/input/")) == 0) { -+ /* If device name starts with /dev/input/, we can assume evdev -+ * input device beeping is wished for and the corresponding -+ * device is somewhere in /dev/input/. Otherwise, the default -+ * console beeper will be used with its default name(s). */ -+ console_device = optarg; -+ } else { -+ fprintf(stderr, "%s: " -+ "Not opening device '%s'. If you do need this device, please " -+ "report that fact to .\n", -+ argv[0], optarg); -+ exit(EXIT_FAILURE); -+ } - break; - case 'h' : /* notice that this is also --help */ - default : -@@ -290,11 +313,42 @@ void play_beep(beep_parms_t parms) { - } - - -+/* Open only character device special file (with race condition). -+ * -+ * We check whether this is a character device special file before -+ * opening as for some devices, opening has an effect and we can avoid -+ * this effect for those devices here. -+ * -+ * We still need to make sure that the file we have actually opened -+ * actually is a character device special file after we have actually -+ * opened it. -+ */ -+int open_chr(const char *const argv0, const char *filename, int flags) -+{ -+ struct stat sb; -+ if (-1 == stat(filename, &sb)) { -+ return -1; -+ } -+ if (S_ISCHR(sb.st_mode)) { -+ return open(filename, flags); -+ } else { -+ fprintf(stderr, "%s: " -+ "console file '%s' is not a character device special file\n", -+ argv0, filename); -+ exit(1); -+ } -+} -+ - - int main(int argc, char **argv) { - char sin[4096], *ptr; -- -+ -+ /* Parse command line */ - beep_parms_t *parms = (beep_parms_t *)malloc(sizeof(beep_parms_t)); -+ if (NULL == parms) { -+ perror("malloc"); -+ exit(1); -+ } - parms->freq = 0; - parms->length = DEFAULT_LENGTH; - parms->reps = DEFAULT_REPS; -@@ -304,29 +358,90 @@ int main(int argc, char **argv) { - parms->verbose = 0; - parms->next = NULL; - -- signal(SIGINT, handle_signal); -- signal(SIGTERM, handle_signal); - parse_command_line(argc, argv, parms); - -- /* try to snag the console */ -- if(console_device) -- console_fd = open(console_device, O_WRONLY); -- else -- if((console_fd = open("/dev/tty0", O_WRONLY)) == -1) -- console_fd = open("/dev/vc/0", O_WRONLY); -- -- if(console_fd == -1) { -- fprintf(stderr, "Could not open %s for writing\n", -- console_device != NULL ? console_device : "/dev/tty0 or /dev/vc/0"); -- printf("\a"); /* Output the only beep we can, in an effort to fall back on usefulness */ -- perror("open"); -+ /* Try opening a console device */ -+ if (console_device) { -+ console_fd = open_chr(argv[0], console_device, O_WRONLY); -+ } else { -+ static char *console_device_list[] = -+ { "/dev/tty0", -+ "/dev/vc/0", -+ "/dev/input/by-path/platform-pcspkr-event-spkr", -+ }; -+ for (size_t i=0; i<(sizeof(console_device_list)/sizeof(console_device_list[0])); ++i) { -+ if ((console_fd = open_chr(argv[0], console_device_list[i], O_WRONLY)) != -1) { -+ console_device = console_device_list[i]; -+ break; -+ } -+ } -+ } -+ -+ if (console_fd == -1) { -+ const int saved_errno = errno; -+ fprintf(stderr, "%s: Could not open %s for writing: %s\n", -+ argv[0], -+ ((console_device != NULL) ? console_device : -+ "console device"), -+ strerror(saved_errno)); -+ /* Output the only beep we can, in an effort to fall back on usefulness */ -+ printf("\a"); - exit(1); - } - -- if (ioctl(console_fd, EVIOCGSND(0)) != -1) -+ /* Verify that console_fd is actually a character device special file */ -+ if (1) { -+ struct stat sb; -+ if (-1 == fstat(console_fd, &sb)) { -+ perror("fstat"); -+ exit(1); -+ } -+ if (S_ISCHR(sb.st_mode)) { -+ /* GOOD: console_fd is a character device special file. Use it. */ -+ } else { -+ /* BAD: console_fd is not a character device special file. Do -+ * not use it any further, and certainly DO NOT WRITE to it. -+ */ -+ fprintf(stderr, -+ "%s: opened console '%s' is not a character special device\n", -+ argv[0], console_device); -+ exit(1); -+ } -+ } -+ -+ /* Determine the API supported by the opened console device */ -+ if (ioctl(console_fd, EVIOCGSND(0)) != -1) { -+ if (parms->verbose) { -+ printf("Using BEEP_TYPE_EVDEV\n"); -+ } - console_type = BEEP_TYPE_EVDEV; -- else -+ } else if (ioctl(console_fd, KIOCSOUND, 0) >= 0) { -+ /* turning off the beeps should be a safe way to check for API support */ -+ if (parms->verbose) { -+ printf("Using BEEP_TYPE_CONSOLE\n"); -+ } - console_type = BEEP_TYPE_CONSOLE; -+ } else { -+ fprintf(stderr, -+ "%s: console device '%s' does not support either API\n", -+ argv[0], console_device); -+ /* Output the only beep we can, in an effort to fall back on usefulness */ -+ printf("\a"); -+ exit(1); -+ } -+ -+ /* At this time, we know what API to use on which device, and we do -+ * not have to fall back onto printing '\a' any more. -+ */ -+ -+ /* After all the initialization has happened and the global -+ * variables used to communicate with the signal handlers have -+ * actually been set up properly, we can finally install the signal -+ * handlers. As we do not start making any noises, there is no need -+ * to install the signal handlers any earlier. -+ */ -+ signal(SIGINT, handle_signal); -+ signal(SIGTERM, handle_signal); - - /* this outermost while loop handles the possibility that -n/--new has been - used, i.e. that we have multiple beeps specified. Each iteration will diff --git a/0014-Update-COPYING-with-new-FSF-address.patch b/0014-Update-COPYING-with-new-FSF-address.patch deleted file mode 100644 index d314c4d..0000000 --- a/0014-Update-COPYING-with-new-FSF-address.patch +++ /dev/null @@ -1,138 +0,0 @@ -From fbadf12841399cce6c218091adc032ad897256de Mon Sep 17 00:00:00 2001 -From: Hans Ulrich Niedermann -Date: Fri, 28 Dec 2018 05:34:54 +0100 -Subject: [PATCH] Update COPYING with new FSF address - ---- - COPYING | 43 +++++++++++++++++++++---------------------- - 1 file changed, 21 insertions(+), 22 deletions(-) - -diff --git a/COPYING b/COPYING -index 60549be..d159169 100644 ---- a/COPYING -+++ b/COPYING -@@ -1,12 +1,12 @@ -- GNU GENERAL PUBLIC LICENSE -- Version 2, June 1991 -+ GNU GENERAL PUBLIC LICENSE -+ Version 2, June 1991 - -- Copyright (C) 1989, 1991 Free Software Foundation, Inc. -- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ Copyright (C) 1989, 1991 Free Software Foundation, Inc., -+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -- Preamble -+ Preamble - - The licenses for most software are designed to take away your - freedom to share and change it. By contrast, the GNU General Public -@@ -15,7 +15,7 @@ software--to make sure the software is free for all its users. This - General Public License applies to most of the Free Software - Foundation's software and to any other program whose authors commit to - using it. (Some other Free Software Foundation software is covered by --the GNU Library General Public License instead.) You can apply it to -+the GNU Lesser General Public License instead.) You can apply it to - your programs, too. - - When we speak of free software, we are referring to freedom, not -@@ -55,8 +55,8 @@ patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and - modification follow. -- -- GNU GENERAL PUBLIC LICENSE -+ -+ GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -@@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions: - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) -- -+ - These requirements apply to the modified work as a whole. If - identifiable sections of that work are not derived from the Program, - and can be reasonably considered independent and separate works in -@@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent - access to copy the source code from the same place counts as - distribution of the source code, even though third parties are not - compelled to copy the source along with the object code. -- -+ - 4. You may not copy, modify, sublicense, or distribute the Program - except as expressly provided under this License. Any attempt - otherwise to copy, modify, sublicense or distribute the Program is -@@ -225,7 +225,7 @@ impose that choice. - - This section is intended to make thoroughly clear what is believed to - be a consequence of the rest of this License. -- -+ - 8. If the distribution and/or use of the Program is restricted in - certain countries either by patents or by copyrighted interfaces, the - original copyright holder who places the Program under this License -@@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals - of preserving the free status of all derivatives of our free software and - of promoting the sharing and reuse of software generally. - -- NO WARRANTY -+ NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY - FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -@@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER - PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE - POSSIBILITY OF SUCH DAMAGES. - -- END OF TERMS AND CONDITIONS -- -- How to Apply These Terms to Your New Programs -+ END OF TERMS AND CONDITIONS -+ -+ How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest - possible use to the public, the best way to achieve this is to make it -@@ -291,7 +291,7 @@ convey the exclusion of warranty; and each file should have at least - the "copyright" line and a pointer to where the full notice is found. - - -- Copyright (C) 19yy -+ Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by -@@ -303,17 +303,16 @@ the "copyright" line and a pointer to where the full notice is found. - 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, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- -+ You should have received a copy of the GNU General Public License along -+ with this program; if not, write to the Free Software Foundation, Inc., -+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Also add information on how to contact you by electronic and paper mail. - - If the program is interactive, make it output a short notice like this - when it starts in an interactive mode: - -- Gnomovision version 69, Copyright (C) 19yy name of author -+ Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. -@@ -336,5 +335,5 @@ necessary. Here is a sample; alter the names: - This General Public License does not permit incorporating your program into - proprietary programs. If your program is a subroutine library, you may - consider it more useful to permit linking proprietary applications with the --library. If this is what you want to do, use the GNU Library General -+library. If this is what you want to do, use the GNU Lesser General - Public License instead of this License. diff --git a/0015-If-do_beep-sees-error-from-API-exit-program.patch b/0015-If-do_beep-sees-error-from-API-exit-program.patch deleted file mode 100644 index a91c4aa..0000000 --- a/0015-If-do_beep-sees-error-from-API-exit-program.patch +++ /dev/null @@ -1,39 +0,0 @@ -From d419a0daa59a3afbbc14354feed2701ed2109afb Mon Sep 17 00:00:00 2001 -From: Hans Ulrich Niedermann -Date: Fri, 28 Dec 2018 06:01:10 +0100 -Subject: [PATCH] If do_beep() sees error from API, exit program - ---- - beep.c | 12 ++++++++++-- - 1 file changed, 10 insertions(+), 2 deletions(-) - -diff --git a/beep.c b/beep.c -index 2a7404e..1b9d8ca 100644 ---- a/beep.c -+++ b/beep.c -@@ -114,7 +114,11 @@ void do_beep(unsigned int freq) { - switch (console_type) { - case BEEP_TYPE_CONSOLE: if (1) { - const uintptr_t argp = ((freq != 0) ? (CLOCK_TICK_RATE/freq) : freq) & 0xffff; -- (void) ioctl(console_fd, KIOCSOUND, argp); -+ if (-1 == ioctl(console_fd, KIOCSOUND, argp)) { -+ /* If we cannot use the sound API, we cannot silence the sound either */ -+ perror("ioctl KIOCSOUND"); -+ exit(1); -+ } - } - break; - case BEEP_TYPE_EVDEV: if (1) { -@@ -125,7 +129,11 @@ void do_beep(unsigned int freq) { - e.code = SND_TONE; - e.value = freq; - -- (void) write(console_fd, &e, sizeof(struct input_event)); -+ if (sizeof(e) != write(console_fd, &e, sizeof(e))) { -+ /* If we cannot use the sound API, we cannot silence the sound either */ -+ perror("write EV_SND"); -+ exit(1); -+ } - } - break; - case BEEP_TYPE_UNSET: diff --git a/0016-Make-the-evdev-device-the-first-to-look-for.patch b/0016-Make-the-evdev-device-the-first-to-look-for.patch deleted file mode 100644 index ec8ceb2..0000000 --- a/0016-Make-the-evdev-device-the-first-to-look-for.patch +++ /dev/null @@ -1,28 +0,0 @@ -From fabfacd13d915c9b4f062b0ad08066d8e5119701 Mon Sep 17 00:00:00 2001 -From: Hans Ulrich Niedermann -Date: Fri, 28 Dec 2018 22:27:12 +0100 -Subject: [PATCH] Make the evdev device the first to look for - -If the evdev device has been set user writable, that will -make beep beep without trying any other devices and root-only -APIs. ---- - beep.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/beep.c b/beep.c -index 1b9d8ca..29f0941 100644 ---- a/beep.c -+++ b/beep.c -@@ -373,9 +373,9 @@ int main(int argc, char **argv) { - console_fd = open_chr(argv[0], console_device, O_WRONLY); - } else { - static char *console_device_list[] = -- { "/dev/tty0", -+ { "/dev/input/by-path/platform-pcspkr-event-spkr", -+ "/dev/tty0", - "/dev/vc/0", -- "/dev/input/by-path/platform-pcspkr-event-spkr", - }; - for (size_t i=0; i<(sizeof(console_device_list)/sizeof(console_device_list[0])); ++i) { - if ((console_fd = open_chr(argv[0], console_device_list[i], O_WRONLY)) != -1) { diff --git a/0017-Use-realpath-3-on-device-name.patch b/0017-Use-realpath-3-on-device-name.patch deleted file mode 100644 index 3914e36..0000000 --- a/0017-Use-realpath-3-on-device-name.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 9d2d0c1ac754a39711143ba85ac451d989ef0517 Mon Sep 17 00:00:00 2001 -From: Hans Ulrich Niedermann -Date: Fri, 28 Dec 2018 22:28:20 +0100 -Subject: [PATCH] Use realpath(3) on device name - -Also allow the standard devices - - /dev/console - /dev/tty0 - /dev/vc/0 - -when given explicitly on the command line. ---- - beep.c | 41 +++++++++++++++++++++++++++++------------ - 1 file changed, 29 insertions(+), 12 deletions(-) - -diff --git a/beep.c b/beep.c -index 29f0941..17115f7 100644 ---- a/beep.c -+++ b/beep.c -@@ -19,6 +19,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -277,18 +278,34 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) { - result->verbose = 1; - break; - case 'e' : /* also --device */ -- if (strncmp("/dev/input/", optarg, strlen("/dev/input/")) == 0) { -- /* If device name starts with /dev/input/, we can assume evdev -- * input device beeping is wished for and the corresponding -- * device is somewhere in /dev/input/. Otherwise, the default -- * console beeper will be used with its default name(s). */ -- console_device = optarg; -- } else { -- fprintf(stderr, "%s: " -- "Not opening device '%s'. If you do need this device, please " -- "report that fact to .\n", -- argv[0], optarg); -- exit(EXIT_FAILURE); -+ if (1) { -+ static char realpath_optarg[PATH_MAX+1]; -+ if (realpath(optarg, realpath_optarg) == NULL) { -+ const int saved_errno = errno; -+ fprintf(stderr, "%s: " -+ "could not run realpath(3) on '%s': %s\n", -+ argv[0], optarg, strerror(saved_errno)); -+ exit(EXIT_FAILURE); -+ } -+ if (strncmp("/dev/input/", realpath_optarg, strlen("/dev/input/")) == 0) { -+ /* If device name starts with /dev/input/, we can assume evdev -+ * input device beeping is wished for and the corresponding -+ * device is somewhere in /dev/input/. Otherwise, the default -+ * console beeper will be used with its default name(s). */ -+ console_device = realpath_optarg; -+ } else if (strcmp("/dev/console", realpath_optarg) == 0) { -+ console_device = realpath_optarg; -+ } else if (strcmp("/dev/tty0", realpath_optarg) == 0) { -+ console_device = realpath_optarg; -+ } else if (strcmp("/dev/vc/0", realpath_optarg) == 0) { -+ console_device = realpath_optarg; -+ } else { -+ fprintf(stderr, "%s: " -+ "Not using device '%s'. If you do need this device, please " -+ "report that fact to .\n", -+ argv[0], optarg); -+ exit(EXIT_FAILURE); -+ } - } - break; - case 'h' : /* notice that this is also --help */ diff --git a/0018-refuse-to-run-when-setuid-or-setgid-usage-detected.patch b/0018-refuse-to-run-when-setuid-or-setgid-usage-detected.patch deleted file mode 100644 index 18ac9c2..0000000 --- a/0018-refuse-to-run-when-setuid-or-setgid-usage-detected.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 67ab66e3201c35b37c2fcabb6b4faeecfee27806 Mon Sep 17 00:00:00 2001 -From: Hans Ulrich Niedermann -Date: Fri, 28 Dec 2018 22:26:05 +0100 -Subject: [PATCH] refuse to run when setuid or setgid usage detected - -Bail out without doing anything when - - getuid() != geteuid() - -or - - getgit() != getegid() - -hoping this catches all setuid-root or setgid-root invocations. ---- - beep.c | 8 ++++++++ - 1 file changed, 8 insertions(+) - -diff --git a/beep.c b/beep.c -index 17115f7..64512b6 100644 ---- a/beep.c -+++ b/beep.c -@@ -368,6 +368,14 @@ int open_chr(const char *const argv0, const char *filename, int flags) - int main(int argc, char **argv) { - char sin[4096], *ptr; - -+ /* bail out if running setuid or setgid */ -+ if ((getuid() != geteuid()) || (getgid() != getegid())) { -+ fprintf(stderr, "%s: " -+ "running setuid or setgid, which is not supported for security reasons", -+ argv[0]); -+ exit(1); -+ } -+ - /* Parse command line */ - beep_parms_t *parms = (beep_parms_t *)malloc(sizeof(beep_parms_t)); - if (NULL == parms) { diff --git a/0019-add-setuid-setgid-check-output-newline.patch b/0019-add-setuid-setgid-check-output-newline.patch deleted file mode 100644 index 819d16f..0000000 --- a/0019-add-setuid-setgid-check-output-newline.patch +++ /dev/null @@ -1,39 +0,0 @@ -From f30015eb60f83359f3caef95ef1484410a7bd138 Mon Sep 17 00:00:00 2001 -From: Hans Ulrich Niedermann -Date: Sat, 29 Dec 2018 01:48:29 +0100 -Subject: [PATCH] add setuid/setgid check output newline - -Also adds a few comments about that check and prints -the UIDs and GIDs involved in the issue. ---- - beep.c | 15 +++++++++++++-- - 1 file changed, 13 insertions(+), 2 deletions(-) - -diff --git a/beep.c b/beep.c -index 64512b6..a72b4e1 100644 ---- a/beep.c -+++ b/beep.c -@@ -368,10 +368,21 @@ int open_chr(const char *const argv0, const char *filename, int flags) - int main(int argc, char **argv) { - char sin[4096], *ptr; - -- /* bail out if running setuid or setgid */ -+ /* Bail out if running setuid or setgid. -+ * -+ * It is near impossible to make beep setuid-safe: -+ * -+ * * We open files for writing, and may even write to them. -+ * -+ * * Checking the device file with realpath leaks information. -+ * -+ * So we refuse running setuid or setgid. -+ */ - if ((getuid() != geteuid()) || (getgid() != getegid())) { -+ fprintf(stderr, "%s: uid=%d euid=%d gid=%d egid=%d\n", -+ argv[0], getuid(), geteuid(), getgid(), getegid()); - fprintf(stderr, "%s: " -- "running setuid or setgid, which is not supported for security reasons", -+ "running setuid or setgid, which is not supported for security reasons\n", - argv[0]); - exit(1); - } diff --git a/0020-refuse-to-run-under-sudo.patch b/0020-refuse-to-run-under-sudo.patch deleted file mode 100644 index 37265d2..0000000 --- a/0020-refuse-to-run-under-sudo.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 8f1faeee39864d2d147df52b8519a5ae4d2320b0 Mon Sep 17 00:00:00 2001 -From: Hans Ulrich Niedermann -Date: Sat, 29 Dec 2018 03:39:48 +0100 -Subject: [PATCH] refuse to run under sudo - ---- - beep.c | 9 +++++++++ - 1 file changed, 9 insertions(+) - -diff --git a/beep.c b/beep.c -index a72b4e1..17eeaa5 100644 ---- a/beep.c -+++ b/beep.c -@@ -387,6 +387,15 @@ int main(int argc, char **argv) { - exit(1); - } - -+ /* Bail out if running under sudo. -+ * -+ * For the reasoning, see the setuid comment above. -+ */ -+ if (getenv("SUDO_COMMAND") || getenv("SUDO_USER") || getenv("SUDO_UID") || getenv("SUDO_GID")) { -+ fprintf(stderr, "%s: Running under sudo. Set up permissions for /dev/input/by-path/platform-pcspkr-event-spkr instead.\n", argv[0]); -+ exit(1); -+ } -+ - /* Parse command line */ - beep_parms_t *parms = (beep_parms_t *)malloc(sizeof(beep_parms_t)); - if (NULL == parms) { diff --git a/0021-print-console_device-in-verbose-message-on-BEEP_TYPE.patch b/0021-print-console_device-in-verbose-message-on-BEEP_TYPE.patch deleted file mode 100644 index 255bebb..0000000 --- a/0021-print-console_device-in-verbose-message-on-BEEP_TYPE.patch +++ /dev/null @@ -1,29 +0,0 @@ -From e04c6badef5c71c5a1d17f87928990e7e5130533 Mon Sep 17 00:00:00 2001 -From: Hans Ulrich Niedermann -Date: Sat, 29 Dec 2018 00:49:14 +0100 -Subject: [PATCH] print console_device in verbose message on BEEP_TYPE_ - ---- - beep.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/beep.c b/beep.c -index 17eeaa5..3be5f0b 100644 ---- a/beep.c -+++ b/beep.c -@@ -465,13 +465,13 @@ int main(int argc, char **argv) { - /* Determine the API supported by the opened console device */ - if (ioctl(console_fd, EVIOCGSND(0)) != -1) { - if (parms->verbose) { -- printf("Using BEEP_TYPE_EVDEV\n"); -+ printf("Using BEEP_TYPE_EVDEV on '%s'\n", console_device); - } - console_type = BEEP_TYPE_EVDEV; - } else if (ioctl(console_fd, KIOCSOUND, 0) >= 0) { - /* turning off the beeps should be a safe way to check for API support */ - if (parms->verbose) { -- printf("Using BEEP_TYPE_CONSOLE\n"); -+ printf("Using BEEP_TYPE_CONSOLE on '%s'\n", console_device); - } - console_type = BEEP_TYPE_CONSOLE; - } else { diff --git a/0022-restructure-device-whitelisting-code.patch b/0022-restructure-device-whitelisting-code.patch deleted file mode 100644 index 4c3f923..0000000 --- a/0022-restructure-device-whitelisting-code.patch +++ /dev/null @@ -1,98 +0,0 @@ -From 0542134f05df18219ec575026e9e6c31ae98fbee Mon Sep 17 00:00:00 2001 -From: Hans Ulrich Niedermann -Date: Sat, 29 Dec 2018 01:11:59 +0100 -Subject: [PATCH] restructure device whitelisting code - -We now allow - - /dev/input/** - /dev/console - /dev/tty - /dev/vc/ - -where is an arbitrary sequence of decimal digits. ---- - beep.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++------------ - 1 file changed, 46 insertions(+), 12 deletions(-) - -diff --git a/beep.c b/beep.c -index 3be5f0b..10a3349 100644 ---- a/beep.c -+++ b/beep.c -@@ -174,6 +174,50 @@ void usage_bail(const char *executable_name) { - } - - -+/* whether character is a digit */ -+int is_digit(char c) -+{ -+ return (('0' <= c) && (c <= '9')); -+} -+ -+ -+/* whether string consists of at least one digit, and only digits */ -+int is_number(const char *const str) -+{ -+ if (str[0] == '\0') { -+ return 0; -+ } -+ for (size_t i=0; str[i] != '\0'; ++i) { -+ if (!is_digit(str[i])) { -+ return 0; -+ } -+ } -+ return 1; -+} -+ -+ -+/* whether device is on whitelist */ -+int is_device_whitelisted(const char *const dev) -+{ -+ if (strncmp("/dev/input/", dev, strlen("/dev/input/")) == 0) { -+ /* If device name starts with /dev/input/, we can assume evdev -+ * input device beeping is wished for and the corresponding -+ * device is somewhere in /dev/input/. -+ */ -+ return 1; -+ } else if (strcmp("/dev/console", dev) == 0) { -+ return 1; -+ } else if ((strncmp("/dev/tty", dev, 8) == 0) && is_number(&dev[8])) { -+ /* match numbered /dev/tty devices */ -+ return 1; -+ } else if ((strncmp("/dev/vc/", dev, 8) == 0) && is_number(&dev[8])) { -+ /* match numbered /dev/vc/ devices */ -+ return 1; -+ } -+ return 0; -+} -+ -+ - /* Parse the command line. argv should be untampered, as passed to main. - * Beep parameters returned in result, subsequent parameters in argv will over- - * ride previous ones. -@@ -287,23 +331,13 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) { - argv[0], optarg, strerror(saved_errno)); - exit(EXIT_FAILURE); - } -- if (strncmp("/dev/input/", realpath_optarg, strlen("/dev/input/")) == 0) { -- /* If device name starts with /dev/input/, we can assume evdev -- * input device beeping is wished for and the corresponding -- * device is somewhere in /dev/input/. Otherwise, the default -- * console beeper will be used with its default name(s). */ -- console_device = realpath_optarg; -- } else if (strcmp("/dev/console", realpath_optarg) == 0) { -- console_device = realpath_optarg; -- } else if (strcmp("/dev/tty0", realpath_optarg) == 0) { -- console_device = realpath_optarg; -- } else if (strcmp("/dev/vc/0", realpath_optarg) == 0) { -+ if (is_device_whitelisted(realpath_optarg)) { - console_device = realpath_optarg; - } else { - fprintf(stderr, "%s: " - "Not using device '%s'. If you do need this device, please " - "report that fact to .\n", -- argv[0], optarg); -+ argv[0], realpath_optarg); - exit(EXIT_FAILURE); - } - } diff --git a/0023-README-beep.1-remove-setuid-suggestions.patch b/0023-README-beep.1-remove-setuid-suggestions.patch deleted file mode 100644 index 663cb1e..0000000 --- a/0023-README-beep.1-remove-setuid-suggestions.patch +++ /dev/null @@ -1,136 +0,0 @@ -From f8c6cbbceb3776aa64397cdf856e50f3bc4d8332 Mon Sep 17 00:00:00 2001 -From: Hans Ulrich Niedermann -Date: Sat, 29 Dec 2018 05:07:30 +0100 -Subject: [PATCH] README, beep.1; remove setuid suggestions - ---- - README | 54 ++++++------------------------------------------------ - beep.1 | 35 ++--------------------------------- - 2 files changed, 8 insertions(+), 81 deletions(-) - -diff --git a/README b/README -index f4db57b..7a97a0c 100644 ---- a/README -+++ b/README -@@ -1,6 +1,8 @@ - Intro - ----- - -+ [ This file partially contains outdated information ] -+ - I just got so tired of being limited to printf("\a"); when I wanted a terminal - beep. This program isn't supposed to be anything stupendous, it's just - supposed to get the job done. Its intended purpose in life is to live inside -@@ -25,54 +27,10 @@ There is a github repository of this code at: git://github.com/johnath/beep.git - A note about ioctl - ------------------ - --As noted in the man page, some users are running into a situation where beep --dies with a complaint from ioctl(). The reason for this, as Peter Tirsek was --nice enough to point out to me, stems from how the kernel handles beep's --attempt to poke at (for non-programmers: ioctl is a sort of catch-all function --that lets you poke at things that have no other predefined poking-at mechanism) --the tty, which is how it beeps. The short story is, the kernel checks that --either: -- --- you are the superuser --- you own the current tty -- --What this means is that root can always make beep work (to the best of my --knowledge!), and that any local user can make beep work, BUT a non-root remote --user cannot use beep in it's natural state. What's worse, an xterm, or other --x-session counts, as far as the kernel is concerned, as 'remote', so beep --won't work from a non-priviledged xterm either. I had originally chalked this --up to a bug, but there's actually nothing I can do about it, and it really is --a Good Thing that the kernel does things this way. There is also a solution. -- --By default beep is not installed with the suid bit set, because that would --just be zany. On the other hand, if you do make it suid root, all your --problems with beep bailing on ioctl calls will magically vanish, which is --pleasant, and the only reason not to is that any suid program is a potential --security hole. Conveniently, beep is very short, so auditing it is pretty --straightforward. -- --Decide for yourself, of course, but it looks safe to me - there's only one --buffer and fgets doesn't let it overflow, there's only one file opening, and --while there is a potential race condition there, it's with /dev/console. If --someone can exploit this race by replacing /dev/console, you've got bigger --problems. :) -- --So the quick solution is beep is not beeping when you want it to is: -- --$ su --Password: --# chmod 4755 /usr/bin/beep -- --(or wherever you put it) -- --The one snag is that this will give any little nitwit the ability to run beep --successfully - make sure this is what you want. If it isn't, a slightly more --complex fix would be something like: -- --# chgrp beep /usr/bin/beep --# chmod 4750 /usr/bin/beep -- --and then add only beep-worthy users to the 'beep' group. -+ [ Section removed for suggesting making `beep` suid root. A new -+ section on `beep` and permissions will be added soon -- -+ without any setuid or sudo priviledge escalation risks. ] -+ - - Playing Songs - ------------- -diff --git a/beep.1 b/beep.1 -index 3de05ec..5b19409 100644 ---- a/beep.1 -+++ b/beep.1 -@@ -75,32 +75,8 @@ will produce first two 1000Hz beeps, then 5 beeps at the default tone, but only - - .SH IOCTL WACKINESS - .PP --Some users will encounter a situation where beep dies with a complaint from ioctl(). The reason for this, as Peter Tirsek was nice enough to point out to me, stems from how the kernel handles beep's attempt to poke at (for non-programmers: ioctl is a sort of catch-all function that lets you poke at things that have no other predefined poking-at mechanism) the tty, which is how it beeps. The short story is, the kernel checks that either: --.PP --- you are the superuser --.PP --- you own the current tty --.PP --What this means is that root can always make beep work (to the best of my knowledge!), and that any local user can make beep work, BUT a non-root remote user cannot use beep in it's natural state. What's worse, an xterm, or other x-session counts, as far as the kernel is concerned, as 'remote', so beep won't work from a non-priviledged xterm either. I had originally chalked this up to a bug, but there's actually nothing I can do about it, and it really is a Good Thing that the kernel does things this way. There is also a solution. --.PP --By default beep is not installed with the suid bit set, because that would just be zany. On the other hand, if you do make it suid root, all your problems with beep bailing on ioctl calls will magically vanish, which is pleasant, and the only reason not to is that any suid program is a potential security hole. Conveniently, beep is very short, so auditing it is pretty straightforward. --.PP --Decide for yourself, of course, but it looks safe to me - there's only one buffer and fgets doesn't let it overflow, there's only one file opening, and while there is a potential race condition there, it's with /dev/console. If someone can exploit this race by replacing /dev/console, you've got bigger problems. :) --.PP --So the quick, only, and likely safe solution if beep is not beeping when you want it to is (as root): --.PP --# chmod 4755 /usr/bin/beep --.PP --(or wherever you put it) --.PP --The one snag is that this will give any little nitwit the ability to run beep successfully - make sure this is what you want. If it isn't, a slightly more complex fix would be something like: --.PP --# chgrp beep /usr/bin/beep -+Section removed for suggesting making \fBbeep\fR suid root. A new section on \fBbeep\fR and permissions will be added soon \-\- without any setuid or sudo priviledge escalation risks. - --# chmod 4750 /usr/bin/beep -- --.PP --and then add only beep-worthy users to the 'beep' group. - .SH FREQUENCY TABLE - .PP - Several people have asked for some basic help translating music notes to frequencies. There are a lot of music notes, and several tables online will give you translations, but here are \fIapproximate\fR numbers for the octave of middle C, to get you started. -@@ -126,14 +102,7 @@ C 523.2 - .PP - None that I'm aware of, though see the \fBIOCTL WACKINESS\fR section. - .SH REPORTING BUGS --Report bugs to -+Report bugs to https://github.com/johnath/beep/issues - .SH AUTHOR - .PP - This program was written by Johnathan Nightingale (johnath@johnath.com) and is distributed under the GNU General Public License. For more contributing information, check the source, and past contributors can be found in CREDITS. -- -- -- -- -- -- -- diff --git a/90-pcspkr-beep.rules b/90-pcspkr-beep.rules deleted file mode 100644 index c250f8d..0000000 --- a/90-pcspkr-beep.rules +++ /dev/null @@ -1,2 +0,0 @@ -# Give write access to the PC speaker to "beep" group so they can run "beep" -ACTION=="add", SUBSYSTEM=="input", ATTRS{name}=="PC Speaker", ENV{DEVNAME}!="", RUN+="/usr/bin/setfacl -m g:beep:w '$env{DEVNAME}'" diff --git a/README-packaging.md b/README-packaging.md index 7b6b280..e0017b9 100644 --- a/README-packaging.md +++ b/README-packaging.md @@ -1,9 +1,4 @@ -Some commands to help the packager: +The Fedora `beep` package +========================= - [user@host ndim-beep.git]$ git format-patch --no-signature -N -o ../ beep-1.3-release - [user@host ndim-beep.git]$ cd .. - [user@host beep]$ git checkout 000[124-9]-*.patch - [user@host beep]$ for p in 00*.patch; do sed -n 's/^Subject: \[PATCH\] /# /p' "$p"; printf "%-15s %s\n" "Patch$(echo "$p" | sed 's/^0\{1,3\}\([0-9]\{1,3\}\).*/\1/'):" "$p"; echo; done | xsel - -(rpm would complain about the '%' characters were we to put this into -a comment in the spec file). +See `PACKAGING.md`. diff --git a/beep-README.fedora b/README.fedora similarity index 100% rename from beep-README.fedora rename to README.fedora diff --git a/beep-modprobe.conf b/beep-modprobe.conf deleted file mode 100644 index c1ddb22..0000000 --- a/beep-modprobe.conf +++ /dev/null @@ -1,3 +0,0 @@ -# Uncomment the following line to have the pcspkr driver loaded -# automatically on boot -# alias platform:pcspkr pcspkr diff --git a/beep.csh b/beep.csh deleted file mode 100644 index d8cc30a..0000000 --- a/beep.csh +++ /dev/null @@ -1,8 +0,0 @@ -# If `/etc/sudoers.d/beep` is configured to allow the non-root user -# access to beep without entering a password, alias `beep` to do that. -# If sudo does require a password, the non-root users will see a sudo -# error message instead of a beep error message. - -if (($euid != 0) && (-x /usr/bin/beep) && (-x /usr/bin/sudo)) then - alias beep 'sudo -n /usr/bin/beep' -endif diff --git a/beep.sh b/beep.sh deleted file mode 100644 index 1825537..0000000 --- a/beep.sh +++ /dev/null @@ -1,8 +0,0 @@ -# If `/etc/sudoers.d/beep` is configured to allow the non-root user -# access to beep without entering a password, alias `beep` to do that. -# If sudo does require a password, the non-root users will see a sudo -# error message instead of a beep error message. - -if [ "${EUID:-}" != 0 ] && [ -x /usr/bin/beep ] && [ -x /usr/bin/sudo ]; then - alias beep='sudo -n /usr/bin/beep' -fi diff --git a/beep.spec b/beep.spec index 142d738..57836f8 100644 --- a/beep.spec +++ b/beep.spec @@ -1,104 +1,24 @@ +%global etcudevrulesdir %{_sysconfdir}/udev/rules.d + Summary: Beep the PC speaker any number of ways Name: beep -Version: 1.3 -Release: 26%{?dist} +Version: 1.4.0 +Release: 1%{?dist} Group: Applications/System License: GPLv2+ -URL: http://www.johnath.com/beep/ +URL: https://github.com/spkr-beep/beep/ -# Upstream github repo: https://github.com/johnath/beep +# Upstream github repo: https://github.com/spkr-beep/beep # hun github repo: https://github.com/ndim/beep -# Alternative source URLs to download: -# curl -L -o beep-github.tar.gz https://api.github.com/repos/johnath/beep/tarball -# curl -L -o beep-g0d790fa.tar.gz https://api.github.com/repos/johnath/beep/tarball/0d790fa -# curl -L -o beep-1.3-gdb6f31a.tar.gz https://api.github.com/repos/johnath/beep/tarball/db6f31a60303e41def1a1d0705164cd5b6d75492 -Source0: http://www.johnath.com/beep/%{name}-%{version}.tar.gz +# Alternative source URL to download: +# curl -L -o spkr-beep-beep-1.4.0-db395a5.tar.gz https://api.github.com/repos/spkr-beep/beep/tarball/db395a53dc862eda80b3c1abf0d9136be97ad15a +Source0: https://github.com/spkr-beep/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz # Fedora specific files -Source1: %{name}-README.fedora -Source2: %{name}-modprobe.conf -Source3: %{name}.sudoers -Source4: %{name}.csh -Source5: %{name}.sh -Source6: 90-pcspkr-beep.rules - - -# Helping commands see README-packaging.md - -# Fix from upstream github repo -Patch1: 0001-Fixed-Makefile.patch - -# Fix from upstream github repo -Patch2: 0002-Add-more-error-detection.patch - -# No sense to add stuff to .gitignore in our source dir -# Patch3: 0003-Gitignorance.patch - -# Fix from upstream github repo -Patch4: 0004-also-catch-SIGTERM-for-stopping-the-beep.patch - -# Make build/install more user and packaging friendly -# https://github.com/johnath/beep/pull/6 -Patch5: 0005-Make-build-install-more-user-and-packaging-friendly.patch - -# Preserve file modification time on install -# https://github.com/johnath/beep/pull/6 -Patch6: 0006-Preserve-file-modification-time-on-install.patch - -# Fix indentation/if brace error -Patch7: 0007-Fix-indentation-if-brace-error.patch - -# Apply CVE-2018-0492.patch from Debian package -Patch8: 0008-Apply-CVE-2018-0492.patch-from-Debian-package.patch - -# store uncompressed beep.1 file in source repository -Patch9: 0009-store-uncompressed-beep.1-file-in-source-repository.patch - -# No sense to add stuff to .gitignore in our source dir -# gitignore: intermediate build results -# Patch10: 0010-gitignore-intermediate-build-results.patch - -# constrain freq and period values -Patch11: 0011-constrain-freq-and-period-values.patch - -# get rid of a few signed int and unchecked input value ranges -Patch12: 0012-get-rid-of-a-few-signed-int-and-unchecked-input-valu.patch - -# Fix CVE-2018-1000532 and mitigate against related issues -Patch13: 0013-Fix-CVE-2018-1000532-and-mitigate-against-related-is.patch - -# Update COPYING with new FSF address -Patch14: 0014-Update-COPYING-with-new-FSF-address.patch - -# If do_beep() sees error from API, exit program -Patch15: 0015-If-do_beep-sees-error-from-API-exit-program.patch - -# Make the evdev device the first to look for -Patch16: 0016-Make-the-evdev-device-the-first-to-look-for.patch - -# Use realpath(3) on device name -Patch17: 0017-Use-realpath-3-on-device-name.patch - -# refuse to run when setuid or setgid usage detected -Patch18: 0018-refuse-to-run-when-setuid-or-setgid-usage-detected.patch - -# add setuid/setgid check output newline -Patch19: 0019-add-setuid-setgid-check-output-newline.patch - -# refuse to run under sudo -Patch20: 0020-refuse-to-run-under-sudo.patch - -# print console_device in verbose message on BEEP_TYPE_ -Patch21: 0021-print-console_device-in-verbose-message-on-BEEP_TYPE.patch - -# restructure device whitelisting code -Patch22: 0022-restructure-device-whitelisting-code.patch - -# README, beep.1; remove setuid suggestions -Patch23: 0023-README-beep.1-remove-setuid-suggestions.patch +Source1: README.fedora BuildRequires: gcc @@ -120,44 +40,22 @@ what's interesting, but it's real good at that notifying part. %prep %setup -q -%patch1 -p1 -b 0001 -%patch2 -p1 -b 0002 -%patch4 -p1 -b 0004 -%patch5 -p1 -b 0005 -%patch6 -p1 -b 0006 -%patch7 -p1 -b 0007 -%patch8 -p1 -b 0008 -%patch9 -p1 -b 0009 -rm -f beep.1.gz -%patch11 -p1 -b 0011 -%patch12 -p1 -b 0012 -%patch13 -p1 -b 0013 -%patch14 -p1 -b 0014 -%patch15 -p1 -b 0015 -%patch16 -p1 -b 0016 -%patch17 -p1 -b 0017 -%patch18 -p1 -b 0018 -%patch19 -p1 -b 0019 -%patch20 -p1 -b 0020 -%patch21 -p1 -b 0021 -%patch22 -p1 -b 0022 -%patch23 -p1 -b 0023 cp -p %{SOURCE1} README.fedora %build -make %{?_smp_mflags} FLAGS="" CFLAGS="-Wall -Wextra -Werror -std=gnu99 -pedantic ${RPM_OPT_FLAGS}" +make %{?_smp_mflags} COMPILERS=gcc CFLAGS_gcc="-Wall -Wextra -std=gnu99 -pedantic -Werror ${RPM_OPT_FLAGS}" CPPFLAGS_gcc="" %install rm -rf "$RPM_BUILD_ROOT" make install DESTDIR="$RPM_BUILD_ROOT" -install -d -m 0755 "$RPM_BUILD_ROOT/%{_sysconfdir}/modprobe.d/" -install -p -m 0644 %{SOURCE2} "$RPM_BUILD_ROOT/%{_sysconfdir}/modprobe.d/beep.conf" +install -d -m 0755 "$RPM_BUILD_ROOT/%{_sysconfdir}/modprobe.d/" +install -p -m 0644 pcspkr-beep.conf "$RPM_BUILD_ROOT/%{_sysconfdir}/modprobe.d/beep.conf" -install -d -m 0755 "$RPM_BUILD_ROOT/%{_udevrulesdir}/" -install -p -m 0644 %{SOURCE6} "$RPM_BUILD_ROOT/%{_udevrulesdir}/" +install -d -m 0755 "$RPM_BUILD_ROOT/%{etcudevrulesdir}/" +install -p -m 0644 90-pcspkr-beep.rules "$RPM_BUILD_ROOT/%{etcudevrulesdir}/" %pre @@ -166,15 +64,18 @@ exit 0 %files -%doc CHANGELOG COPYING CREDITS README +%doc CHANGELOG COPYING CREDITS README.md PERMISSIONS.md %attr(0755,root,root) %{_bindir}/beep %{_mandir}/man1/beep.1.gz %doc README.fedora %config(noreplace) %attr(0644,root,root) %{_sysconfdir}/modprobe.d/beep.conf -%{_udevrulesdir}/90-pcspkr-beep.rules +%config(noreplace) %{etcudevrulesdir}/90-pcspkr-beep.rules %changelog +* Fri Jan 4 2019 Hans Ulrich Niedermann - 1.4.0-1 +- Update to beep-1.4.0 + * Sat Dec 29 2018 Hans Ulrich Niedermann - 1.3-26 - Stop shipping old sudo related config files - Refuse to run when run via sudo diff --git a/beep.sudoers b/beep.sudoers deleted file mode 100644 index 130144d..0000000 --- a/beep.sudoers +++ /dev/null @@ -1,5 +0,0 @@ -# Allow user 'jane' to run beep as root (if uncommented) -# jane ALL=NOPASSWD: /usr/bin/beep - -# Allow all members of the group 'mock' to run beep as root (if uncommented) -# %mock ALL=NOPASSWD: /usr/bin/beep diff --git a/sources b/sources index 0ac109c..0359046 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -49c340ceb95dbda3f97b2daafac7892a beep-1.3.tar.gz +SHA512 (beep-1.4.0.tar.gz) = a81119128f3cc6797c1fbb30e0a3480e62d74d3d650973cbe1d75de59f8dc60b95286bede5164d05bd93a18722b7a77c044cedbdb52a63b99358ddafd7ac877b From cbc662f837203242e85d0fb8e737f217ae6cd6fa Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 8 Jan 2019 07:59:39 +0100 Subject: [PATCH 33/80] clean up specfile with new guidelines in hand --- beep.spec | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/beep.spec b/beep.spec index 57836f8..27f98ec 100644 --- a/beep.spec +++ b/beep.spec @@ -5,7 +5,6 @@ Name: beep Version: 1.4.0 Release: 1%{?dist} -Group: Applications/System License: GPLv2+ URL: https://github.com/spkr-beep/beep/ @@ -28,6 +27,9 @@ BuildRequires: systemd Requires(pre): shadow-utils +Requires: /etc/modprobe.d/ +Requires: /etc/udev/rules.d/ + %description Beep allows the user to control the PC speaker with precision, @@ -40,23 +42,26 @@ what's interesting, but it's real good at that notifying part. %prep %setup -q -cp -p %{SOURCE1} README.fedora +install -m 0644 -p %{SOURCE1} README.fedora %build -make %{?_smp_mflags} COMPILERS=gcc CFLAGS_gcc="-Wall -Wextra -std=gnu99 -pedantic -Werror ${RPM_OPT_FLAGS}" CPPFLAGS_gcc="" +make %{?_smp_mflags} COMPILERS=gcc CFLAGS_gcc="-Wall -Wextra -std=gnu99 -pedantic -Werror ${RPM_OPT_FLAGS}" LDFLAGS="${RPM_LD_FLAGS}" CPPFLAGS_gcc="" %install rm -rf "$RPM_BUILD_ROOT" make install DESTDIR="$RPM_BUILD_ROOT" -install -d -m 0755 "$RPM_BUILD_ROOT/%{_sysconfdir}/modprobe.d/" -install -p -m 0644 pcspkr-beep.conf "$RPM_BUILD_ROOT/%{_sysconfdir}/modprobe.d/beep.conf" +install -d -m 0755 "$RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/" +install -p -m 0644 pcspkr-beep.conf "$RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/beep.conf" -install -d -m 0755 "$RPM_BUILD_ROOT/%{etcudevrulesdir}/" -install -p -m 0644 90-pcspkr-beep.rules "$RPM_BUILD_ROOT/%{etcudevrulesdir}/" +install -d -m 0755 "$RPM_BUILD_ROOT%{etcudevrulesdir}/" +install -p -m 0644 90-pcspkr-beep.rules "$RPM_BUILD_ROOT%{etcudevrulesdir}/" +# Fedora Packaging GL says Fedora wants to choose and do the compression itself + +gunzip "$RPM_BUILD_ROOT%{_mandir}/man1/beep.1.gz" %pre getent group beep >/dev/null || groupadd -r beep @@ -64,9 +69,10 @@ exit 0 %files -%doc CHANGELOG COPYING CREDITS README.md PERMISSIONS.md +%license %{_pkgdocdir}/COPYING +%doc CHANGELOG CREDITS README.md PERMISSIONS.md %attr(0755,root,root) %{_bindir}/beep -%{_mandir}/man1/beep.1.gz +%{_mandir}/man1/beep.1* %doc README.fedora %config(noreplace) %attr(0644,root,root) %{_sysconfdir}/modprobe.d/beep.conf %config(noreplace) %{etcudevrulesdir}/90-pcspkr-beep.rules From ff47ff157f26bff5060c9b37327a83e7a3225c44 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 8 Jan 2019 08:00:43 +0100 Subject: [PATCH 34/80] Update to 1.4.1 --- beep.spec | 6 +++++- sources | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/beep.spec b/beep.spec index 27f98ec..c28e793 100644 --- a/beep.spec +++ b/beep.spec @@ -2,7 +2,7 @@ Summary: Beep the PC speaker any number of ways Name: beep -Version: 1.4.0 +Version: 1.4.1 Release: 1%{?dist} License: GPLv2+ @@ -13,6 +13,7 @@ URL: https://github.com/spkr-beep/beep/ # Alternative source URL to download: # curl -L -o spkr-beep-beep-1.4.0-db395a5.tar.gz https://api.github.com/repos/spkr-beep/beep/tarball/db395a53dc862eda80b3c1abf0d9136be97ad15a +# curl -L -o spkr-beep-beep-1.4.1-9ffa7a1.tar.gz https://api.github.com/repos/spkr-beep/beep/tarball/9ffa7a1feb195a60db20792890225b69720984d3 Source0: https://github.com/spkr-beep/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz @@ -79,6 +80,9 @@ exit 0 %changelog +* Tue Jan 8 2019 Hans Ulrich Niedermann - 1.4.1-1 +- Update to beep-1.4.1 + * Fri Jan 4 2019 Hans Ulrich Niedermann - 1.4.0-1 - Update to beep-1.4.0 diff --git a/sources b/sources index 0359046..0bd9d78 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (beep-1.4.0.tar.gz) = a81119128f3cc6797c1fbb30e0a3480e62d74d3d650973cbe1d75de59f8dc60b95286bede5164d05bd93a18722b7a77c044cedbdb52a63b99358ddafd7ac877b +SHA512 (beep-1.4.1.tar.gz) = f4330dc7dd562a95b006e382528adcb2bbb5891f7f3e4a5a9962137aa96c3126cb87d6e85dee03d605a3eaf2080f428a4e3652518c38cbc75e649b5cced3a5a7 From 14bf4ee54703413f7b502652b993d696f3280246 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 15 Jan 2019 20:47:23 +0100 Subject: [PATCH 35/80] Change directory Requires to use package names This should avoid the errors thrown by the automated dist.rpmdeplint. --- beep.spec | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/beep.spec b/beep.spec index c28e793..24b02ed 100644 --- a/beep.spec +++ b/beep.spec @@ -28,8 +28,10 @@ BuildRequires: systemd Requires(pre): shadow-utils -Requires: /etc/modprobe.d/ -Requires: /etc/udev/rules.d/ +# /etc/modprobe.d/ +Requires: kmod +# /etc/udev/rules.d/ +Requires: systemd-udev %description From 704d834cd4091e03b7acecc222f04146fc73e681 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 18 Jan 2019 03:21:04 +0100 Subject: [PATCH 36/80] Update to beep-1.4.3 --- beep.spec | 5 ++++- sources | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/beep.spec b/beep.spec index 24b02ed..6f6212e 100644 --- a/beep.spec +++ b/beep.spec @@ -2,7 +2,7 @@ Summary: Beep the PC speaker any number of ways Name: beep -Version: 1.4.1 +Version: 1.4.3 Release: 1%{?dist} License: GPLv2+ @@ -82,6 +82,9 @@ exit 0 %changelog +* Fri Jan 18 2019 Hans Ulrich Niedermann - 1.4.3-1 +- Update to beep-1.4.3 + * Tue Jan 8 2019 Hans Ulrich Niedermann - 1.4.1-1 - Update to beep-1.4.1 diff --git a/sources b/sources index 0bd9d78..851a2c8 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (beep-1.4.1.tar.gz) = f4330dc7dd562a95b006e382528adcb2bbb5891f7f3e4a5a9962137aa96c3126cb87d6e85dee03d605a3eaf2080f428a4e3652518c38cbc75e649b5cced3a5a7 +SHA512 (beep-1.4.3.tar.gz) = 2de9f88fec12c77293e02303332705045785f012623f6798f5742f05e4b9d403a6d392b73f0db44d3f44a75e10b56eb016f566cfac11868636be57104f101050 From b8c78793f08c9ebeca42dd18712d8880848eb8f9 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 31 Jan 2019 14:31:30 +0000 Subject: [PATCH 37/80] - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- beep.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beep.spec b/beep.spec index 6f6212e..2738ec3 100644 --- a/beep.spec +++ b/beep.spec @@ -3,7 +3,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.4.3 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2+ URL: https://github.com/spkr-beep/beep/ @@ -82,6 +82,9 @@ exit 0 %changelog +* Thu Jan 31 2019 Fedora Release Engineering - 1.4.3-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + * Fri Jan 18 2019 Hans Ulrich Niedermann - 1.4.3-1 - Update to beep-1.4.3 From 9bbcce32d1a9c88cfc3f0a165b1548c53364cb71 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 22 Mar 2019 23:39:18 +0100 Subject: [PATCH 38/80] Update to beep-1.4.4 release Summary of the changes in the beep-1.4.4 release: * ship our own modprobe.d and udev rules.d files * install udev rules into /usr/lib/udev/rules.d/ (if the sysadmin want their own rules, they can add them to /etc/udev/rules.d/) * new out of the box permission setup: allow local users and "beep" group * add note on using sox/play with modern sound infrastructure * adapt beep(1) man page to mention README.fedora * set compiler flags for "make install" (just in case) * install extra source files directly from %{SOURCEn} * ship the installed doc files as %doc (no need to install them from source) --- 70-pcspkr-beep.rules | 2 ++ 90-pcspkr-beep.rules | 2 ++ README-packaging.md | 4 ---- README.fedora | 22 ++++++++++++++++------ beep.spec | 41 +++++++++++++++++++++++++++-------------- pcspkr-beep.conf | 3 +++ sources | 2 +- 7 files changed, 51 insertions(+), 25 deletions(-) create mode 100644 70-pcspkr-beep.rules create mode 100644 90-pcspkr-beep.rules delete mode 100644 README-packaging.md create mode 100644 pcspkr-beep.conf diff --git a/70-pcspkr-beep.rules b/70-pcspkr-beep.rules new file mode 100644 index 0000000..ef31672 --- /dev/null +++ b/70-pcspkr-beep.rules @@ -0,0 +1,2 @@ +# Give write access to the PC speaker to the user logged in on the current virtual console +ACTION=="add", SUBSYSTEM=="input", ATTRS{name}=="PC Speaker", ENV{DEVNAME}!="", TAG+="uaccess" diff --git a/90-pcspkr-beep.rules b/90-pcspkr-beep.rules new file mode 100644 index 0000000..7090857 --- /dev/null +++ b/90-pcspkr-beep.rules @@ -0,0 +1,2 @@ +# Give write access to the PC speaker to the "beep" group so group members can run "beep" +ACTION=="add", SUBSYSTEM=="input", ATTRS{name}=="PC Speaker", ENV{DEVNAME}!="", RUN+="/usr/bin/setfacl -m g:beep:w '$env{DEVNAME}'" diff --git a/README-packaging.md b/README-packaging.md deleted file mode 100644 index e0017b9..0000000 --- a/README-packaging.md +++ /dev/null @@ -1,4 +0,0 @@ -The Fedora `beep` package -========================= - -See `PACKAGING.md`. diff --git a/README.fedora b/README.fedora index 972a0d5..cafd144 100644 --- a/README.fedora +++ b/README.fedora @@ -40,6 +40,9 @@ as root and verify that you hear the beep coming from the PC speaker. 2. Add non-root users to the "beep" group ----------------------------------------- +For more information on permission setup, please consult +/usr/share/doc/beep/PERMISSIONS.md file. + To add user `jane` to the `beep` group, have root run [root@host ~]# usermod jane -a -G beep @@ -79,15 +82,22 @@ To check the permission of the PC speaker device file, run 3. Avoid using `beep` --------------------- -An alternative way to get sound output for non-root users without -becoming root works if the system has a sound card set up with a -speaker connected to it. The standard 440Hz square wave which `beep` -emits can be played through the standard sound infrastructure with the -command `play` from the `sox` package (more pleasant examples are in -the `sox(1)` man page): +An alternative way to get sound output for non-root users works if the +system has a sound card set up with a speaker connected to it. + +The standard 440Hz square wave which `beep` emits can be played +through the standard sound infrastructure with the command `play` from +the `sox` package (more pleasant examples are in the `sox(1)` man +page): [jane@host ~]$ play -q -n synth 0.3 square 440 +However, modern desktop systems with the freedesktop.org suite of +middleware (systemd user sessions, pulseaudio audio routing, etc.) +will probably not be set up to allow use of the sound infrastructure +for users other than the user currently logged into the current +virtual console. + 4. Example Usage ---------------- diff --git a/beep.spec b/beep.spec index 2738ec3..9c10c5d 100644 --- a/beep.spec +++ b/beep.spec @@ -1,9 +1,7 @@ -%global etcudevrulesdir %{_sysconfdir}/udev/rules.d - Summary: Beep the PC speaker any number of ways Name: beep -Version: 1.4.3 -Release: 2%{?dist} +Version: 1.4.4 +Release: 1%{?dist} License: GPLv2+ URL: https://github.com/spkr-beep/beep/ @@ -19,6 +17,9 @@ Source0: https://github.com/spkr-beep/%{name}/archive/v%{version}/%{name} # Fedora specific files Source1: README.fedora +Source2: 70-pcspkr-beep.rules +Source3: 90-pcspkr-beep.rules +Source4: pcspkr-beep.conf BuildRequires: gcc @@ -30,7 +31,7 @@ Requires(pre): shadow-utils # /etc/modprobe.d/ Requires: kmod -# /etc/udev/rules.d/ +# /etc/udev/rules.d/ and /usr/lib/udev/rules.d/ Requires: systemd-udev @@ -46,6 +47,7 @@ what's interesting, but it's real good at that notifying part. %prep %setup -q install -m 0644 -p %{SOURCE1} README.fedora +sed -i 's|^\.\\" \(\.BR .*\)README.Distro\(.*\)|\1README.fedora\2|' beep.1.in && : #" %build @@ -54,34 +56,45 @@ make %{?_smp_mflags} COMPILERS=gcc CFLAGS_gcc="-Wall -Wextra -std=gnu99 -pedanti %install rm -rf "$RPM_BUILD_ROOT" -make install DESTDIR="$RPM_BUILD_ROOT" +make install DESTDIR="$RPM_BUILD_ROOT" COMPILERS=gcc CFLAGS_gcc="-Wall -Wextra -std=gnu99 -pedantic -Werror ${RPM_OPT_FLAGS}" LDFLAGS="${RPM_LD_FLAGS}" CPPFLAGS_gcc="" -install -d -m 0755 "$RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/" -install -p -m 0644 pcspkr-beep.conf "$RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/beep.conf" +install -d -m 0755 "$RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/" +install -p -m 0644 "%{SOURCE4}" "$RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/beep.conf" -install -d -m 0755 "$RPM_BUILD_ROOT%{etcudevrulesdir}/" -install -p -m 0644 90-pcspkr-beep.rules "$RPM_BUILD_ROOT%{etcudevrulesdir}/" +install -d -m 0755 "$RPM_BUILD_ROOT%{_udevrulesdir}/" +install -p -m 0644 "%{SOURCE2}" "$RPM_BUILD_ROOT%{_udevrulesdir}/" +install -p -m 0644 "%{SOURCE3}" "$RPM_BUILD_ROOT%{_udevrulesdir}/" # Fedora Packaging GL says Fedora wants to choose and do the compression itself - gunzip "$RPM_BUILD_ROOT%{_mandir}/man1/beep.1.gz" + %pre getent group beep >/dev/null || groupadd -r beep exit 0 %files +%doc README.fedora %license %{_pkgdocdir}/COPYING -%doc CHANGELOG CREDITS README.md PERMISSIONS.md +%doc %{_pkgdocdir}/CHANGELOG +%doc %{_pkgdocdir}/CREDITS +%doc %{_pkgdocdir}/README.md +%doc %{_pkgdocdir}/PERMISSIONS.md %attr(0755,root,root) %{_bindir}/beep %{_mandir}/man1/beep.1* -%doc README.fedora %config(noreplace) %attr(0644,root,root) %{_sysconfdir}/modprobe.d/beep.conf -%config(noreplace) %{etcudevrulesdir}/90-pcspkr-beep.rules +%{_udevrulesdir}/70-pcspkr-beep.rules +%{_udevrulesdir}/90-pcspkr-beep.rules %changelog +* Tue Apr 2 2019 Hans Ulrich Niedermann - 1.4.4-1 +- Update to beep-1.4.4 +- Install default udev rules to /usr/lib/udev/rules.d/ (not /etc/udev/) +- Give the currently locally logged in user PC speaker access out of the box +- Have beep(1) man page mention README.fedora + * Thu Jan 31 2019 Fedora Release Engineering - 1.4.3-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild diff --git a/pcspkr-beep.conf b/pcspkr-beep.conf new file mode 100644 index 0000000..a9fbe0c --- /dev/null +++ b/pcspkr-beep.conf @@ -0,0 +1,3 @@ +# Uncomment the following line to have the pcspkr.ko driver +# load automatically on boot +# alias platform:pcspkr pcspkr diff --git a/sources b/sources index 851a2c8..2a3eb9b 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (beep-1.4.3.tar.gz) = 2de9f88fec12c77293e02303332705045785f012623f6798f5742f05e4b9d403a6d392b73f0db44d3f44a75e10b56eb016f566cfac11868636be57104f101050 +SHA512 (beep-1.4.4.tar.gz) = cfaecbebbbd0596bee5f304c3bd74968d06873037d054def0907dfd36e5bd6e7fbd7d7051eacedd20480b88f8b4e343db05eb5d3dde0fdced33756545b630373 From b8d4138ba1d5b0c22cb325bddabd3e9ef8f7dccc Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 24 Jul 2019 19:10:24 +0000 Subject: [PATCH 39/80] - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- beep.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beep.spec b/beep.spec index 9c10c5d..1e6b718 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.4.4 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2+ URL: https://github.com/spkr-beep/beep/ @@ -89,6 +89,9 @@ exit 0 %changelog +* Wed Jul 24 2019 Fedora Release Engineering - 1.4.4-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + * Tue Apr 2 2019 Hans Ulrich Niedermann - 1.4.4-1 - Update to beep-1.4.4 - Install default udev rules to /usr/lib/udev/rules.d/ (not /etc/udev/) From a794ec4747e64b92fbff56b62b0cad5644b670fa Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 20 Dec 2019 05:34:54 +0100 Subject: [PATCH 40/80] Update to the beep-1.4.6 release Summary of the changes compared to the beep-1.4.4 release: * Use va_copy() macro in function with va_list parameter to avoid possible bug * Use BEEP_LOG_LEVEL environment variable for default log level --- beep.spec | 9 +++++++-- sources | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/beep.spec b/beep.spec index 1e6b718..1413639 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep -Version: 1.4.4 -Release: 2%{?dist} +Version: 1.4.6 +Release: 1%{?dist} License: GPLv2+ URL: https://github.com/spkr-beep/beep/ @@ -89,6 +89,11 @@ exit 0 %changelog +* Fri Dec 20 2019 Hans Ulrich Niedermann - 1.4.6-1 +- Update to beep-1.4.6 +- Use BEEP_LOG_LEVEL environment variable for default log level +- Avoid possible bug related to not using va_copy() with a va_list parameter + * Wed Jul 24 2019 Fedora Release Engineering - 1.4.4-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild diff --git a/sources b/sources index 2a3eb9b..ea19b4e 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (beep-1.4.4.tar.gz) = cfaecbebbbd0596bee5f304c3bd74968d06873037d054def0907dfd36e5bd6e7fbd7d7051eacedd20480b88f8b4e343db05eb5d3dde0fdced33756545b630373 +SHA512 (beep-1.4.6.tar.gz) = 753ab7f22624defba5645c2fceb1382137641fa8f219875783d5809d0bd344c530176b46a61a1d783bb2e5feb17c8137868e02744e1ee5d9e7ec331dbe1fe417 From 4f70157bb9541936026be36fd60daf55fd280f9e Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 1 Jan 2020 22:44:23 +0100 Subject: [PATCH 41/80] Grammatical fixes for %description --- beep.spec | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/beep.spec b/beep.spec index 1413639..a39ac39 100644 --- a/beep.spec +++ b/beep.spec @@ -38,10 +38,10 @@ Requires: systemd-udev %description Beep allows the user to control the PC speaker with precision, allowing different sounds to indicate different events. While it -can be run quite happily on the command line, its intended place -of residence is within shell/Perl scripts, notifying the user when -something interesting occurs. Of course, it has no notion of -what's interesting, but it's real good at that notifying part. +can be run quite happily from the command line, its intended place +of use is within scripts, notifying the user when something +interesting occurs. Of course, it has no notion of what is +interesting, but it is really good at the notifying part. %prep From 24330ac51ee74d75cf27629597fb6176a6fcde75 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 1 Jan 2020 22:51:17 +0100 Subject: [PATCH 42/80] Update to beep-1.4.7 Update to beep-1.4.7: - Install contrib scripts for both successfully and failing sounding beeps. - beep installs its man page uncompressed, so the spec file can stop unzipping it for the packaging scripts to be able to do their compression magic. --- beep.spec | 11 +++++++---- sources | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/beep.spec b/beep.spec index a39ac39..bae9ece 100644 --- a/beep.spec +++ b/beep.spec @@ -1,6 +1,6 @@ Summary: Beep the PC speaker any number of ways Name: beep -Version: 1.4.6 +Version: 1.4.7 Release: 1%{?dist} License: GPLv2+ @@ -65,9 +65,6 @@ install -d -m 0755 "$RPM_BUILD_ROOT%{_udevrulesdir}/" install -p -m 0644 "%{SOURCE2}" "$RPM_BUILD_ROOT%{_udevrulesdir}/" install -p -m 0644 "%{SOURCE3}" "$RPM_BUILD_ROOT%{_udevrulesdir}/" -# Fedora Packaging GL says Fedora wants to choose and do the compression itself -gunzip "$RPM_BUILD_ROOT%{_mandir}/man1/beep.1.gz" - %pre getent group beep >/dev/null || groupadd -r beep @@ -81,6 +78,8 @@ exit 0 %doc %{_pkgdocdir}/CREDITS %doc %{_pkgdocdir}/README.md %doc %{_pkgdocdir}/PERMISSIONS.md +%doc %{_pkgdocdir}/contrib/failure-beeps +%doc %{_pkgdocdir}/contrib/success-beeps %attr(0755,root,root) %{_bindir}/beep %{_mandir}/man1/beep.1* %config(noreplace) %attr(0644,root,root) %{_sysconfdir}/modprobe.d/beep.conf @@ -89,6 +88,10 @@ exit 0 %changelog +* Wed Jan 1 2020 Hans Ulrich Niedermann - 1.4.7-1 +- Update to beep-1.4.7 +- Install contrib scripts for both successfully and failing sounding beeps. + * Fri Dec 20 2019 Hans Ulrich Niedermann - 1.4.6-1 - Update to beep-1.4.6 - Use BEEP_LOG_LEVEL environment variable for default log level diff --git a/sources b/sources index ea19b4e..886e63a 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (beep-1.4.6.tar.gz) = 753ab7f22624defba5645c2fceb1382137641fa8f219875783d5809d0bd344c530176b46a61a1d783bb2e5feb17c8137868e02744e1ee5d9e7ec331dbe1fe417 +SHA512 (beep-1.4.7.tar.gz) = a1482a16f971c56dc6a62047fa449c96519c897d2e8cb18dcc06178564943c1eb3b9d9106ca6b76054e0fa109e3b161fb8e9ec1966a02d0d739222b5434b71c7 From b17da1af4c5d191cfdbab099cb2488087b0330ae Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Tue, 28 Jan 2020 12:51:16 +0000 Subject: [PATCH 43/80] - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- beep.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beep.spec b/beep.spec index bae9ece..f7d5c4f 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.4.7 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2+ URL: https://github.com/spkr-beep/beep/ @@ -88,6 +88,9 @@ exit 0 %changelog +* Tue Jan 28 2020 Fedora Release Engineering - 1.4.7-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + * Wed Jan 1 2020 Hans Ulrich Niedermann - 1.4.7-1 - Update to beep-1.4.7 - Install contrib scripts for both successfully and failing sounding beeps. From c0fc04897881374971184c92f14742de47067f43 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Mon, 27 Jul 2020 13:02:28 +0000 Subject: [PATCH 44/80] - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- beep.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beep.spec b/beep.spec index f7d5c4f..f71af90 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.4.7 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2+ URL: https://github.com/spkr-beep/beep/ @@ -88,6 +88,9 @@ exit 0 %changelog +* Mon Jul 27 2020 Fedora Release Engineering - 1.4.7-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + * Tue Jan 28 2020 Fedora Release Engineering - 1.4.7-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild From e3e5a10920f19b6640e9cc52ff016b31c196e508 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 17 Dec 2020 02:48:56 +0000 Subject: [PATCH 45/80] Add BuildRequires: make https://fedoraproject.org/wiki/Changes/Remove_make_from_BuildRoot --- beep.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/beep.spec b/beep.spec index f71af90..1c8adad 100644 --- a/beep.spec +++ b/beep.spec @@ -26,6 +26,7 @@ BuildRequires: gcc BuildRequires: glibc-kernheaders # for the udev macros BuildRequires: systemd +BuildRequires: make Requires(pre): shadow-utils From 05b52566e256a933264815adcb65b558316a8cf9 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Tue, 26 Jan 2021 01:03:25 +0000 Subject: [PATCH 46/80] - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- beep.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beep.spec b/beep.spec index 1c8adad..b757f65 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.4.7 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2+ URL: https://github.com/spkr-beep/beep/ @@ -89,6 +89,9 @@ exit 0 %changelog +* Tue Jan 26 2021 Fedora Release Engineering - 1.4.7-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + * Mon Jul 27 2020 Fedora Release Engineering - 1.4.7-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild From 47695ab28190633d3c87aae5c9e06dad931d1557 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Thu, 25 Mar 2021 15:57:53 +0100 Subject: [PATCH 47/80] Fix indentation of "BuildRequires: make" The "BuildRequires: make" was added by a script running through all of Fedora, so they did not check that the indentation matches that of the surrounding lines of spec file. This adapts this line to match the indentation of the other lines in the spec file. --- beep.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beep.spec b/beep.spec index b757f65..4dd4980 100644 --- a/beep.spec +++ b/beep.spec @@ -26,7 +26,7 @@ BuildRequires: gcc BuildRequires: glibc-kernheaders # for the udev macros BuildRequires: systemd -BuildRequires: make +BuildRequires: make Requires(pre): shadow-utils From c3ad7fc60d3c917fd21ea3101fcf9ce73bb75810 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Thu, 25 Mar 2021 00:40:54 +0100 Subject: [PATCH 48/80] Update README.fedora to match beep-1.4.x permission setup --- README.fedora | 68 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 27 deletions(-) diff --git a/README.fedora b/README.fedora index cafd144..d4e3561 100644 --- a/README.fedora +++ b/README.fedora @@ -1,14 +1,14 @@ Content ======= - 1. Load the pkspkr.ko Kernel Driver Module (required) - 2. Add non-root users to the "beep" group - 3. Avoid using `beep` - 4. Example Usage + 1. Load the `pkspkr.ko` Kernel Driver Module (required) + 2. Permission setup for non-root users (for non-local logins) + 3. When and how to avoid using `beep` + 4. Example usage of `beep` -1. Load the pkspkr.ko Kernel Driver Module (required) ------------------------------------------------------ +1. Load the `pkspkr.ko` Kernel Driver Module (required) +------------------------------------------------------- To have a working PC speaker beep on Fedora >= 12, you must load the kernel driver module `pcspkr.ko` first. @@ -18,31 +18,45 @@ You can do this manually as root as follows: [root@host ~]# modprobe pcspkr If you want the system to automatically load the pcspkr driver the -next time it boots, uncomment the +next time it boots (very much recommended), uncomment the line alias platform:pcspkr pcspkr -line in the `/etc/modprobe.d/beep.conf` config file. +in the `/etc/modprobe.d/beep.conf` config file. You can check whether pcspkr.ko is loaded by running - [root@host ~]# lsmod | grep pcspkr - -as root. + [user@host ~]$ lsmod | grep pcspkr When pcspkr is loaded, you can run [root@host ~]# beep -as root and verify that you hear the beep coming from the PC speaker. +as root and as a non-root user + + [user@host ~]$ beep + +and verify that you hear the beep coming from the PC speaker. -2. Add non-root users to the "beep" group ------------------------------------------ +2. Permission setup for non-root users (for non-local logins) +------------------------------------------------------------- For more information on permission setup, please consult /usr/share/doc/beep/PERMISSIONS.md file. +On Fedora, if a user is currently logged in locally via either a +graphical session or a getty@ttyN.service text session on the virtual +console, that user will automatically be able to access the device +special file `/dev/input/by-path/platform-pcspkr-event-spkr` which +`beep` uses to access the PC speaker. + +This means that for many cases, no special permission setup is +required for a user to run beep. + +For other cases (such as e.g. users only logged in via ssh sessions), +you can add the respective user to the `beep` group. + To add user `jane` to the `beep` group, have root run [root@host ~]# usermod jane -a -G beep @@ -64,43 +78,43 @@ their group membership as follows: To check the permission of the PC speaker device file, run [user@host ~]$ ls -lH /dev/input/by-path/platform-pcspkr-event-spkr - crw-rw----+ 1 root input 13, 85 29. Dez 02:52 /dev/input/by-path/platform-pcspkr-event-spkr + crw-rw----+ 1 root input 13, 85 Dec 29 13:52 /dev/input/by-path/platform-pcspkr-event-spkr [user@host ~]$ getfacl /dev/input/by-path/platform-pcspkr-event-spkr getfacl: Removing leading '/' from absolute path names # file: dev/input/by-path/platform-pcspkr-event-spkr # owner: root # group: input user::rw- - group:beep:-w- + user:user:rw- group::rw- + group:beep:-w- mask::rw- other::--- [user@host ~]$ -3. Avoid using `beep` ---------------------- +3. When and how to avoid using `beep` +------------------------------------- An alternative way to get sound output for non-root users works if the system has a sound card set up with a speaker connected to it. -The standard 440Hz square wave which `beep` emits can be played +E.g. the standard 440Hz square wave which `beep` emits can be played through the standard sound infrastructure with the command `play` from -the `sox` package (more pleasant examples are in the `sox(1)` man -page): +the `sox` package (more pleasant examples are shown in the `sox(1)` +man page): [jane@host ~]$ play -q -n synth 0.3 square 440 However, modern desktop systems with the freedesktop.org suite of middleware (systemd user sessions, pulseaudio audio routing, etc.) -will probably not be set up to allow use of the sound infrastructure -for users other than the user currently logged into the current -virtual console. +may not be set up to allow use of the sound infrastructure for users +other than the user currently logged into the current virtual console. -4. Example Usage ----------------- +4. Example Usage of `beep` +-------------------------- An acoustic notification when a long running compile job finishes (whether the build was successful or not) could be done with @@ -109,4 +123,4 @@ An acoustic notification when a long running compile job finishes or - [bill@host ~/rpms/foobar]$ fedpkg mockbuild; beep + [bill@host ~/rpms/foobar]$ if fedpkg mockbuild; then /usr/share/doc/beep/contrib/success-beeps; else /usr/share/doc/beep/contrib/failure-beeps; fi From 2b9e64956b2dea3bc2daa7f80ec0765e6c24586a Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Thu, 25 Mar 2021 00:43:55 +0100 Subject: [PATCH 49/80] Add "Recommends: kmod(pcspkr.ko)" We "recommend" the kernel driver and do not "require" it in order to not break cases where beep is installed on systems other than bare-metal PC hardware such as containers. This assumes the people using the "beep" package can deal with a "beep" invocation not producing a beep on those other systems. The alternative would be to "require" the kernel driver which would mean that you could not install beep inside a container, even if that container is run in a priviledged way with access to the host's pcspkr.ko. While the kernel supports more speaker drivers, the only hardware platforms with a speaker driver supported by Fedora use pcspkr.ko (PCSPKR_PLATFORM in the kernel config). Slightly (but not quite) similar packages would be floppy-support and joystick-support which both "require" their respective kernel drivers, but they make less sense inside containers. --- README.fedora | 11 ++++++++--- beep.spec | 22 +++++++++++++++++++++- pcspkr-beep.conf | 17 +++++++++++++++-- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/README.fedora b/README.fedora index d4e3561..5d47f80 100644 --- a/README.fedora +++ b/README.fedora @@ -10,10 +10,15 @@ Content 1. Load the `pkspkr.ko` Kernel Driver Module (required) ------------------------------------------------------- -To have a working PC speaker beep on Fedora >= 12, you must load the -kernel driver module `pcspkr.ko` first. +To have a working PC speaker beep, the kernel driver module +`pcspkr.ko` must be loaded. -You can do this manually as root as follows: +On Fedora >= 32, you need to install the `kernel-modules-extra` +package first which contains the `pcspkr.ko` kernel driver module. + +On Fedora >= 12, you need to explicitly make the kernel load the +driver module `pcspkr.ko`. You can do this manually as root as +follows: [root@host ~]# modprobe pcspkr diff --git a/beep.spec b/beep.spec index 4dd4980..02938d4 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.4.7 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv2+ URL: https://github.com/spkr-beep/beep/ @@ -28,6 +28,23 @@ BuildRequires: glibc-kernheaders BuildRequires: systemd BuildRequires: make +# We "recommend" the kernel driver and do not "require" it in order to +# not break cases where beep is installed on systems other than +# bare-metal PC hardware such as containers. +# +# This assumes the people using the "beep" package can deal with a +# "beep" invocation not producing a beep on those other systems. +# +# The alternative would be to "require" the kernel driver which would +# mean that you could not install beep inside a container, even if +# that container is run in a priviledged way with access to the host's +# pcspkr.ko. +# +# While the kernel supports more speaker drivers, the only hardware +# platforms with a speaker driver supported by Fedora use pcspkr.ko +# (PCSPKR_PLATFORM in the kernel config). +Recommends: kmod(pcspkr.ko) + Requires(pre): shadow-utils # /etc/modprobe.d/ @@ -89,6 +106,9 @@ exit 0 %changelog +* Wed Mar 24 2021 Hans Ulrich Niedermann - 1.4.7-5 +- Add "Recommends: kmod(pcspkr.ko)" to install the driver if available (#1942670) + * Tue Jan 26 2021 Fedora Release Engineering - 1.4.7-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild diff --git a/pcspkr-beep.conf b/pcspkr-beep.conf index a9fbe0c..6fd4aee 100644 --- a/pcspkr-beep.conf +++ b/pcspkr-beep.conf @@ -1,3 +1,16 @@ -# Uncomment the following line to have the pcspkr.ko driver -# load automatically on boot +# Uncomment the alias line to have the pcspkr.ko driver load +# automatically on boot. +# +# The pcspkr.ko driver module is shipped in the kernel-modules-extra +# RPM package has probably been installed by default if it is +# possible, but you still might need to install it. +# +# Note that the kernel-modules-extra package and the pcspkr.ko module +# might not be available inside a container, while the hosts's actual +# pcspkr.ko API might or might not be available inside the container. +# +# So inside a container, the "beep" command might or might not produce +# sound depending on things entirely outside of the control of "beep" +# or even the container. +# # alias platform:pcspkr pcspkr From c856d6be9c9e29f21dd7191266b9cb53f9631b7a Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Thu, 25 Mar 2021 20:24:31 +0100 Subject: [PATCH 50/80] Remove all module dependencies Remove all kmod(pcspkr.ko) dependencies as https://bugzilla.redhat.com/show_bug.cgi?id=1652823 shows dnf would just install the wrong package. So instead, we document that the user has to explicitly install the kernel-modules-extra package. --- beep.spec | 26 +++++++++++++++++++++----- pcspkr-beep.conf | 13 +++++++++---- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/beep.spec b/beep.spec index 02938d4..353fe15 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.4.7 -Release: 5%{?dist} +Release: 6%{?dist} License: GPLv2+ URL: https://github.com/spkr-beep/beep/ @@ -28,9 +28,19 @@ BuildRequires: glibc-kernheaders BuildRequires: systemd BuildRequires: make -# We "recommend" the kernel driver and do not "require" it in order to -# not break cases where beep is installed on systems other than -# bare-metal PC hardware such as containers. +# Until https://bugzilla.redhat.com/show_bug.cgi?id=1652823 has been +# fixed (which makes dnf pull in a completely new debug kernel, while +# absolutely not installing the kernel module for the non-debug kernel +# actually in use), we cannot use the kmod(pcspkr.ko) recommends +# below. The boolean recommends also do not work (they do not pull in +# any package on "dnf install"), so we can only keep those here to +# document that they do not work. +# +# So people need to install the required package by hand. +# +# We would "recommend" the kernel driver and not "require" it in +# order to not break cases where beep is installed on systems other +# than bare-metal PC hardware such as containers. # # This assumes the people using the "beep" package can deal with a # "beep" invocation not producing a beep on those other systems. @@ -43,7 +53,10 @@ BuildRequires: make # While the kernel supports more speaker drivers, the only hardware # platforms with a speaker driver supported by Fedora use pcspkr.ko # (PCSPKR_PLATFORM in the kernel config). -Recommends: kmod(pcspkr.ko) +# +# Recommends: kmod(pcspkr.ko) +# Recommends: (kernel-modules-extras if kernel-modules) +# Recommends: (kernel-debug-modules-extras if kernel-debug-modules) Requires(pre): shadow-utils @@ -106,6 +119,9 @@ exit 0 %changelog +* Thu Mar 25 2021 Hans Ulrich Niedermann - 1.4.7-6 +- Remove any kmod(pcspkr.ko) dependencies as they install the wrong package + * Wed Mar 24 2021 Hans Ulrich Niedermann - 1.4.7-5 - Add "Recommends: kmod(pcspkr.ko)" to install the driver if available (#1942670) diff --git a/pcspkr-beep.conf b/pcspkr-beep.conf index 6fd4aee..cfe1e8f 100644 --- a/pcspkr-beep.conf +++ b/pcspkr-beep.conf @@ -2,12 +2,17 @@ # automatically on boot. # # The pcspkr.ko driver module is shipped in the kernel-modules-extra -# RPM package has probably been installed by default if it is -# possible, but you still might need to install it. +# which you need to install manually at this time. +# +# An automatic installation via "requires" or "recommends" is not +# possible due to "dnf install 'kmod(pcspkr.ko)'" likely installing an +# unrelated (-debug) kernel (see +# https://bugzilla.redhat.com/show_bug.cgi?id=1652823). # # Note that the kernel-modules-extra package and the pcspkr.ko module -# might not be available inside a container, while the hosts's actual -# pcspkr.ko API might or might not be available inside the container. +# might also not be available inside a container, while the hosts's +# actual pcspkr.ko API might or might not be available inside the +# container depending on how the container is launched. # # So inside a container, the "beep" command might or might not produce # sound depending on things entirely outside of the control of "beep" From 6585171286b66b28964e7dab2db1127e73ca3d97 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 21 Jul 2021 13:34:58 +0000 Subject: [PATCH 51/80] - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild Signed-off-by: Fedora Release Engineering From cf0ac04709a9a1774eeb68a40e8642dd185cb013 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 21 Jul 2021 18:31:19 +0000 Subject: [PATCH 52/80] - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- beep.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beep.spec b/beep.spec index 353fe15..bebb860 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.4.7 -Release: 6%{?dist} +Release: 7%{?dist} License: GPLv2+ URL: https://github.com/spkr-beep/beep/ @@ -119,6 +119,9 @@ exit 0 %changelog +* Wed Jul 21 2021 Fedora Release Engineering - 1.4.7-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + * Thu Mar 25 2021 Hans Ulrich Niedermann - 1.4.7-6 - Remove any kmod(pcspkr.ko) dependencies as they install the wrong package From eeec5749f33861648b81b9f730f986f5f4469499 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sat, 15 Jan 2022 13:53:03 +0100 Subject: [PATCH 53/80] Use underscore as cursor in command prompt depiction --- README.fedora | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.fedora b/README.fedora index 5d47f80..0f9b27e 100644 --- a/README.fedora +++ b/README.fedora @@ -70,7 +70,7 @@ You can check which users are members of the `beep` group by running [user@host ~]$ getent group beep beep:x:951:jane,bill - [user@host ~]$ + [user@host ~]$ _ However, any user newly added to the `beep` group must re-login so their processes can pick up the group membership. A user can check @@ -78,7 +78,7 @@ their group membership as follows: [jane@host ~]$ id uid=1000(jane) gid=1000(jane) groups=1000(jane),10(wheel),951(beep) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 - [jane@host ~]$ + [jane@host ~]$ _ To check the permission of the PC speaker device file, run @@ -96,7 +96,7 @@ To check the permission of the PC speaker device file, run mask::rw- other::--- - [user@host ~]$ + [user@host ~]$ _ 3. When and how to avoid using `beep` From b89de01c88f1ba692dc93d5e357f75fe330dc94c Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sat, 15 Jan 2022 13:53:34 +0100 Subject: [PATCH 54/80] Update README.fedora regarding alsamixer requirements --- README.fedora | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/README.fedora b/README.fedora index 0f9b27e..276126a 100644 --- a/README.fedora +++ b/README.fedora @@ -99,7 +99,39 @@ To check the permission of the PC speaker device file, run [user@host ~]$ _ -3. When and how to avoid using `beep` +3. Set up the audio mixer (required on some hardware) +----------------------------------------------------- + +On some systems with integrated speakers like e.g. laptops from the +IBM/Lenovo Thinkpad series, there is no separate physical speaker for +the PC speaker. + +Instead, the square wave sound generated by the PC speaker goes to the +integrated speakers through a mixer chip, where it is mixed with PCM +sound, CD drive audio, line in, microphone in, and other sources. + +On these systems, you might need to configure the mixer to make the PC +speaker audible through the laptop speakers, e.g. + + * Start alsamixer. + * Find the correct card (switch with the `F6` key). + * Maybe enable loopback. + * Unmute the appropriate PC speaker source (`m` key) and turn up + its volume. + * Weirdly, a microphone volume below 0% apparently can also + silence the PC speaker beeps. + +Some experimentation might be required. + +Of course, these mixer settings must be saved before the next system +reboot so that the reboot can restore the mixer settings. Some systems +save the mixer settings as part of their shutdown procedure, others +may need you to save them explicitly. + +TBD: How does Fedora handle saving alsamixer state across reboots? + + +4. When and how to avoid using `beep` ------------------------------------- An alternative way to get sound output for non-root users works if the @@ -118,7 +150,7 @@ may not be set up to allow use of the sound infrastructure for users other than the user currently logged into the current virtual console. -4. Example Usage of `beep` +5. Example Usage of `beep` -------------------------- An acoustic notification when a long running compile job finishes From 97bcb978d453007d6b387c6269a0bba47f3fc675 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sat, 15 Jan 2022 13:53:59 +0100 Subject: [PATCH 55/80] Update to beep-1.4.10 --- beep.spec | 13 ++++++++----- sources | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/beep.spec b/beep.spec index bebb860..ce66957 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep -Version: 1.4.7 -Release: 7%{?dist} +Version: 1.4.10 +Release: 1%{?dist} License: GPLv2+ URL: https://github.com/spkr-beep/beep/ @@ -105,10 +105,10 @@ exit 0 %files %doc README.fedora %license %{_pkgdocdir}/COPYING -%doc %{_pkgdocdir}/CHANGELOG -%doc %{_pkgdocdir}/CREDITS -%doc %{_pkgdocdir}/README.md +%doc %{_pkgdocdir}/CREDITS.md +%doc %{_pkgdocdir}/NEWS.md %doc %{_pkgdocdir}/PERMISSIONS.md +%doc %{_pkgdocdir}/README.md %doc %{_pkgdocdir}/contrib/failure-beeps %doc %{_pkgdocdir}/contrib/success-beeps %attr(0755,root,root) %{_bindir}/beep @@ -119,6 +119,9 @@ exit 0 %changelog +* Sat Jan 15 2022 Hans Ulrich Niedermann - 1.4.10-1 +- Update to beep-1.4.10 + * Wed Jul 21 2021 Fedora Release Engineering - 1.4.7-7 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild diff --git a/sources b/sources index 886e63a..defe8cb 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (beep-1.4.7.tar.gz) = a1482a16f971c56dc6a62047fa449c96519c897d2e8cb18dcc06178564943c1eb3b9d9106ca6b76054e0fa109e3b161fb8e9ec1966a02d0d739222b5434b71c7 +SHA512 (beep-1.4.10.tar.gz) = b2e8325c1560b066073dbb9965c4566f7040f42eb8345e332218b5da73889cd6fd72ede8b91f171500e26766ff00de19b3ff82bc57d555dfb18365a0efbc76d8 From 9ac4e16ee104e73d4c7c5816e212796fa912d310 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sat, 15 Jan 2022 15:53:00 +0100 Subject: [PATCH 56/80] Update to beep-1.4.11 --- beep.spec | 7 ++++++- sources | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/beep.spec b/beep.spec index ce66957..07da527 100644 --- a/beep.spec +++ b/beep.spec @@ -1,6 +1,6 @@ Summary: Beep the PC speaker any number of ways Name: beep -Version: 1.4.10 +Version: 1.4.11 Release: 1%{?dist} License: GPLv2+ @@ -110,6 +110,8 @@ exit 0 %doc %{_pkgdocdir}/PERMISSIONS.md %doc %{_pkgdocdir}/README.md %doc %{_pkgdocdir}/contrib/failure-beeps +%doc %{_pkgdocdir}/contrib/morse2beep.pl +%doc %{_pkgdocdir}/contrib/morse2beep.sed %doc %{_pkgdocdir}/contrib/success-beeps %attr(0755,root,root) %{_bindir}/beep %{_mandir}/man1/beep.1* @@ -119,6 +121,9 @@ exit 0 %changelog +* Sat Jan 15 2022 Hans Ulrich Niedermann - 1.4.11-1 +- Update to beep-1.4.11 + * Sat Jan 15 2022 Hans Ulrich Niedermann - 1.4.10-1 - Update to beep-1.4.10 diff --git a/sources b/sources index defe8cb..6ae0569 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (beep-1.4.10.tar.gz) = b2e8325c1560b066073dbb9965c4566f7040f42eb8345e332218b5da73889cd6fd72ede8b91f171500e26766ff00de19b3ff82bc57d555dfb18365a0efbc76d8 +SHA512 (beep-1.4.11.tar.gz) = 8849e18b2dbd85d412b71215deec87e81a141438c632ca2c3e95a340ea7adf83054b5643be310eacfe47e37a0c448256adc5d594623cc7f8cb7ceaae223e753a From 74674faf18b1549564e7a640c1c93e2a49874f51 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 19 Jan 2022 11:28:51 +0100 Subject: [PATCH 57/80] Support versioned pkgdocdir for epel7 Apparently, epel7 uses a versioned directory name /usr/share/doc/$(PACKAGE)-$(VERSION)/ to store documentation files instead of the more common (f34 and f35 and fNN for along time, and epel8, and presumably epel9 as well, also Debian 10, FreeBSD13, etc.) /usr/share/doc/$(PACKAGE)/ --- beep.spec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/beep.spec b/beep.spec index 07da527..99887db 100644 --- a/beep.spec +++ b/beep.spec @@ -77,6 +77,8 @@ interesting, but it is really good at the notifying part. %prep %setup -q +%{?el7:sed -i 's|^pkgdocdir=.*|pkgdocdir=$(docdir)/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)|' GNUmakefile} +grep ^pkgdocdir= GNUmakefile install -m 0644 -p %{SOURCE1} README.fedora sed -i 's|^\.\\" \(\.BR .*\)README.Distro\(.*\)|\1README.fedora\2|' beep.1.in && : #" @@ -87,6 +89,7 @@ make %{?_smp_mflags} COMPILERS=gcc CFLAGS_gcc="-Wall -Wextra -std=gnu99 -pedanti %install rm -rf "$RPM_BUILD_ROOT" +ls -l "/usr/share/doc" ||: make install DESTDIR="$RPM_BUILD_ROOT" COMPILERS=gcc CFLAGS_gcc="-Wall -Wextra -std=gnu99 -pedantic -Werror ${RPM_OPT_FLAGS}" LDFLAGS="${RPM_LD_FLAGS}" CPPFLAGS_gcc="" install -d -m 0755 "$RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/" From 3926561aa5f522f2e2b381f147249da93471558e Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 19 Jan 2022 19:04:48 +0100 Subject: [PATCH 58/80] package.cfg: Add epel, remove master --- package.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.cfg b/package.cfg index 6b189b9..1cb0d1a 100644 --- a/package.cfg +++ b/package.cfg @@ -1,2 +1,2 @@ [koji] -targets = master fedora +targets = epel fedora From 8d050db7cc825936e5aab95563d33b22ec75694d Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 19 Jan 2022 19:07:03 +0100 Subject: [PATCH 59/80] remove package.cfg Trying to get this to build for both Fedora and Epel, and package.cfg appears to be confusing fedpkg --- package.cfg | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 package.cfg diff --git a/package.cfg b/package.cfg deleted file mode 100644 index 1cb0d1a..0000000 --- a/package.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[koji] -targets = epel fedora From 4989d4a7f3a91e2b72dfd12ae68b834be969d465 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 19 Jan 2022 19:21:32 +0100 Subject: [PATCH 60/80] rebuild to have common sources for all branches --- beep.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beep.spec b/beep.spec index 99887db..d0004c0 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.4.11 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2+ URL: https://github.com/spkr-beep/beep/ @@ -124,6 +124,9 @@ exit 0 %changelog +* Wed Jan 19 2022 Hans Ulrich Niedermann - 1.4.11-2 +- rebuild to have common sources for all branches + * Sat Jan 15 2022 Hans Ulrich Niedermann - 1.4.11-1 - Update to beep-1.4.11 From 3e678feefd8d7e4f69acc2d867ba823f2d4372d8 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 24 Jan 2022 23:34:49 +0100 Subject: [PATCH 61/80] Use more RPM macros in %build and %install steps Use %{build_cflags} and %{build_ldflags} to hopefully use more of what default flags are available in default builds, and switch to more %{...} rpm macros instead of ${RPM_*} shell vars. --- beep.spec | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/beep.spec b/beep.spec index d0004c0..32a03fa 100644 --- a/beep.spec +++ b/beep.spec @@ -84,20 +84,19 @@ sed -i 's|^\.\\" \(\.BR .*\)README.Distro\(.*\)|\1README.fedora\2|' beep.1.in && %build -make %{?_smp_mflags} COMPILERS=gcc CFLAGS_gcc="-Wall -Wextra -std=gnu99 -pedantic -Werror ${RPM_OPT_FLAGS}" LDFLAGS="${RPM_LD_FLAGS}" CPPFLAGS_gcc="" +make %{?_smp_mflags} COMPILERS=gcc COMPILER_gcc=gcc COMPILER_clang=false CPPFLAGS_gcc="" CFLAGS_gcc="-std=gnu99 -pedantic -Wall -Wextra -Werror %{build_cflags}" LDFLAGS_gcc="%{build_ldflags}" prefix=%{_prefix} bindir=%{_bindir} pkgdocdir=%{_pkgdocdir} %install -rm -rf "$RPM_BUILD_ROOT" -ls -l "/usr/share/doc" ||: -make install DESTDIR="$RPM_BUILD_ROOT" COMPILERS=gcc CFLAGS_gcc="-Wall -Wextra -std=gnu99 -pedantic -Werror ${RPM_OPT_FLAGS}" LDFLAGS="${RPM_LD_FLAGS}" CPPFLAGS_gcc="" +rm -rf "%{buildroot}" +make install DESTDIR="%{buildroot}" COMPILER_gcc=false COMPILER_clang=false CPPFLAGS_gcc="" CFLAGS_gcc="-std=gnu99 -pedantic -Wall -Wextra -Werror %{build_cflags}" LDFLAGS_gcc="%{build_ldflags}" prefix=%{_prefix} bindir=%{_bindir} pkgdocdir=%{_pkgdocdir} -install -d -m 0755 "$RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/" -install -p -m 0644 "%{SOURCE4}" "$RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/beep.conf" +install -d -m 0755 "%{buildroot}%{_sysconfdir}/modprobe.d/" +install -p -m 0644 "%{SOURCE4}" "%{buildroot}%{_sysconfdir}/modprobe.d/beep.conf" -install -d -m 0755 "$RPM_BUILD_ROOT%{_udevrulesdir}/" -install -p -m 0644 "%{SOURCE2}" "$RPM_BUILD_ROOT%{_udevrulesdir}/" -install -p -m 0644 "%{SOURCE3}" "$RPM_BUILD_ROOT%{_udevrulesdir}/" +install -d -m 0755 "%{buildroot}%{_udevrulesdir}/" +install -p -m 0644 "%{SOURCE2}" "%{buildroot}%{_udevrulesdir}/" +install -p -m 0644 "%{SOURCE3}" "%{buildroot}%{_udevrulesdir}/" %pre From c7032d376536d854e9e56aa3dafed4e566220b48 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 25 Jan 2022 20:26:57 +0100 Subject: [PATCH 62/80] Stop using %doc with relative paths Stop using %doc with relative paths and absolute paths: Only use %doc with absolute paths (%{_pkgdocdir}). Why? It's in the Fedora Packaging Guidelines, and epel7 builds complain about doc files being listed twice. --- beep.spec | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/beep.spec b/beep.spec index 32a03fa..1b4f73d 100644 --- a/beep.spec +++ b/beep.spec @@ -79,7 +79,6 @@ interesting, but it is really good at the notifying part. %setup -q %{?el7:sed -i 's|^pkgdocdir=.*|pkgdocdir=$(docdir)/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)|' GNUmakefile} grep ^pkgdocdir= GNUmakefile -install -m 0644 -p %{SOURCE1} README.fedora sed -i 's|^\.\\" \(\.BR .*\)README.Distro\(.*\)|\1README.fedora\2|' beep.1.in && : #" @@ -91,6 +90,8 @@ make %{?_smp_mflags} COMPILERS=gcc COMPILER_gcc=gcc COMPILER_clang=false CPPFLAG rm -rf "%{buildroot}" make install DESTDIR="%{buildroot}" COMPILER_gcc=false COMPILER_clang=false CPPFLAGS_gcc="" CFLAGS_gcc="-std=gnu99 -pedantic -Wall -Wextra -Werror %{build_cflags}" LDFLAGS_gcc="%{build_ldflags}" prefix=%{_prefix} bindir=%{_bindir} pkgdocdir=%{_pkgdocdir} +install -p -m 0644 "%{SOURCE1}" "%{buildroot}%{_pkgdocdir}/README.fedora" + install -d -m 0755 "%{buildroot}%{_sysconfdir}/modprobe.d/" install -p -m 0644 "%{SOURCE4}" "%{buildroot}%{_sysconfdir}/modprobe.d/beep.conf" @@ -105,11 +106,11 @@ exit 0 %files -%doc README.fedora %license %{_pkgdocdir}/COPYING %doc %{_pkgdocdir}/CREDITS.md %doc %{_pkgdocdir}/NEWS.md %doc %{_pkgdocdir}/PERMISSIONS.md +%doc %{_pkgdocdir}/README.fedora %doc %{_pkgdocdir}/README.md %doc %{_pkgdocdir}/contrib/failure-beeps %doc %{_pkgdocdir}/contrib/morse2beep.pl From 4a513c887f2a9d2be65e6d39b148f48b54fd5770 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 26 Jan 2022 23:39:26 +0100 Subject: [PATCH 63/80] Remove explicit non-functional %attr() statements If it is not needed, we can remove it. --- beep.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/beep.spec b/beep.spec index 1b4f73d..887145c 100644 --- a/beep.spec +++ b/beep.spec @@ -116,9 +116,9 @@ exit 0 %doc %{_pkgdocdir}/contrib/morse2beep.pl %doc %{_pkgdocdir}/contrib/morse2beep.sed %doc %{_pkgdocdir}/contrib/success-beeps -%attr(0755,root,root) %{_bindir}/beep +%{_bindir}/beep %{_mandir}/man1/beep.1* -%config(noreplace) %attr(0644,root,root) %{_sysconfdir}/modprobe.d/beep.conf +%config(noreplace) %{_sysconfdir}/modprobe.d/beep.conf %{_udevrulesdir}/70-pcspkr-beep.rules %{_udevrulesdir}/90-pcspkr-beep.rules From ef038e4ea781794e8f76c3f599d323d40337bf57 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Thu, 27 Jan 2022 23:22:45 +0100 Subject: [PATCH 64/80] fix broken rpm build from 1.4.11-3 (missing COMPILERS= in %install) --- beep.spec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/beep.spec b/beep.spec index a4d79ca..578873b 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.4.11 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2+ URL: https://github.com/spkr-beep/beep/ @@ -88,7 +88,7 @@ make %{?_smp_mflags} COMPILERS=gcc COMPILER_gcc=gcc COMPILER_clang=false CPPFLAG %install rm -rf "%{buildroot}" -make install DESTDIR="%{buildroot}" COMPILER_gcc=false COMPILER_clang=false CPPFLAGS_gcc="" CFLAGS_gcc="-std=gnu99 -pedantic -Wall -Wextra -Werror %{build_cflags}" LDFLAGS_gcc="%{build_ldflags}" prefix=%{_prefix} bindir=%{_bindir} pkgdocdir=%{_pkgdocdir} +make install DESTDIR="%{buildroot}" COMPILERS=gcc COMPILER_gcc=false COMPILER_clang=false CPPFLAGS_gcc="" CFLAGS_gcc="-std=gnu99 -pedantic -Wall -Wextra -Werror %{build_cflags}" LDFLAGS_gcc="%{build_ldflags}" prefix=%{_prefix} bindir=%{_bindir} pkgdocdir=%{_pkgdocdir} install -p -m 0644 "%{SOURCE1}" "%{buildroot}%{_pkgdocdir}/README.fedora" @@ -124,6 +124,9 @@ exit 0 %changelog +* Thu Jan 27 2022 Hans Ulrich Niedermann - 1.4.11-4 +- fix broken rpm build from 1.4.11-3 (missing COMPILERS= in %%install) + * Thu Jan 27 2022 Hans Ulrich Niedermann - 1.4.11-3 - only use %%doc with absolute paths (removes duplicate listings) - stop using env vars in favour of rpm macros From e4571393b1999532e197b189019f821ba7bd7827 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Thu, 27 Jan 2022 23:25:24 +0100 Subject: [PATCH 65/80] Update to beep-1.4.12 beep-1.4.12 mainly uses a simplified build system. --- beep.spec | 26 ++++++++++++++++++++------ sources | 2 +- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/beep.spec b/beep.spec index 578873b..4575c7d 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep -Version: 1.4.11 -Release: 4%{?dist} +Version: 1.4.12 +Release: 1%{?dist} License: GPLv2+ URL: https://github.com/spkr-beep/beep/ @@ -24,6 +24,8 @@ Source4: pcspkr-beep.conf BuildRequires: gcc BuildRequires: glibc-kernheaders +%{!?el7:BuildRequires: libubsan} + # for the udev macros BuildRequires: systemd BuildRequires: make @@ -77,18 +79,27 @@ interesting, but it is really good at the notifying part. %prep %setup -q -%{?el7:sed -i 's|^pkgdocdir=.*|pkgdocdir=$(docdir)/$(PACKAGE_TARNAME)-$(PACKAGE_VERSION)|' GNUmakefile} -grep ^pkgdocdir= GNUmakefile sed -i 's|^\.\\" \(\.BR .*\)README.Distro\(.*\)|\1README.fedora\2|' beep.1.in && : #" %build -make %{?_smp_mflags} COMPILERS=gcc COMPILER_gcc=gcc COMPILER_clang=false CPPFLAGS_gcc="" CFLAGS_gcc="-std=gnu99 -pedantic -Wall -Wextra -Werror %{build_cflags}" LDFLAGS_gcc="%{build_ldflags}" prefix=%{_prefix} bindir=%{_bindir} pkgdocdir=%{_pkgdocdir} +cat>local.mk< - 1.4.12-1 +- Update to beep-1.4.12 with simplified makefile + * Thu Jan 27 2022 Hans Ulrich Niedermann - 1.4.11-4 - fix broken rpm build from 1.4.11-3 (missing COMPILERS= in %%install) diff --git a/sources b/sources index 6ae0569..7052993 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (beep-1.4.11.tar.gz) = 8849e18b2dbd85d412b71215deec87e81a141438c632ca2c3e95a340ea7adf83054b5643be310eacfe47e37a0c448256adc5d594623cc7f8cb7ceaae223e753a +SHA512 (beep-1.4.12.tar.gz) = 18fed77bc4820ecc84ac12e903d516d5228fa2038df1788cc68db76e40b3c47a271911cc45bc48ce94e3f215803c5c05cb6c08ebb47ae6d7fcf1e0bc1ac169cd From 698582ac49c027175dee6c06cc617401abbfae9e Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 20 Jul 2022 21:53:41 +0000 Subject: [PATCH 66/80] Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- beep.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beep.spec b/beep.spec index 4575c7d..3d74629 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.4.12 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv2+ URL: https://github.com/spkr-beep/beep/ @@ -135,6 +135,9 @@ exit 0 %changelog +* Wed Jul 20 2022 Fedora Release Engineering - 1.4.12-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + * Fri Jan 28 2022 Hans Ulrich Niedermann - 1.4.12-1 - Update to beep-1.4.12 with simplified makefile From bd4f8addeb0bded643a8edae98917093f95513c3 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 16 Aug 2022 22:02:04 +0200 Subject: [PATCH 67/80] Move package to rpmautospec --- beep.spec | 179 +----------------------------------------------------- changelog | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 178 insertions(+), 177 deletions(-) create mode 100644 changelog diff --git a/beep.spec b/beep.spec index 3d74629..3b3f24c 100644 --- a/beep.spec +++ b/beep.spec @@ -1,7 +1,7 @@ Summary: Beep the PC speaker any number of ways Name: beep Version: 1.4.12 -Release: 2%{?dist} +Release: %autorelease License: GPLv2+ URL: https://github.com/spkr-beep/beep/ @@ -135,179 +135,4 @@ exit 0 %changelog -* Wed Jul 20 2022 Fedora Release Engineering - 1.4.12-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild - -* Fri Jan 28 2022 Hans Ulrich Niedermann - 1.4.12-1 -- Update to beep-1.4.12 with simplified makefile - -* Thu Jan 27 2022 Hans Ulrich Niedermann - 1.4.11-4 -- fix broken rpm build from 1.4.11-3 (missing COMPILERS= in %%install) - -* Thu Jan 27 2022 Hans Ulrich Niedermann - 1.4.11-3 -- only use %%doc with absolute paths (removes duplicate listings) -- stop using env vars in favour of rpm macros -- remove non-functional explicit %%attr - -* Wed Jan 19 2022 Hans Ulrich Niedermann - 1.4.11-2 -- rebuild to have common sources for all branches - -* Sat Jan 15 2022 Hans Ulrich Niedermann - 1.4.11-1 -- Update to beep-1.4.11 - -* Sat Jan 15 2022 Hans Ulrich Niedermann - 1.4.10-1 -- Update to beep-1.4.10 - -* Wed Jul 21 2021 Fedora Release Engineering - 1.4.7-7 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild - -* Thu Mar 25 2021 Hans Ulrich Niedermann - 1.4.7-6 -- Remove any kmod(pcspkr.ko) dependencies as they install the wrong package - -* Wed Mar 24 2021 Hans Ulrich Niedermann - 1.4.7-5 -- Add "Recommends: kmod(pcspkr.ko)" to install the driver if available (#1942670) - -* Tue Jan 26 2021 Fedora Release Engineering - 1.4.7-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild - -* Mon Jul 27 2020 Fedora Release Engineering - 1.4.7-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild - -* Tue Jan 28 2020 Fedora Release Engineering - 1.4.7-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild - -* Wed Jan 1 2020 Hans Ulrich Niedermann - 1.4.7-1 -- Update to beep-1.4.7 -- Install contrib scripts for both successfully and failing sounding beeps. - -* Fri Dec 20 2019 Hans Ulrich Niedermann - 1.4.6-1 -- Update to beep-1.4.6 -- Use BEEP_LOG_LEVEL environment variable for default log level -- Avoid possible bug related to not using va_copy() with a va_list parameter - -* Wed Jul 24 2019 Fedora Release Engineering - 1.4.4-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild - -* Tue Apr 2 2019 Hans Ulrich Niedermann - 1.4.4-1 -- Update to beep-1.4.4 -- Install default udev rules to /usr/lib/udev/rules.d/ (not /etc/udev/) -- Give the currently locally logged in user PC speaker access out of the box -- Have beep(1) man page mention README.fedora - -* Thu Jan 31 2019 Fedora Release Engineering - 1.4.3-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild - -* Fri Jan 18 2019 Hans Ulrich Niedermann - 1.4.3-1 -- Update to beep-1.4.3 - -* Tue Jan 8 2019 Hans Ulrich Niedermann - 1.4.1-1 -- Update to beep-1.4.1 - -* Fri Jan 4 2019 Hans Ulrich Niedermann - 1.4.0-1 -- Update to beep-1.4.0 - -* Sat Dec 29 2018 Hans Ulrich Niedermann - 1.3-26 -- Stop shipping old sudo related config files -- Refuse to run when run via sudo -- Set up group 'beep' for write access to evdev device with new udev rule -- Update README.fedora to reflect new group permission setup on evdev device - -* Fri Dec 28 2018 Hans Ulrich Niedermann - 1.3-25 -- guard against directory traversal in /dev/input/ check -- refuse to run if setuid or setgid root -- make the evdev device the first device to look for (does not require root) - -* Fri Dec 28 2018 Hans Ulrich Niedermann - 1.3-24 -- Actually apply the patches -- Update COPYING with new FSF address -- Fix Patch9 to work as non-git patch (do the rest with shell) -- Proper naming of Patch14 -- Exit beep when error accessing API - -* Fri Dec 28 2018 Hans Ulrich Niedermann - 1.3-23 -- Fix CVE-2018-1000532 and mitigate against related issues (#1595592) -- Fix a number of potential integer overflows - -* Thu Jul 12 2018 Fedora Release Engineering - 1.3-22 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild - -* Tue Apr 3 2018 Hans Ulrich Niedermann - 1.3-21 -- Add CVE-2018-0492 fix. -- Behaviour of multiple -f parameters matches documentation now. - -* Wed Feb 07 2018 Fedora Release Engineering - 1.3-20 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild - -* Wed Aug 02 2017 Fedora Release Engineering - 1.3-19 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild - -* Wed Jul 26 2017 Fedora Release Engineering - 1.3-18 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild - -* Fri Feb 10 2017 Fedora Release Engineering - 1.3-17 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild - -* Tue May 31 2016 Hans Ulrich Niedermann - 1.3-16 -- Use more appropriate sox play example in README.fedora -- Make command line examples more readable in README.fedora - -* Tue May 31 2016 Hans Ulrich Niedermann - 1.3-15 -- Add shell aliases to allow non-root users to run beep from the shell -- Fix mail address in %%changelog - -* Tue May 31 2016 Hans Ulrich Niedermann - 1.3-14 -- Document how non-root users can run beep via sudo (#1133231) -- Remove spec file conditional required in Fedora 12 times - -* Mon May 16 2016 Hans Ulrich Niedermann - 1.3-13 -- Remove useless %%defattr for clarity - -* Wed Feb 03 2016 Fedora Release Engineering - 1.3-12 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild - -* Sun Jan 17 2016 Hans Ulrich Niedermann - 1.3-11 -- Do not replace config file modprobe.d/beep.conf (#1087616) - -* Wed Jun 17 2015 Fedora Release Engineering - 1.3-10 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild - -* Fri Aug 15 2014 Fedora Release Engineering - 1.3-9 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild - -* Sat Jun 07 2014 Fedora Release Engineering - 1.3-8 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild - -* Tue Nov 19 2013 Hans Ulrich Niedermann - 1.3-7 -- Use new upstream tarball beep-1.3.tar.gz (yes, it has changed!) -- Add a few fixes from upstream git repo -- Move our Makefile cleanup to upstream pull request - -* Sat Aug 03 2013 Fedora Release Engineering - 1.3-6 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild - -* Wed Feb 13 2013 Fedora Release Engineering - 1.3-5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild - -* Wed Jul 18 2012 Fedora Release Engineering - 1.3-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild - -* Thu Jan 12 2012 Fedora Release Engineering - 1.3-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild - -* Mon Feb 07 2011 Fedora Release Engineering - 1.3-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild - -* Fri Jul 16 2010 Hans Ulrich Niedermann - 1.3-1 -- Update to upstream release beep-1.3 - -* Fri Jan 22 2010 Hans Ulrich Niedermann - 1.2.2-6 -- Ship modprobe config file with alias for pcspkr on F12 and later - -* Fri Jul 24 2009 Fedora Release Engineering - 1.2.2-5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild - -* Mon Feb 23 2009 Fedora Release Engineering - 1.2.2-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild - -* Sun Sep 7 2008 Hans Ulrich Niedermann - 1.2.2-3 -- Initial package for submission to Fedora +%autochangelog diff --git a/changelog b/changelog new file mode 100644 index 0000000..e448e07 --- /dev/null +++ b/changelog @@ -0,0 +1,176 @@ +* Wed Jul 20 2022 Fedora Release Engineering - 1.4.12-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + +* Fri Jan 28 2022 Hans Ulrich Niedermann - 1.4.12-1 +- Update to beep-1.4.12 with simplified makefile + +* Thu Jan 27 2022 Hans Ulrich Niedermann - 1.4.11-4 +- fix broken rpm build from 1.4.11-3 (missing COMPILERS= in %%install) + +* Thu Jan 27 2022 Hans Ulrich Niedermann - 1.4.11-3 +- only use %%doc with absolute paths (removes duplicate listings) +- stop using env vars in favour of rpm macros +- remove non-functional explicit %%attr + +* Wed Jan 19 2022 Hans Ulrich Niedermann - 1.4.11-2 +- rebuild to have common sources for all branches + +* Sat Jan 15 2022 Hans Ulrich Niedermann - 1.4.11-1 +- Update to beep-1.4.11 + +* Sat Jan 15 2022 Hans Ulrich Niedermann - 1.4.10-1 +- Update to beep-1.4.10 + +* Wed Jul 21 2021 Fedora Release Engineering - 1.4.7-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + +* Thu Mar 25 2021 Hans Ulrich Niedermann - 1.4.7-6 +- Remove any kmod(pcspkr.ko) dependencies as they install the wrong package + +* Wed Mar 24 2021 Hans Ulrich Niedermann - 1.4.7-5 +- Add "Recommends: kmod(pcspkr.ko)" to install the driver if available (#1942670) + +* Tue Jan 26 2021 Fedora Release Engineering - 1.4.7-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Mon Jul 27 2020 Fedora Release Engineering - 1.4.7-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Tue Jan 28 2020 Fedora Release Engineering - 1.4.7-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Wed Jan 1 2020 Hans Ulrich Niedermann - 1.4.7-1 +- Update to beep-1.4.7 +- Install contrib scripts for both successfully and failing sounding beeps. + +* Fri Dec 20 2019 Hans Ulrich Niedermann - 1.4.6-1 +- Update to beep-1.4.6 +- Use BEEP_LOG_LEVEL environment variable for default log level +- Avoid possible bug related to not using va_copy() with a va_list parameter + +* Wed Jul 24 2019 Fedora Release Engineering - 1.4.4-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Tue Apr 2 2019 Hans Ulrich Niedermann - 1.4.4-1 +- Update to beep-1.4.4 +- Install default udev rules to /usr/lib/udev/rules.d/ (not /etc/udev/) +- Give the currently locally logged in user PC speaker access out of the box +- Have beep(1) man page mention README.fedora + +* Thu Jan 31 2019 Fedora Release Engineering - 1.4.3-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Fri Jan 18 2019 Hans Ulrich Niedermann - 1.4.3-1 +- Update to beep-1.4.3 + +* Tue Jan 8 2019 Hans Ulrich Niedermann - 1.4.1-1 +- Update to beep-1.4.1 + +* Fri Jan 4 2019 Hans Ulrich Niedermann - 1.4.0-1 +- Update to beep-1.4.0 + +* Sat Dec 29 2018 Hans Ulrich Niedermann - 1.3-26 +- Stop shipping old sudo related config files +- Refuse to run when run via sudo +- Set up group 'beep' for write access to evdev device with new udev rule +- Update README.fedora to reflect new group permission setup on evdev device + +* Fri Dec 28 2018 Hans Ulrich Niedermann - 1.3-25 +- guard against directory traversal in /dev/input/ check +- refuse to run if setuid or setgid root +- make the evdev device the first device to look for (does not require root) + +* Fri Dec 28 2018 Hans Ulrich Niedermann - 1.3-24 +- Actually apply the patches +- Update COPYING with new FSF address +- Fix Patch9 to work as non-git patch (do the rest with shell) +- Proper naming of Patch14 +- Exit beep when error accessing API + +* Fri Dec 28 2018 Hans Ulrich Niedermann - 1.3-23 +- Fix CVE-2018-1000532 and mitigate against related issues (#1595592) +- Fix a number of potential integer overflows + +* Thu Jul 12 2018 Fedora Release Engineering - 1.3-22 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Tue Apr 3 2018 Hans Ulrich Niedermann - 1.3-21 +- Add CVE-2018-0492 fix. +- Behaviour of multiple -f parameters matches documentation now. + +* Wed Feb 07 2018 Fedora Release Engineering - 1.3-20 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Wed Aug 02 2017 Fedora Release Engineering - 1.3-19 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Wed Jul 26 2017 Fedora Release Engineering - 1.3-18 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Fri Feb 10 2017 Fedora Release Engineering - 1.3-17 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Tue May 31 2016 Hans Ulrich Niedermann - 1.3-16 +- Use more appropriate sox play example in README.fedora +- Make command line examples more readable in README.fedora + +* Tue May 31 2016 Hans Ulrich Niedermann - 1.3-15 +- Add shell aliases to allow non-root users to run beep from the shell +- Fix mail address in %%changelog + +* Tue May 31 2016 Hans Ulrich Niedermann - 1.3-14 +- Document how non-root users can run beep via sudo (#1133231) +- Remove spec file conditional required in Fedora 12 times + +* Mon May 16 2016 Hans Ulrich Niedermann - 1.3-13 +- Remove useless %%defattr for clarity + +* Wed Feb 03 2016 Fedora Release Engineering - 1.3-12 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Sun Jan 17 2016 Hans Ulrich Niedermann - 1.3-11 +- Do not replace config file modprobe.d/beep.conf (#1087616) + +* Wed Jun 17 2015 Fedora Release Engineering - 1.3-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Fri Aug 15 2014 Fedora Release Engineering - 1.3-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + +* Sat Jun 07 2014 Fedora Release Engineering - 1.3-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Tue Nov 19 2013 Hans Ulrich Niedermann - 1.3-7 +- Use new upstream tarball beep-1.3.tar.gz (yes, it has changed!) +- Add a few fixes from upstream git repo +- Move our Makefile cleanup to upstream pull request + +* Sat Aug 03 2013 Fedora Release Engineering - 1.3-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Wed Feb 13 2013 Fedora Release Engineering - 1.3-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Wed Jul 18 2012 Fedora Release Engineering - 1.3-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Thu Jan 12 2012 Fedora Release Engineering - 1.3-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Mon Feb 07 2011 Fedora Release Engineering - 1.3-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Fri Jul 16 2010 Hans Ulrich Niedermann - 1.3-1 +- Update to upstream release beep-1.3 + +* Fri Jan 22 2010 Hans Ulrich Niedermann - 1.2.2-6 +- Ship modprobe config file with alias for pcspkr on F12 and later + +* Fri Jul 24 2009 Fedora Release Engineering - 1.2.2-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Mon Feb 23 2009 Fedora Release Engineering - 1.2.2-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Sun Sep 7 2008 Hans Ulrich Niedermann - 1.2.2-3 +- Initial package for submission to Fedora From 24958d483177725e12a22783dbf0a50fa7c97dd9 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 16 Aug 2022 22:16:45 +0200 Subject: [PATCH 68/80] Pass through some more package flags Pass through some more package flags, mostly so that the rpmautospec change can be tested. --- beep.spec | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/beep.spec b/beep.spec index 3b3f24c..a4fa3cb 100644 --- a/beep.spec +++ b/beep.spec @@ -83,11 +83,20 @@ sed -i 's|^\.\\" \(\.BR .*\)README.Distro\(.*\)|\1README.fedora\2|' beep.1.in && %build +if test "x%{build_cppflags}" = "x%%{build_cppflags}"; then + BUILD_CPPFLAGS="" +else + BUILD_CPPFLAGS="%{build_cppflags}" +fi cat>local.mk< Date: Wed, 18 Jan 2023 22:47:18 +0000 Subject: [PATCH 69/80] Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild Signed-off-by: Fedora Release Engineering From bdcc70091aa65c1852d0408c2f4c1c0f8c5bc178 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 27 Jan 2023 13:39:09 +0100 Subject: [PATCH 70/80] On EL7, Require: systemd instead of systemd-udev (#2157788) It appears that the udev directories /etc/udev/rules.d/ /usr/lib/udev/rules.d/ were split off from the systemd package into the systemd-udev package some time after EL7, so a beep package for EL7 and earlier can only "Require:" systemd, not the systemd-udev package introduced later. Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2157788 --- beep.spec | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/beep.spec b/beep.spec index a4fa3cb..9b35454 100644 --- a/beep.spec +++ b/beep.spec @@ -65,7 +65,11 @@ Requires(pre): shadow-utils # /etc/modprobe.d/ Requires: kmod # /etc/udev/rules.d/ and /usr/lib/udev/rules.d/ +%if 0%{?rhel} <= 7 +Requires: systemd +%else Requires: systemd-udev +%endif %description From cc7b64aeed1fc28786a705c7e2b1f40ce6474866 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 27 Jan 2023 22:19:40 +0100 Subject: [PATCH 71/80] Require: systemd only on EL7, not on Fedora (#2157788) We got the range wrong the last time. This does the correct Requires: el7 systemd el8 systemd-udev el9 systemd-udev fc36 systemd-udev fc37 systemd-udev fc38 systemd-udev --- beep.spec | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/beep.spec b/beep.spec index 9b35454..dc90672 100644 --- a/beep.spec +++ b/beep.spec @@ -64,12 +64,10 @@ Requires(pre): shadow-utils # /etc/modprobe.d/ Requires: kmod + # /etc/udev/rules.d/ and /usr/lib/udev/rules.d/ -%if 0%{?rhel} <= 7 -Requires: systemd -%else -Requires: systemd-udev -%endif +%{?el7:Requires: systemd} +%{!?el7:Requires: systemd-udev} %description From e11898073c3e675da0c31256182d254c965cf3ed Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 19 Jul 2023 14:30:40 +0000 Subject: [PATCH 72/80] Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild Signed-off-by: Fedora Release Engineering From 1cb1544375936c1c444f5cc51032b8b4e683a3bb Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Wed, 30 Aug 2023 18:18:29 +0200 Subject: [PATCH 73/80] On EL7, use #!/bin/sed instead of #!/usr/bin/sed --- beep.spec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/beep.spec b/beep.spec index dc90672..5843a3c 100644 --- a/beep.spec +++ b/beep.spec @@ -107,6 +107,8 @@ mandir = %{_mandir} EOF make %{?_smp_mflags} +%{?el7:sed -i '1s|.*|#!/bin/sed -f|' contrib/morse/morse2beep.sed} + %install rm -rf "%{buildroot}" From ac4e09a02c24fab0f4a99106e3053f54814d9172 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 19 Jan 2024 14:18:27 +0000 Subject: [PATCH 74/80] Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild From d05d757b644363754bad734a632c065542169291 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Tue, 23 Jan 2024 00:15:34 +0000 Subject: [PATCH 75/80] Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild From 3207e186bf7bbd037e819af2e2ed30612cda25ea Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 17 Jul 2024 18:12:00 +0000 Subject: [PATCH 76/80] Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild From 4697af52e03b7b79022918b79be1f9aa49f5dfce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Such=C3=BD?= Date: Thu, 25 Jul 2024 23:06:43 +0200 Subject: [PATCH 77/80] convert GPLv2+ license to SPDX This is part of https://fedoraproject.org/wiki/Changes/SPDX_Licenses_Phase_4 --- beep.spec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/beep.spec b/beep.spec index 5843a3c..8c040d1 100644 --- a/beep.spec +++ b/beep.spec @@ -3,7 +3,8 @@ Name: beep Version: 1.4.12 Release: %autorelease -License: GPLv2+ +# Automatically converted from old format: GPLv2+ - review is highly recommended. +License: GPL-2.0-or-later URL: https://github.com/spkr-beep/beep/ # Upstream github repo: https://github.com/spkr-beep/beep From 57e1d336b8c4f3a48434d12d5c3e4f5e23f198c1 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 16 Jan 2025 12:24:15 +0000 Subject: [PATCH 78/80] Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild From 3c133d9e347a3ba569d4315c64c8816e436c1506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 11 Feb 2025 14:36:19 +0100 Subject: [PATCH 79/80] Add sysusers.d config file to allow rpm to create users/groups automatically See https://fedoraproject.org/wiki/Changes/RPMSuportForSystemdSysusers. --- beep.spec | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/beep.spec b/beep.spec index 8c040d1..84ce491 100644 --- a/beep.spec +++ b/beep.spec @@ -61,7 +61,6 @@ BuildRequires: make # Recommends: (kernel-modules-extras if kernel-modules) # Recommends: (kernel-debug-modules-extras if kernel-debug-modules) -Requires(pre): shadow-utils # /etc/modprobe.d/ Requires: kmod @@ -84,6 +83,11 @@ interesting, but it is really good at the notifying part. %setup -q sed -i 's|^\.\\" \(\.BR .*\)README.Distro\(.*\)|\1README.fedora\2|' beep.1.in && : #" +# Create a sysusers.d config file +cat >beep.sysusers.conf </dev/null || groupadd -r beep -exit 0 %files @@ -146,6 +149,7 @@ exit 0 %config(noreplace) %{_sysconfdir}/modprobe.d/beep.conf %{_udevrulesdir}/70-pcspkr-beep.rules %{_udevrulesdir}/90-pcspkr-beep.rules +%{_sysusersdir}/beep.conf %changelog From 03c83cc47758c6f1f233ecf7e1a4fd1048d5b5d4 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Wed, 23 Jul 2025 17:39:01 +0000 Subject: [PATCH 80/80] Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild