diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 30 | ||||
-rw-r--r-- | src/console_check.c | 208 | ||||
-rw-r--r-- | src/console_init.c | 256 | ||||
-rw-r--r-- | src/consoletype.c | 4 | ||||
-rw-r--r-- | src/fstab-decode.8 | 46 | ||||
-rw-r--r-- | src/fstab-decode.c | 86 | ||||
-rw-r--r-- | src/genhostid.c | 4 | ||||
-rw-r--r-- | src/getkey.1 | 80 | ||||
-rw-r--r-- | src/getkey.c | 141 | ||||
-rw-r--r-- | src/ipcalc.c | 4 | ||||
-rw-r--r-- | src/netreport.c | 4 | ||||
-rw-r--r-- | src/ppp-watch.c | 4 | ||||
-rw-r--r-- | src/rename_device.c | 7 | ||||
-rw-r--r-- | src/securetty.8 | 15 | ||||
-rw-r--r-- | src/securetty.c | 111 | ||||
-rw-r--r-- | src/shvar.c | 4 | ||||
-rw-r--r-- | src/shvar.h | 4 | ||||
-rw-r--r-- | src/testd.c | 9 | ||||
-rwxr-xr-x | src/testdinit | 44 | ||||
-rw-r--r-- | src/usernetctl.c | 4 | ||||
-rw-r--r-- | src/usleep.c | 4 |
21 files changed, 26 insertions, 1043 deletions
diff --git a/src/Makefile b/src/Makefile index b478cb9f..d93e7202 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 +PROGS=usernetctl netreport usleep ipcalc \ + 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 @@ -23,40 +22,23 @@ 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 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 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 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 -# 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 - ipcalc: ipcalc.o $(CC) -D_GNU_SOURCE $(LDFLAGS) -o $@ $< -lpopt @@ -72,9 +54,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 +63,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 9b66cfcb..00000000 --- a/src/console_check.c +++ /dev/null @@ -1,208 +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - * - */ - -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <termios.h> -#include <unistd.h> - -#include <sys/ioctl.h> - -#include <linux/types.h> -#include <linux/serial.h> -#include <linux/serial_core.h> - -#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 <device>\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 494959a1..00000000 --- a/src/console_init.c +++ /dev/null @@ -1,256 +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - * - */ - -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> - -#include <sys/ioctl.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <sys/wait.h> - -#include <linux/kd.h> - -#include "shvar.h" - -static char *lang = NULL; -static char *font = NULL; -static char *acm = NULL; -static char *unimap = NULL; -static char *keymap = NULL; -static char *unikeytable = NULL; -static char *backspace = NULL; -static char *grp_toggle = 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(int utf8) { - shvarFile *keyboard = NULL; - char *tmp; - struct stat sb; - - - if (!stat("/etc/sysconfig/console/default.kmap",&sb)) { - keymap = "/etc/sysconfig/console/default.kmap"; - } - - if ((keyboard = svNewFile("/etc/sysconfig/keyboard")) == NULL) - return 0; - - tmp = svGetValue(keyboard, "BACKSPACE"); - if (tmp) - backspace = tmp; - - tmp = svGetValue(keyboard, "GRP_TOGGLE"); - if (tmp) - grp_toggle = tmp; - - if (keymap) - return 0; - - tmp = svGetValue(keyboard, "KEYMAP"); - if (tmp) - keymap = tmp; - - tmp = svGetValue(keyboard, "UNIKEYTABLE"); - if (tmp) - unikeytable = tmp; - - tmp = svGetValue(keyboard, "KEYTABLE"); - if (tmp) { - if (keymap) free(keymap); - keymap = NULL; - if (utf8) { - if (g_str_has_suffix (tmp, "uni") || strstr(tmp,".uni.")) - unikeytable = tmp; - else { - char * substring; - if ((substring = strstr(tmp, ".map"))) { - GString *new_string; - new_string = g_string_new_len (tmp, strlen(tmp)+4); - new_string = g_string_insert_len(new_string, substring-tmp,".uni",4); - unikeytable = g_string_free (new_string, FALSE); - } - else { - free (unikeytable); - asprintf (&unikeytable, "%s.uni", tmp); - } - } - - } - 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; - int status; - - if ((pid = fork()) == 0) { - char *args[] = { "/bin/loadkeys", "-q", NULL, NULL, NULL }; - dup2(fd, 0); - dup2(fd, 1); - - if (utf8) { - if (unikeytable) { - args[2] = unikeytable; - if (g_spawn_sync (NULL, args, NULL, G_SPAWN_CHILD_INHERITS_STDIN , NULL, NULL, NULL, NULL, NULL, NULL)) - exit(0); - } - - args[2] = "-u"; - args[3] = keymap; - } else { - args[2] = keymap; - } - execv("/bin/loadkeys", args); - exit(1); - } - waitpid(pid, &status, 0); -} - -static void set_backspace(int fd) { - int pid; - int status; - - if ((pid = fork()) == 0) { - char *args[] = { "/bin/loadkeys", "-q", NULL, NULL }; - dup2(fd, 0); - dup2(fd, 1); - - if (backspace && g_ascii_strcasecmp (backspace, "BackSpace")) { - args[2] = "backspace"; - } else { - args[2] = "delete"; - } - execv("/bin/loadkeys", args); - exit(1); - } - waitpid(pid, &status, 0); -} - -static void set_grp_toggle(int fd) { - int pid; - int status; - - if ((pid = fork()) == 0) { - char *args[] = { "/bin/loadkeys", "-q", NULL, NULL }; - dup2(fd, 0); - dup2(fd, 1); - - args[2] = grp_toggle; - execv("/bin/loadkeys", args); - exit(1); - } - waitpid(pid, &status, 0); -} - -int main(int argc, char **argv) { - char *device; - int dev; - struct stat sb; - - if (argc < 2) { - printf("usage: console_init <device>\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(utf8); - if (keymap || unikeytable) - set_keymap(dev,utf8); - set_backspace(dev); - if (grp_toggle) - set_grp_toggle(dev); - } - /* check if /usr is mounted */ - return stat("/usr/bin",&sb) != 0; -} 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/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 <mitr@redhat.com> -.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 <mitr@redhat.com> */ - -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -/* 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/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.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 <mitr@redhat.com> -.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 11496260..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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- * - * getkey
- *
- * A very simple keygrabber.
- *
- */
-#include <ctype.h>
-#include <errno.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-#include <sys/poll.h>
-#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);
- }
- }
-}
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 <ewt@redhat.com> 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 <errno.h> 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/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; 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 9ec8e7ef..00000000 --- a/src/securetty.c +++ /dev/null @@ -1,111 +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - * - */ - -#include <errno.h> -#include <fcntl.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <syslog.h> -#include <unistd.h> - -#include <sys/types.h> -#include <sys/stat.h> - -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; - 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)); - return 1; - } - write(fd, terminal, strlen(terminal)); - write(fd, "\n", 1); -out_ok: - close(fd); - return 0; -} - -int main(int argc, char **argv) { - if (argc < 2 ) { - fprintf(stderr, "Usage: securetty <device>\n"); - exit(1); - } - openlog("securetty", LOG_CONS, LOG_DAEMON); - return rewrite_securetty(argv[1]); -} 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/testd.c b/src/testd.c deleted file mode 100644 index b2a5c7e6..00000000 --- a/src/testd.c +++ /dev/null @@ -1,9 +0,0 @@ -#include <sys/signal.h> -#include <unistd.h> -#include <stdlib.h> - -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 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. * */ |