Skip to content

Instantly share code, notes, and snippets.

@kaworu
Last active October 15, 2015 13:48
Show Gist options
  • Save kaworu/3457ba112f87e7bab017 to your computer and use it in GitHub Desktop.
Save kaworu/3457ba112f87e7bab017 to your computer and use it in GitHub Desktop.
newsyslog.conf: Allow SIGUSR1 instead of 30
--- /usr/src/usr.sbin/newsyslog/newsyslog.c.orig 2015-10-15 12:19:00.592923000 +0200
+++ /usr/src/usr.sbin/newsyslog/newsyslog.c 2015-10-15 15:47:30.565310000 +0200
@@ -278,6 +278,7 @@
static int log_trim(const char *logname, const struct conf_entry *log_ent);
static int age_old_log(const char *file);
static void savelog(char *from, char *to);
+static int signame_to_signum(const char *);
static void createdir(const struct conf_entry *ent, char *dirpart);
static void createlog(const struct conf_entry *ent);
@@ -1338,7 +1339,7 @@
if (q && *q) {
if (*q == '/')
working->pid_cmd_file = strdup(q);
- else if (isdigit(*q))
+ else if (isalnum(*q))
goto got_sig;
else
errx(1,
@@ -1354,9 +1355,12 @@
working->sig = SIGHUP;
if (q && *q) {
- if (isdigit(*q)) {
+ if (isalnum(*q)) {
got_sig:
- working->sig = atoi(q);
+ if (isdigit(*q))
+ working->sig = atoi(q);
+ else
+ working->sig = signame_to_signum(q);
} else {
err_sig:
errx(1,
@@ -2469,6 +2473,20 @@
err(1, "can't fclose %s", from);
}
+static int
+signame_to_signum(const char *sig)
+{
+ int n;
+
+ if (strncasecmp(sig, "SIG", 3) == 0)
+ sig += 3;
+ for (n = 1; n < sys_nsig; n++) {
+ if (!strcasecmp(sys_signame[n], sig))
+ return (n);
+ }
+ return (-1);
+}
+
/* create one or more directory components of a path */
static void
createdir(const struct conf_entry *ent, char *dirpart)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment