beep-1.4.0-1
Update to beep-1.4.0.
This commit is contained in:
parent
1ddc1b2250
commit
5d7189e984
31 changed files with 26 additions and 1890 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1 +1,2 @@
|
|||
beep-1.3.tar.gz
|
||||
/beep-1.*/
|
||||
/beep-1.*.tar.gz
|
||||
|
|
|
|||
|
|
@ -1,45 +0,0 @@
|
|||
From 8b32b8b088be1f29e8bfea57a97b9bfaa76ec8ee Mon Sep 17 00:00:00 2001
|
||||
From: Chris Wong <chrisyco@gmail.com>
|
||||
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
|
||||
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
From d3aee6c489852108c91dc22abcacff364e9429f2 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Wong <chrisyco@gmail.com>
|
||||
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
|
||||
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
From e1320c1da52ca92aa68b4224f9532982184fbe00 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?J=C3=A9r=C3=B4me?= <jerome@jolimont.fr>
|
||||
Date: Thu, 7 Feb 2013 12:54:53 +0100
|
||||
Subject: [PATCH] also catch SIGTERM for stopping the beep
|
||||
|
||||
Signed-off-by: Gerfried Fuchs <rhonda@deb.at>
|
||||
---
|
||||
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
|
||||
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
From 947a7e332908dcba1c7e523fbdc927d39ee6adb1 Mon Sep 17 00:00:00 2001
|
||||
From: Hans Ulrich Niedermann <hun@n-dimensional.de>
|
||||
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
|
||||
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
From 4622dd15dc12dab47a0381a8a7188f0f0421e01d Mon Sep 17 00:00:00 2001
|
||||
From: Hans Ulrich Niedermann <hun@n-dimensional.de>
|
||||
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
|
||||
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
From 35ba84dccb8fc8dc43cb3f575904a33ffa27e7b7 Mon Sep 17 00:00:00 2001
|
||||
From: Hans Ulrich Niedermann <hun@n-dimensional.de>
|
||||
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
|
||||
|
||||
|
|
@ -1,118 +0,0 @@
|
|||
From 3b67473e16aaf2f83cb8ac18c13c9183a8e3c7b2 Mon Sep 17 00:00:00 2001
|
||||
From: Hans Ulrich Niedermann <hun@n-dimensional.de>
|
||||
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
|
||||
|
||||
|
|
@ -1,196 +0,0 @@
|
|||
From 0d386dbdbf6f5dcb4079b07aef0a905c2ebda532 Mon Sep 17 00:00:00 2001
|
||||
From: Hans Ulrich Niedermann <hun@n-dimensional.de>
|
||||
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 <johnath@johnath.com>
|
||||
+.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.
|
||||
+
|
||||
+
|
||||
+
|
||||
+
|
||||
+
|
||||
+
|
||||
+
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
From 358ec04ce636df50a30be04370bf7c622afbe3d5 Mon Sep 17 00:00:00 2001
|
||||
From: Hans Ulrich Niedermann <hun@n-dimensional.de>
|
||||
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 <fcntl.h>
|
||||
#include <getopt.h>
|
||||
+#include <math.h>
|
||||
#include <signal.h>
|
||||
+#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -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 */
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
From 60a0d26ba7dc9e6c9456c37dbd892cd56d4a2ddb Mon Sep 17 00:00:00 2001
|
||||
From: Hans Ulrich Niedermann <hun@n-dimensional.de>
|
||||
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. */
|
||||
}
|
||||
|
||||
|
|
@ -1,298 +0,0 @@
|
|||
From 10cd5126f320154dccf344e19248c5589d9c20bb Mon Sep 17 00:00:00 2001
|
||||
From: Hans Ulrich Niedermann <hun@n-dimensional.de>
|
||||
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 <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <math.h>
|
||||
@@ -26,6 +27,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
+#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <linux/kd.h>
|
||||
#include <linux/input.h>
|
||||
@@ -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 <https://github.com/ndim/beep/issues>.\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
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
From fbadf12841399cce6c218091adc032ad897256de Mon Sep 17 00:00:00 2001
|
||||
From: Hans Ulrich Niedermann <hun@n-dimensional.de>
|
||||
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.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
- Copyright (C) 19yy <name of author>
|
||||
+ Copyright (C) <year> <name of author>
|
||||
|
||||
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.
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
From d419a0daa59a3afbbc14354feed2701ed2109afb Mon Sep 17 00:00:00 2001
|
||||
From: Hans Ulrich Niedermann <hun@n-dimensional.de>
|
||||
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:
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
From fabfacd13d915c9b4f062b0ad08066d8e5119701 Mon Sep 17 00:00:00 2001
|
||||
From: Hans Ulrich Niedermann <hun@n-dimensional.de>
|
||||
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) {
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
From 9d2d0c1ac754a39711143ba85ac451d989ef0517 Mon Sep 17 00:00:00 2001
|
||||
From: Hans Ulrich Niedermann <hun@n-dimensional.de>
|
||||
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 <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
+#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <signal.h>
|
||||
#include <stdint.h>
|
||||
@@ -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 <https://github.com/ndim/beep/issues>.\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 <https://github.com/ndim/beep/issues>.\n",
|
||||
+ argv[0], optarg);
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ }
|
||||
}
|
||||
break;
|
||||
case 'h' : /* notice that this is also --help */
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
From 67ab66e3201c35b37c2fcabb6b4faeecfee27806 Mon Sep 17 00:00:00 2001
|
||||
From: Hans Ulrich Niedermann <hun@n-dimensional.de>
|
||||
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) {
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
From f30015eb60f83359f3caef95ef1484410a7bd138 Mon Sep 17 00:00:00 2001
|
||||
From: Hans Ulrich Niedermann <hun@n-dimensional.de>
|
||||
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);
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
From 8f1faeee39864d2d147df52b8519a5ae4d2320b0 Mon Sep 17 00:00:00 2001
|
||||
From: Hans Ulrich Niedermann <hun@n-dimensional.de>
|
||||
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) {
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
From e04c6badef5c71c5a1d17f87928990e7e5130533 Mon Sep 17 00:00:00 2001
|
||||
From: Hans Ulrich Niedermann <hun@n-dimensional.de>
|
||||
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 {
|
||||
|
|
@ -1,98 +0,0 @@
|
|||
From 0542134f05df18219ec575026e9e6c31ae98fbee Mon Sep 17 00:00:00 2001
|
||||
From: Hans Ulrich Niedermann <hun@n-dimensional.de>
|
||||
Date: Sat, 29 Dec 2018 01:11:59 +0100
|
||||
Subject: [PATCH] restructure device whitelisting code
|
||||
|
||||
We now allow
|
||||
|
||||
/dev/input/**
|
||||
/dev/console
|
||||
/dev/tty<N>
|
||||
/dev/vc/<N>
|
||||
|
||||
where <N> 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<N> devices */
|
||||
+ return 1;
|
||||
+ } else if ((strncmp("/dev/vc/", dev, 8) == 0) && is_number(&dev[8])) {
|
||||
+ /* match numbered /dev/vc/<N> 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 <https://github.com/ndim/beep/issues>.\n",
|
||||
- argv[0], optarg);
|
||||
+ argv[0], realpath_optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,136 +0,0 @@
|
|||
From f8c6cbbceb3776aa64397cdf856e50f3bc4d8332 Mon Sep 17 00:00:00 2001
|
||||
From: Hans Ulrich Niedermann <hun@n-dimensional.de>
|
||||
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 <johnath@johnath.com>
|
||||
+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.
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
|
|
@ -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}'"
|
||||
|
|
@ -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`.
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
# Uncomment the following line to have the pcspkr driver loaded
|
||||
# automatically on boot
|
||||
# alias platform:pcspkr pcspkr
|
||||
8
beep.csh
8
beep.csh
|
|
@ -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
|
||||
8
beep.sh
8
beep.sh
|
|
@ -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
|
||||
139
beep.spec
139
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 <hun@n-dimensional.de> - 1.4.0-1
|
||||
- Update to beep-1.4.0
|
||||
|
||||
* Sat Dec 29 2018 Hans Ulrich Niedermann <hun@n-dimensional.de> - 1.3-26
|
||||
- Stop shipping old sudo related config files
|
||||
- Refuse to run when run via sudo
|
||||
|
|
|
|||
|
|
@ -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
|
||||
2
sources
2
sources
|
|
@ -1 +1 @@
|
|||
49c340ceb95dbda3f97b2daafac7892a beep-1.3.tar.gz
|
||||
SHA512 (beep-1.4.0.tar.gz) = a81119128f3cc6797c1fbb30e0a3480e62d74d3d650973cbe1d75de59f8dc60b95286bede5164d05bd93a18722b7a77c044cedbdb52a63b99358ddafd7ac877b
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue