From a13cf6f7955dcf526c1526e0b53d51cfaaaf40af Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Wed, 2 Nov 2011 08:53:27 +0100 Subject: rename_device: skip VLAN=yes configuration files --- src/rename_device.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/rename_device.c b/src/rename_device.c index 3cd25e1e..f96291b0 100644 --- a/src/rename_device.c +++ b/src/rename_device.c @@ -147,11 +147,13 @@ struct netdev *get_configs() { for (x = 0; x < ncfgs; x++ ) { char *path; char *devname, *hwaddr; + int vlan; gchar *contents, **lines; int i; devname = hwaddr = contents = NULL; lines = NULL; + vlan = 0; if (asprintf(&path,"/etc/sysconfig/network-scripts/%s", cfgs[x]->d_name) == -1) continue; @@ -175,8 +177,11 @@ struct netdev *get_configs() { hwaddr = dequote(lines[i] + 7, NULL); } #endif + if (g_str_has_prefix(lines[i],"VLAN=yes")) { + vlan=1; + } } - if (!devname || !hwaddr) { + if (!devname || !hwaddr || vlan) { g_free(contents); g_strfreev(lines); continue; -- cgit v1.2.1 From 823ca3ee71aabcac532c44e8d5489e4606594ac9 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Tue, 24 Apr 2012 17:50:42 -0400 Subject: securetty: check if the device is in the file before attempting to write to it This avoids spurious failures on RO root systems. --- src/securetty.c | 58 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/securetty.c b/src/securetty.c index 9ec8e7ef..a4768e35 100644 --- a/src/securetty.c +++ b/src/securetty.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -25,6 +26,7 @@ #include #include +#include #include #include @@ -66,29 +68,10 @@ int open_and_lock_securetty() { int rewrite_securetty(char *terminal) { int fd; - char *buf, *pos; - struct stat sbuf; fd = open_and_lock_securetty(); if (fd == -1) return 1; - if (fstat(fd, &sbuf) == -1) { - close(fd); - syslog(LOG_ERR, "Couldn't stat /etc/securetty: %s",strerror(errno)); - return 1; - } - buf = malloc(sbuf.st_size + 1); - if (read(fd, buf, sbuf.st_size) != sbuf.st_size) { - close(fd); - syslog(LOG_ERR, "Couldn't read /etc/securetty: %s",strerror(errno)); - return 1; - } - if (!strncmp(buf,terminal,strlen(terminal)) && buf[strlen(terminal)] == '\n') - goto out_ok; - if ((pos = strstr(buf, terminal))) { - if (pos[strlen(terminal)] == '\n' && *(pos-1) == '\n') - goto out_ok; - } if (lseek(fd, 0, SEEK_END) == -1) { close(fd); syslog(LOG_ERR, "Couldn't seek to end of /etc/securetty: %s",strerror(errno)); @@ -96,16 +79,49 @@ int rewrite_securetty(char *terminal) { } write(fd, terminal, strlen(terminal)); write(fd, "\n", 1); -out_ok: close(fd); return 0; } +int check_securetty(char *terminal) { + int fd, rc = 1; + char *buf, term[PATH_MAX]; + struct stat sb; + + fd = open("/etc/securetty", O_RDONLY); + if (fd == -1) + goto out; + fstat(fd, &sb); + buf = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd, 0); + if (buf == ((caddr_t) -1)) { + close(fd); + return 1; + } + snprintf(term,PATH_MAX,"%s\n",terminal); + if (!strncmp(buf,term,strlen(term))) { + rc = 0; + goto out_unmap; + } + snprintf(term,PATH_MAX,"\n%s\n",terminal); + if (strstr(buf,term)) { + rc = 0; + goto out_unmap; + } +out_unmap: + munmap(buf, sb.st_size); +out: + close(fd); + return rc; +} + int main(int argc, char **argv) { if (argc < 2 ) { fprintf(stderr, "Usage: securetty \n"); exit(1); } openlog("securetty", LOG_CONS, LOG_DAEMON); - return rewrite_securetty(argv[1]); + if (check_securetty(argv[1])) + return rewrite_securetty(argv[1]); + else + return 0; } -- cgit v1.2.1 From 746aedf50e522a8dafa5ba82f1febceec9af6d1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Tue, 26 Jun 2012 23:54:50 +0300 Subject: Sync FSF address with current GPLv2. --- src/console_check.c | 4 ++-- src/console_init.c | 4 ++-- src/consoletype.c | 4 ++-- src/genhostid.c | 4 ++-- src/getkey.c | 8 ++++---- src/ipcalc.c | 4 ++-- src/netreport.c | 4 ++-- src/ppp-watch.c | 4 ++-- src/securetty.c | 4 ++-- src/shvar.c | 4 ++-- src/shvar.h | 4 ++-- src/usernetctl.c | 4 ++-- src/usleep.c | 4 ++-- 13 files changed, 28 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/console_check.c b/src/console_check.c index 688bff61..8d01d829 100644 --- a/src/console_check.c +++ b/src/console_check.c @@ -11,8 +11,8 @@ * 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 + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ diff --git a/src/console_init.c b/src/console_init.c index 22083a86..446433d0 100644 --- a/src/console_init.c +++ b/src/console_init.c @@ -11,8 +11,8 @@ * 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 + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ diff --git a/src/consoletype.c b/src/consoletype.c index fb2a9116..929969a4 100644 --- a/src/consoletype.c +++ b/src/consoletype.c @@ -11,8 +11,8 @@ * 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 + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ diff --git a/src/genhostid.c b/src/genhostid.c index 1b83d538..c7561c9e 100644 --- a/src/genhostid.c +++ b/src/genhostid.c @@ -10,8 +10,8 @@ * 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 + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ diff --git a/src/getkey.c b/src/getkey.c index 11496260..95e660ba 100644 --- a/src/getkey.c +++ b/src/getkey.c @@ -11,11 +11,11 @@ * 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 + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * getkey * - * getkey - * * A very simple keygrabber. * */ diff --git a/src/ipcalc.c b/src/ipcalc.c index 8decccad..7316f058 100644 --- a/src/ipcalc.c +++ b/src/ipcalc.c @@ -11,8 +11,8 @@ * 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 + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * Authors: * Erik Troan diff --git a/src/netreport.c b/src/netreport.c index a2b2625c..31bfe2f6 100644 --- a/src/netreport.c +++ b/src/netreport.c @@ -11,8 +11,8 @@ * 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 + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #include diff --git a/src/ppp-watch.c b/src/ppp-watch.c index 1fa81929..cbe35360 100644 --- a/src/ppp-watch.c +++ b/src/ppp-watch.c @@ -19,8 +19,8 @@ * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ diff --git a/src/securetty.c b/src/securetty.c index a4768e35..59abb6e9 100644 --- a/src/securetty.c +++ b/src/securetty.c @@ -11,8 +11,8 @@ * 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 + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ diff --git a/src/shvar.c b/src/shvar.c index 765a77e7..9817d9a4 100644 --- a/src/shvar.c +++ b/src/shvar.c @@ -23,8 +23,8 @@ * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ diff --git a/src/shvar.h b/src/shvar.h index 50d10680..46fb6b7b 100644 --- a/src/shvar.h +++ b/src/shvar.h @@ -23,8 +23,8 @@ * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ #ifndef _SHVAR_H diff --git a/src/usernetctl.c b/src/usernetctl.c index f66cfeb9..9e127604 100644 --- a/src/usernetctl.c +++ b/src/usernetctl.c @@ -11,8 +11,8 @@ * 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 + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ diff --git a/src/usleep.c b/src/usleep.c index 0409498d..a5e7d9d7 100644 --- a/src/usleep.c +++ b/src/usleep.c @@ -15,8 +15,8 @@ * 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 + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ -- cgit v1.2.1 From d85174edb7389f670705595804b48aee0278ed2f Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Mon, 6 Aug 2012 15:18:23 -0400 Subject: Initial removal of support for non-systemd systems. --- src/Makefile | 15 +--- src/console_check.c | 207 ---------------------------------------------------- src/console_init.c | 168 ------------------------------------------ src/securetty.8 | 15 ---- src/securetty.c | 127 -------------------------------- 5 files changed, 1 insertion(+), 531 deletions(-) delete mode 100644 src/console_check.c delete mode 100644 src/console_init.c delete mode 100644 src/securetty.8 delete mode 100644 src/securetty.c (limited to 'src') diff --git a/src/Makefile b/src/Makefile index b478cb9f..68833182 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,8 +1,7 @@ CFLAGS+=$(RPM_OPT_FLAGS) -Wall -D_GNU_SOURCE PROGS=usernetctl netreport testd usleep ipcalc \ - fstab-decode getkey ppp-watch consoletype genhostid rename_device \ - console_init console_check securetty + fstab-decode getkey ppp-watch consoletype genhostid rename_device PPPWATCH_OBJS=ppp-watch.o shvar.o CONSOLE_INIT_OBJS=console_init.o shvar.o USLEEP_OBJS=usleep.o @@ -28,11 +27,8 @@ install: install -m 755 getkey $(ROOT)/sbin/getkey install -m 755 ppp-watch $(ROOT)/sbin/ppp-watch install -m 755 consoletype $(ROOT)/sbin/consoletype - install -m 755 securetty $(ROOT)/sbin/securetty install -m 755 sushell $(ROOT)/sbin/sushell install -m 755 rename_device $(ROOT)/lib/udev/rename_device - install -m 755 console_init $(ROOT)/lib/udev/console_init - install -m 755 console_check $(ROOT)/lib/udev/console_check install -m 644 genhostid.1 $(ROOT)$(mandir)/man1 install -m 644 getkey.1 $(ROOT)$(mandir)/man1 install -m 644 netreport.1 $(ROOT)$(mandir)/man1 @@ -44,7 +40,6 @@ install: install -m 644 consoletype.1 $(ROOT)$(mandir)/man1 install -m 644 ifup.8 $(ROOT)$(mandir)/man8 install -m 644 setsysfont.8 $(ROOT)$(mandir)/man8 - install -m 644 securetty.8 $(ROOT)$(mandir)/man8 install -m 644 sushell.8 $(ROOT)$(mandir)/man8 ln -s ifup.8 $(ROOT)$(mandir)/man8/ifdown.8 @@ -72,9 +67,6 @@ usernetctl.o: usernetctl.c usernetctl: usernetctl.c usernetctl.o $(CC) $(LDFLAGS) -pie -o $@ $@.o -securetty: securetty.o - $(CC) $(LDFLAGS) -o $@ $< - shvar.o: shvar.c $(CC) $(CFLAGS) `pkg-config glib-2.0 --cflags` -c shvar.c -o shvar.o @@ -84,8 +76,3 @@ ppp-watch.o: ppp-watch.c rename_device: rename_device.c $(CC) $(CFLAGS) `pkg-config glib-2.0 --cflags` -o $@ $< `pkg-config glib-2.0 --libs` -console_init.o: console_init.c - $(CC) $(CFLAGS) `pkg-config glib-2.0 --cflags` -c console_init.c -o console_init.o - -console_init: $(CONSOLE_INIT_OBJS) - $(CC) $(LDFLAGS) -o $@ $(CONSOLE_INIT_OBJS) `pkg-config glib-2.0 --libs` diff --git a/src/console_check.c b/src/console_check.c deleted file mode 100644 index 8d01d829..00000000 --- a/src/console_check.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (c) 2008-2009 Red Hat, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#ifndef PORT_OMAP -/* from linux-2.6/include/linux/serial_core.h commit b612633b */ -#define PORT_OMAP 96 -#endif - -struct speeds -{ - speed_t speed; - unsigned long value; -}; - -struct speeds speed_map[] = -{ - {B50, 50}, - {B75, 75}, - {B110, 110}, - {B134, 134}, - {B150, 150}, - {B200, 200}, - {B300, 300}, - {B600, 600}, - {B1200, 1200}, - {B1800, 1800}, - {B2400, 2400}, - {B4800, 4800}, - {B9600, 9600}, - {B19200, 19200}, - {B38400, 38400}, -#ifdef B57600 - {B57600, 57600}, -#endif -#ifdef B115200 - {B115200, 115200}, -#endif -#ifdef B230400 - {B230400, 230400}, -#endif -#ifdef B460800 - {B460800, 460800}, -#endif - {0, 0} -}; - -int termcmp(struct termios *a, struct termios *b) { - if (a->c_iflag != b->c_iflag || a->c_oflag != b->c_oflag || - a->c_cflag != b->c_cflag || a->c_lflag != b->c_lflag || - cfgetispeed(a) != cfgetispeed(b) || cfgetospeed(a) != cfgetospeed(b)) - return 1; - return memcmp(a->c_cc, b->c_cc, sizeof(a->c_cc)); -} - -int get_serial_speed(int fd) { - struct termios mode; - - if (!tcgetattr(fd, &mode)) { - int i; - speed_t speed; - - speed = cfgetospeed(&mode); - for (i = 0; speed_map[i].value != 0; i++) - if (speed_map[i].speed == speed) - return speed_map[i].value; - } - return 0; -} - -int compare_termios_to_console(char *dev, int *speed) { - struct termios cmode, mode; - int fd, cfd; - - cfd = open ("/dev/console", O_RDONLY); - tcgetattr(cfd, &cmode); - close(cfd); - - fd = open(dev, O_RDONLY|O_NONBLOCK); - tcgetattr(fd, &mode); - - if (!termcmp(&cmode, &mode)) { - *speed = get_serial_speed(fd); - close(fd); - return 1; - } - close(fd); - return 0; -} - -char *serial_tty_name(int type) { - switch (type) { - case PORT_8250...PORT_MAX_8250: - return "ttyS"; - case PORT_PMAC_ZILOG: - return "ttyPZ"; - case PORT_MPSC: - return "ttyMM"; - case PORT_CPM: - return "ttyCPM"; - case PORT_MPC52xx: - return "ttyPSC"; - case PORT_IMX: - return "ttymxc"; - case PORT_OMAP: - return "ttyO"; - default: - return NULL; - } -} - -char *check_serial_console(int *speed) { - int fd; - char *ret = NULL, *device; - char twelve = 12; - struct serial_struct si, si2; - char *tty_name; - - memset(&si, 0, sizeof(si)); - memset(&si2, 0, sizeof(si)); - - fd = open("/dev/console", O_RDWR); - if (ioctl (fd, TIOCLINUX, &twelve) >= 0) - goto out; - - if (ioctl(fd, TIOCGSERIAL, &si) < 0) - goto out; - close(fd); - - tty_name = serial_tty_name(si.type); - if (!tty_name) - goto out; - - asprintf(&device, "%s%d", tty_name, si.line); - fd = open(device, O_RDWR|O_NONBLOCK); - if (fd == -1) - goto out; - - if (ioctl(fd, TIOCGSERIAL, &si2) < 0) - goto out; - - if (memcmp(&si,&si2, sizeof(si))) - goto out; - - *speed = get_serial_speed(fd); - ret = device; -out: - close(fd); - return ret; -} - -int emit_console_event(char *dev, int speed) { - char *args[] = { "initctl", "emit", "--no-wait", "fedora.serial-console-available", NULL, NULL, NULL }; - - if (dev) - asprintf(&args[4],"DEV=%s",dev); - if (speed) - asprintf(&args[5],"SPEED=%d",speed); - execv("/sbin/initctl", args); - return 1; -} - -int main(int argc, char **argv) { - char *device; - int speed; - - if (argc < 2) { - printf("usage: console_check \n"); - exit(1); - } - chdir("/dev"); - device = argv[1]; - if (!strcmp(device, "console")) { - device = check_serial_console(&speed); - if (device) - return emit_console_event(device, speed); - } else if (compare_termios_to_console(device, &speed)) { - return emit_console_event(device, speed); - } - return 0; -} diff --git a/src/console_init.c b/src/console_init.c deleted file mode 100644 index 446433d0..00000000 --- a/src/console_init.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2008-2009 Red Hat, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - */ - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include "shvar.h" - -static char *lang = NULL; -static char *font = NULL; -static char *acm = NULL; -static char *unimap = NULL; -static char *keymap = NULL; - -static int linux_console(int fd) { - unsigned char twelve = 12; - - if (ioctl(fd, TIOCLINUX, &twelve) >= 0) - return 1; - return 0; -} - -static int configured_as_utf8() { - shvarFile *i18nfile = NULL; - - if ((i18nfile = svNewFile("/etc/sysconfig/i18n")) == NULL) - return 1; /* assume UTF-8 */ - - lang = svGetValue(i18nfile, "LANG"); - font = svGetValue(i18nfile, "SYSFONT"); - acm = svGetValue(i18nfile, "SYSFONTACM"); - unimap = svGetValue(i18nfile, "UNIMAP"); - svCloseFile(i18nfile); - if (!lang) - return 1; - if (g_str_has_suffix(lang,".utf8") || g_str_has_suffix(lang,".UTF-8")) - return 1; - return 0; -} - -static int read_keymap() { - shvarFile *keyboard = NULL; - char *tmp; - struct stat sb; - - if (!stat("/etc/sysconfig/console/default.kmap",&sb)) { - keymap = "/etc/sysconfig/console/default.kmap"; - return 0; - } - - if ((keyboard = svNewFile("/etc/sysconfig/keyboard")) == NULL) - return 0; - - tmp = svGetValue(keyboard, "KEYMAP"); - if (tmp) - keymap = tmp; - tmp = svGetValue(keyboard, "KEYTABLE"); - if (tmp) { - if (keymap) free(keymap); - asprintf(&keymap, "%s.map", tmp); - } - return 0; -} - -static void set_font(char *device) { - int pid; - - if ( (pid = fork()) == 0) { - char *args[] = { "setfont", "latarcyrheb-sun16", "-C", NULL, - NULL, NULL, NULL, NULL, NULL }; - - if (font) - args[1] = font; - args[3] = device; - if (acm) { - args[4] = "-m"; - args[5] = acm; - if (unimap) { - args[6] = "-u"; - args[7] = unimap; - } - } else if (unimap) { - args[4] = "-u"; - args[5] = unimap; - } - execv("/bin/setfont", args); - exit(1); - } -} - -static void set_keyboard(int fd, int utf8) { - if (ioctl(fd, KDSKBMODE, utf8 ? K_UNICODE : K_XLATE)) - perror("could not set keyboard mode"); -} - -static void set_terminal(int fd, int utf8) { - if (utf8) - write(fd, "\033%G", 3); - else - write(fd, "\033%@", 3); -} - -static void set_keymap(int fd, int utf8) { - int pid; - - if ((pid = fork()) == 0) { - char *args[] = { "loadkeys", "-q", NULL, NULL, NULL }; - dup2(fd, 0); - dup2(fd, 1); - - if (utf8) { - args[2] = "-u"; - args[3] = keymap; - } else { - args[2] = keymap; - } - execv("/bin/loadkeys", args); - exit(1); - } -} - -int main(int argc, char **argv) { - char *device; - int dev; - - if (argc < 2) { - printf("usage: console_init \n"); - exit(1); - } - chdir("/dev"); - device = argv[1]; - dev = open(device, O_RDWR); - if (linux_console(dev)) { - int utf8 = configured_as_utf8(); - - set_keyboard(dev, utf8); - set_terminal(dev, utf8); - set_font(device); - read_keymap(); - if (keymap) - set_keymap(dev,utf8); - } - return 0; -} diff --git a/src/securetty.8 b/src/securetty.8 deleted file mode 100644 index 2aad6bca..00000000 --- a/src/securetty.8 +++ /dev/null @@ -1,15 +0,0 @@ -.\" Copyright 2009 Petr Lautrbach (plautrba@redhat.com) -.TH securetty 8 2009-10-27 "" "System Administration tools and Daemons" -.SH NAME -securetty \- add a tty to /etc/securetty -.SH SYNOPSIS -.B securetty \fItty\fP -.SH DESCRIPTION -.B securetty -safely adds \fItty\fP to /etc/securetty. -.SH NOTES -.B securetty -is not normally meant to be run by hand; it is invoked by the upstart job that -sets up the system serial console. -.SH "SEE ALSO" -.BR securetty(5) diff --git a/src/securetty.c b/src/securetty.c deleted file mode 100644 index 59abb6e9..00000000 --- a/src/securetty.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2008 Red Hat, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -void alarm_handler(int num) { - return; -} - -int open_and_lock_securetty() { - int fd; - struct flock lock; - struct sigaction act, oldact; - - lock.l_type = F_WRLCK; - lock.l_whence = SEEK_SET; - lock.l_start = 0; - lock.l_len = 0; - - fd = open("/etc/securetty", O_RDWR); - if (fd == -1) { - syslog(LOG_ERR, "Couldn't open /etc/securetty: %s",strerror(errno)); - return -1; - } - act.sa_handler = alarm_handler; - act.sa_flags = 0; - sigaction(SIGALRM, &act, &oldact); - alarm(2); - while (fcntl(fd, F_SETLKW, &lock) == -1) { - if (errno == EINTR) { - syslog(LOG_ERR, "Couldn't lock /etc/securetty: Timeout exceeded"); - } else { - syslog(LOG_ERR, "Couldn't lock /etc/securetty: %s",strerror(errno)); - } - return -1; - } - alarm(0); - sigaction(SIGALRM, &oldact, NULL); - return fd; -} - -int rewrite_securetty(char *terminal) { - int fd; - - fd = open_and_lock_securetty(); - if (fd == -1) - return 1; - if (lseek(fd, 0, SEEK_END) == -1) { - close(fd); - syslog(LOG_ERR, "Couldn't seek to end of /etc/securetty: %s",strerror(errno)); - return 1; - } - write(fd, terminal, strlen(terminal)); - write(fd, "\n", 1); - close(fd); - return 0; -} - -int check_securetty(char *terminal) { - int fd, rc = 1; - char *buf, term[PATH_MAX]; - struct stat sb; - - fd = open("/etc/securetty", O_RDONLY); - if (fd == -1) - goto out; - fstat(fd, &sb); - buf = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd, 0); - if (buf == ((caddr_t) -1)) { - close(fd); - return 1; - } - snprintf(term,PATH_MAX,"%s\n",terminal); - if (!strncmp(buf,term,strlen(term))) { - rc = 0; - goto out_unmap; - } - snprintf(term,PATH_MAX,"\n%s\n",terminal); - if (strstr(buf,term)) { - rc = 0; - goto out_unmap; - } -out_unmap: - munmap(buf, sb.st_size); -out: - close(fd); - return rc; -} - -int main(int argc, char **argv) { - if (argc < 2 ) { - fprintf(stderr, "Usage: securetty \n"); - exit(1); - } - openlog("securetty", LOG_CONS, LOG_DAEMON); - if (check_securetty(argv[1])) - return rewrite_securetty(argv[1]); - else - return 0; -} -- cgit v1.2.1 From 23bfcbd74b4a02d302927961dc183066937e17e4 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Mon, 6 Aug 2012 15:19:38 -0400 Subject: Drop testd test sysv script. --- src/Makefile | 8 +------- src/testd.c | 9 --------- src/testdinit | 44 -------------------------------------------- 3 files changed, 1 insertion(+), 60 deletions(-) delete mode 100644 src/testd.c delete mode 100755 src/testdinit (limited to 'src') diff --git a/src/Makefile b/src/Makefile index 68833182..09f17771 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,6 +1,6 @@ CFLAGS+=$(RPM_OPT_FLAGS) -Wall -D_GNU_SOURCE -PROGS=usernetctl netreport testd usleep ipcalc \ +PROGS=usernetctl netreport usleep ipcalc \ fstab-decode getkey ppp-watch consoletype genhostid rename_device PPPWATCH_OBJS=ppp-watch.o shvar.o CONSOLE_INIT_OBJS=console_init.o shvar.o @@ -43,12 +43,6 @@ install: install -m 644 sushell.8 $(ROOT)$(mandir)/man8 ln -s ifup.8 $(ROOT)$(mandir)/man8/ifdown.8 -# this daemon and initscript are useful for testing the up/down/status stuff -# not installed by default, only comes from sources. -install-test: - install -m 755 testd $(ROOT)/usr/sbin/testd - install -m 755 testdinit $(ROOT)/etc/init.d/testd - getkey: getkey.o $(CC) $(LDFLAGS) -o $@ $< -lpopt diff --git a/src/testd.c b/src/testd.c deleted file mode 100644 index b2a5c7e6..00000000 --- a/src/testd.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include -#include - -int main() { - signal(SIGTERM, SIG_IGN); - while (1) sleep(20); - exit(0); -} diff --git a/src/testdinit b/src/testdinit deleted file mode 100755 index a6500991..00000000 --- a/src/testdinit +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -# -# lpd This shell script takes care of starting and stopping -# lpd (printer daemon). -# - -# Source function library. -. /etc/init.d/functions - -# See how we were called. -case "$1" in - start) - # Start daemons. - echo -n $"Starting testd: " - testd & - echo - touch /var/lock/subsys/testd - ;; - stop) - # Stop daemons. - echo -n $"Shutting down testd: " - killproc testd - echo - rm -f /var/lock/subsys/testd - ;; - status) - # Am I alive? - status testd - exit $? - ;; - restart) - echo -n $"Shutting down testd: " - killproc testd - echo - echo -n $"Starting testd: " - testd & - echo - ;; - *) - echo $"Usage: testd {start|stop|status|restart}" - exit 1 -esac - -exit 0 -- cgit v1.2.1 From 345e4fc14c6e6a043bc3fe4eeb8c39a36957fbf8 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Mon, 6 Aug 2012 15:20:03 -0400 Subject: Drop fstab-decode and getkey; no longer used. Drop the umount loop from rc.d/init.d/functions. --- src/Makefile | 9 +--- src/fstab-decode.8 | 46 ----------------- src/fstab-decode.c | 86 -------------------------------- src/getkey.1 | 80 ------------------------------ src/getkey.c | 141 ----------------------------------------------------- 5 files changed, 1 insertion(+), 361 deletions(-) delete mode 100644 src/fstab-decode.8 delete mode 100644 src/fstab-decode.c delete mode 100644 src/getkey.1 delete mode 100644 src/getkey.c (limited to 'src') diff --git a/src/Makefile b/src/Makefile index 09f17771..d93e7202 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,7 @@ CFLAGS+=$(RPM_OPT_FLAGS) -Wall -D_GNU_SOURCE PROGS=usernetctl netreport usleep ipcalc \ - fstab-decode getkey ppp-watch consoletype genhostid rename_device + ppp-watch consoletype genhostid rename_device PPPWATCH_OBJS=ppp-watch.o shvar.o CONSOLE_INIT_OBJS=console_init.o shvar.o USLEEP_OBJS=usleep.o @@ -22,18 +22,14 @@ install: install -m 4755 usernetctl $(ROOT)/usr/sbin/usernetctl install -m 2755 netreport $(ROOT)/sbin/netreport install -m 755 ipcalc $(ROOT)/bin/ipcalc - install -m 755 fstab-decode $(ROOT)/sbin/fstab-decode install -m 755 genhostid $(ROOT)/sbin/genhostid - install -m 755 getkey $(ROOT)/sbin/getkey install -m 755 ppp-watch $(ROOT)/sbin/ppp-watch install -m 755 consoletype $(ROOT)/sbin/consoletype install -m 755 sushell $(ROOT)/sbin/sushell install -m 755 rename_device $(ROOT)/lib/udev/rename_device install -m 644 genhostid.1 $(ROOT)$(mandir)/man1 - install -m 644 getkey.1 $(ROOT)$(mandir)/man1 install -m 644 netreport.1 $(ROOT)$(mandir)/man1 install -m 644 usleep.1 $(ROOT)$(mandir)/man1 - install -m 644 fstab-decode.8 $(ROOT)$(mandir)/man8 install -m 644 usernetctl.8 $(ROOT)$(mandir)/man8 install -m 644 ppp-watch.8 $(ROOT)$(mandir)/man8 install -m 644 ipcalc.1 $(ROOT)$(mandir)/man1 @@ -43,9 +39,6 @@ install: install -m 644 sushell.8 $(ROOT)$(mandir)/man8 ln -s ifup.8 $(ROOT)$(mandir)/man8/ifdown.8 -getkey: getkey.o - $(CC) $(LDFLAGS) -o $@ $< -lpopt - ipcalc: ipcalc.o $(CC) -D_GNU_SOURCE $(LDFLAGS) -o $@ $< -lpopt diff --git a/src/fstab-decode.8 b/src/fstab-decode.8 deleted file mode 100644 index d7ce9e70..00000000 --- a/src/fstab-decode.8 +++ /dev/null @@ -1,46 +0,0 @@ -.\" A man page for fstab-decode(8). -.\" -.\" Copyright (C) 2006 Red Hat, Inc. All rights reserved. -.\" -.\" This copyrighted material is made available to anyone wishing to use, -.\" modify, copy, or redistribute it subject to the terms and conditions of the -.\" GNU General Public License v.2. -.\" -.\" This program is distributed in the hope that it will be useful, but WITHOUT -.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -.\" FITNESS FOR A PARTICULAR PURPOSE. See the 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., -.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -.\" -.\" Author: Miloslav Trmac -.TH fstab-decode 8 "May 2006" - -.SH NAME -fstab-decode \- run a command with fstab-encoded arguments - -.SH SYNOPSIS -\fB fstab-decode\fR \fICOMMAND\fR [\fIARGUMENT\fR]... - -.SH DESCRIPTION -.B fstab-decode -decodes escapes in the specified \FIARGUMENT\fRs -and uses them to run \fICOMMAND\fR. -The argument escaping uses the same rules as path escaping in -\fB/etc/fstab\fR, -.B /etc/mtab -and \fB/proc/mtab\fR. - -.SH EXIT STATUS -.B fstab-decode -exits with status 127 if -.I COMMAND -can't be run. -Otherwise it exits with the status returned by \fICOMMAND\fR. - -.SH EXAMPLES - -.B -fstab-decode umount $(awk '$3 == "vfat" { print $2 }' /etc/fstab) diff --git a/src/fstab-decode.c b/src/fstab-decode.c deleted file mode 100644 index 4a162dfe..00000000 --- a/src/fstab-decode.c +++ /dev/null @@ -1,86 +0,0 @@ -/* fstab-decode(8). - -Copyright (c) 2006 Red Hat, Inc. All rights reserved. - -This copyrighted material is made available to anyone wishing to use, modify, -copy, or redistribute it subject to the terms and conditions of the GNU General -Public License v.2. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PARTICULAR PURPOSE. See the 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., 51 Franklin -Street, Fifth Floor, Boston, MA 02110-1301, USA. - -Author: Miloslav Trmac */ - -#include -#include -#include -#include -#include - -/* Decode the fstab-encoded string in place. */ -static void -decode(char *s) -{ - const char *src; - char *dest; - - src = s; - dest = s; - while (*src != '\0') { - if (*src != '\\') - *dest = *src++; - else { - static const struct repl { - char orig[4]; - size_t len; - char new; - } repls[] = { -#define R(X, Y) { X, sizeof(X) - 1, Y } - R("\\", '\\'), - R("011", '\t'), - R("012", '\n'), - R("040", ' '), - R("134", '\\') -#undef R - }; - - size_t i; - - for (i = 0; i < sizeof (repls) / sizeof (repls[0]); - i++) { - if (memcmp(src + 1, repls[i].orig, - repls[i].len) == 0) { - *dest = repls[i].new; - src += 1 + repls[i].len; - goto found; - } - } - *dest = *src++; - found: - ; - } - dest++; - } - *dest = '\0'; -} - -int -main (int argc, char *argv[]) -{ - size_t i; - - if (argc < 2) { - fprintf(stderr, "Usage: fstab-decode command [arguments]\n"); - return EXIT_FAILURE; - } - for (i = 2; i < (size_t)argc; i++) - decode(argv[i]); - execvp(argv[1], argv + 1); - fprintf(stderr, "fstab-decode: %s: %s\n", argv[1], strerror(errno)); - return 127; -} diff --git a/src/getkey.1 b/src/getkey.1 deleted file mode 100644 index f6c11616..00000000 --- a/src/getkey.1 +++ /dev/null @@ -1,80 +0,0 @@ -.\" A man page for getkey(1). -*- nroff -*- -.\" -.\" Copyright (C) 2006 Red Hat, Inc. All rights reserved. -.\" -.\" This copyrighted material is made available to anyone wishing to use, -.\" modify, copy, or redistribute it subject to the terms and conditions of the -.\" GNU General Public License v.2. -.\" -.\" This program is distributed in the hope that it will be useful, but WITHOUT -.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -.\" FITNESS FOR A PARTICULAR PURPOSE. See the 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., -.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -.\" -.\" Author: Miloslav Trmac -.TH getkey 1 "Jan 2006" - -.SH NAME -getkey \- wait until a key is pressed - -.SH SYNOPSIS -\fBgetkey\fR [\fIOPTION\fR]... [\fIKEYS\fR] - -.SH DESCRIPTION -.B getkey -waits until one of -.I KEYS -is pressed. -If -.I KEYS -are not specified, any key is accepted. -.I KEYS -are matched case-insensitive. - -.SH EXIT STATUS -.B getkey -exits with status 0 if one of the expected keys is pressed. -If invalid arguments are specified, -.B getkey -exits with status 255. -If -.B getkey -is interrupted or the wait times out, -.B getkey -exits with other non-zero status. - -.SH OPTIONS -.TP -\fB\-c\fR, \fB\-\-wait\fR \fISECONDS\fR -Wait only for -.I SECONDS -seconds. -The default is 0, which means to wait without a time limit. - -.TP -\fB\-i\fR, \fB\-\-ignore\-control\-chars\fR -Don't treat Ctrl+C and Ctrl+D specially. -When this option is not specified, these characters interrupt \fBgetkey\fR. - -.TP -\fB\-m\fR, \fB\-\-message\fR \fIMESSAGE\fR -Display -.I MESSAGE -while waiting. -The message is used as a format string in -.BR sprintf (3), -with a single argument, the number of seconds left. -Typical usage is therefore -\fB"Press a key within %d seconds to ..."\fR. -If -.I MESSAGE -contains other format string directives, the behavior is undefined and -.B getkey -may crash. - -If there is no time limit specified, -the number of seconds left is reported as 0. diff --git a/src/getkey.c b/src/getkey.c deleted file mode 100644 index 95e660ba..00000000 --- a/src/getkey.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 1999-2003, 2006 Red Hat, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * getkey - * - * A very simple keygrabber. - * - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "popt.h" - -static struct termios orig_tp; - -static void reset_term(int x) { - tcsetattr(0,TCSANOW,&orig_tp); - _exit(x); -} - -int main(int argc, char **argv) { - static const char default_list[] = ""; - - const char *list; - char *waitmessage = NULL; - char *waitprint, *waitsprint; - int waitseconds=0; - int alarmlen=0; - int ignore_control=0; - struct termios tp; - int r; - struct pollfd ufds; /* only one, no need for an array... */ - poptContext context; - struct poptOption options[] = { - { "wait", 'c', POPT_ARG_INT, &waitseconds, 0, "Number of seconds to wait for keypress", NULL }, - { "message", 'm', POPT_ARG_STRING, &waitmessage, 0, "Message to print out while waiting for string\nNOTE: The message may have a \"%d\" in it, to hold the number of seconds left to wait.", NULL }, - { "ignore-control-chars", 'i', POPT_ARG_NONE, &ignore_control, 0, "Ignore Control-C and Control-D", NULL }, - POPT_AUTOHELP - POPT_TABLEEND - }; - - context = poptGetContext("getkey", argc, (const char **)argv, options, - POPT_CONTEXT_POSIXMEHARDER); - poptSetOtherOptionHelp(context, "[keys]"); - - r = poptGetNextOpt(context); - if (r < -1) { - fprintf(stderr, "%s: %s\n", - poptBadOption(context, POPT_BADOPTION_NOALIAS), - poptStrerror(r)); - - return -1; - } - list = poptGetArg(context); - if (list != NULL) { - char *p; - - p = strdup(list); - list = p; - while (*p != 0) { - *p = toupper(*p); - p++; - } - } else - list = default_list; - if (waitseconds) { - if (waitseconds < 0) { - fprintf(stderr, "--wait: Invalid time %d seconds\n", - waitseconds); - return -1; - } - alarmlen = waitseconds; - } - - tcgetattr(0,&tp); - orig_tp = tp; - signal(SIGTERM,reset_term); - if (alarmlen != 0) { - signal(SIGALRM,reset_term); - alarm(alarmlen); - } - - tp.c_iflag=0; - tp.c_oflag &= ~OPOST; - tp.c_lflag &= ~(ISIG | ICANON); - tcsetattr(0,TCSANOW,&tp); - - ufds.events = POLLIN; - ufds.fd = 0; - - if (waitmessage) { - waitprint = alloca (strlen(waitmessage)+15); /* long enough */ - waitprint[0] = '\r'; - waitsprint = waitprint + 1; - } - - while (1) { - if (waitmessage) { - sprintf (waitsprint, waitmessage, waitseconds); - write (1, waitprint, strlen(waitprint)); - } - r = poll(&ufds, 1, alarmlen ? 1000 : -1); - if (r == 0) { - /* we have waited a whole second with no keystroke... */ - waitseconds--; - } - if (r > 0) { - char ch; - - read(0, &ch, sizeof(ch)); - ch = toupper(ch); - /* Die if we get a control-c or control-d */ - if (ignore_control == 0 && (ch == 3 || ch == 4)) - reset_term(1); - /* Don't let a null character be interpreted as a match - by strchr */ - if (ch != 0 - && (strcmp(list, "") == 0 || strchr(list, ch) != NULL)) - reset_term(0); - } - } -} -- cgit v1.2.1