aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOlav Vitters <olav@vitters.nl>2020-07-26 21:46:44 +0200
committerOlav Vitters <olav@vitters.nl>2020-07-26 21:46:44 +0200
commit244c9a00ae9a0dc62156aeb8781c2b22da0ad96e (patch)
treec0d76ed490862837a8a37bb61ed8e653e5cc2558 /src
parentd0d18c6de12efeba25eb41d7cf207037027e4964 (diff)
parent6ca701a23c74b245f35750149a22f7d21805a8e0 (diff)
downloadinitscripts-244c9a00ae9a0dc62156aeb8781c2b22da0ad96e.tar
initscripts-244c9a00ae9a0dc62156aeb8781c2b22da0ad96e.tar.gz
initscripts-244c9a00ae9a0dc62156aeb8781c2b22da0ad96e.tar.bz2
initscripts-244c9a00ae9a0dc62156aeb8781c2b22da0ad96e.tar.xz
initscripts-244c9a00ae9a0dc62156aeb8781c2b22da0ad96e.zip
Merge tag '10.04' into distro/mga
10.04 release
Diffstat (limited to 'src')
-rw-r--r--src/.gitignore11
-rw-r--r--src/Makefile115
-rw-r--r--src/build/.gitkeep0
-rw-r--r--src/consoletype.144
-rw-r--r--src/consoletype.c5
-rw-r--r--src/genhostid.112
-rw-r--r--src/genhostid.c35
-rw-r--r--src/ifup.836
-rw-r--r--src/netreport.122
-rw-r--r--src/netreport.c72
-rw-r--r--src/rename_device.c5
-rw-r--r--src/shvar.c393
-rw-r--r--src/shvar.h103
-rwxr-xr-xsrc/sushell5
-rw-r--r--src/sushell.816
-rw-r--r--src/usernetctl.843
-rw-r--r--src/usernetctl.c5
-rw-r--r--src/usleep.130
-rw-r--r--src/usleep.c4
19 files changed, 104 insertions, 852 deletions
diff --git a/src/.gitignore b/src/.gitignore
index 01d63587..a007feab 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -1,10 +1 @@
-usernetctl
-netreport
-testd
-usleep
-ipcalc
-getkey
-ppp-watch
-consoletype
-genhostid
-rename_device
+build/*
diff --git a/src/Makefile b/src/Makefile
index d4df499b..8825e45b 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,54 +1,73 @@
-CFLAGS+=$(RPM_OPT_FLAGS) -Wall -D_GNU_SOURCE -fPIE
-LDFLAGS+=$(RPM_LD_FLAGS) -pie -z relro -z now
+# Basic Makefile for compiling & installing the files.
+#
+# Supports standard GNU Makefile variables for specifying the paths:
+# * prefix
+# * bindir
+# * sbindir
+# * libdir
+# * DESTDIR
+#
-PROGS=usernetctl netreport usleep \
- consoletype genhostid rename_device
-CONSOLE_INIT_OBJS=console_init.o shvar.o
-USLEEP_OBJS=usleep.o
+SHELL = /bin/bash
-mandir=/usr/share/man
+# Normally /usr/local is used. However, it does not make sense for us to use it
+# here, as it just complicates things even further.
+prefix = /usr
+bindir = $(prefix)/bin
+sbindir = $(prefix)/sbin
+libdir = $(prefix)/lib
-all: $(PROGS)
+CC = gcc
+CFLAGS += $(RPM_OPT_FLAGS) -Wall -D_GNU_SOURCE -fPIE
+LDFLAGS += $(RPM_LD_FLAGS) -pie -z relro -z now
+
+PROGS = consoletype genhostid rename_device usernetctl usleep
+
+all: $(PROGS)
+
+install: all
+ install -m 0755 -d $(DESTDIR)$(bindir)
+ install -m 0755 -d $(DESTDIR)$(sbindir)
+ install -m 0755 -d $(DESTDIR)$(libdir)/udev
+ install -m 0755 build/usleep $(DESTDIR)$(bindir)
+ install -m 0755 build/consoletype $(DESTDIR)$(sbindir)
+ install -m 0755 build/genhostid $(DESTDIR)$(sbindir)
+ install -m 0755 build/usernetctl $(DESTDIR)$(sbindir)
+ install -m 0755 build/rename_device $(DESTDIR)$(libdir)/udev
clean:
- rm -f $(PROGS) *.o *~
-
-install:
- mkdir -p $(ROOT)/usr/bin $(ROOT)/usr/sbin $(ROOT)$(mandir)/man{1,8} $(ROOT)/etc $(ROOT)/usr/lib/udev
- install -m 755 usleep $(ROOT)/usr/bin/usleep
- install -m 4755 usernetctl $(ROOT)/usr/sbin/usernetctl
- install -m 2755 netreport $(ROOT)/usr/sbin/netreport
- install -m 755 genhostid $(ROOT)/usr/sbin/genhostid
- install -m 755 consoletype $(ROOT)/usr/sbin/consoletype
- install -m 755 sushell $(ROOT)/usr/sbin/sushell
- install -m 755 rename_device $(ROOT)/usr/lib/udev/rename_device
- install -m 644 genhostid.1 $(ROOT)$(mandir)/man1
- install -m 644 netreport.1 $(ROOT)$(mandir)/man1
- install -m 644 usleep.1 $(ROOT)$(mandir)/man1
- install -m 644 usernetctl.8 $(ROOT)$(mandir)/man8
- install -m 644 consoletype.1 $(ROOT)$(mandir)/man1
- install -m 644 ifup.8 $(ROOT)$(mandir)/man8
- install -m 644 sushell.8 $(ROOT)$(mandir)/man8
- ln -s ifup.8 $(ROOT)$(mandir)/man8/ifdown.8
-
-usleep: $(USLEEP_OBJS)
- $(CC) $(LDFLAGS) -o $@ $(USLEEP_OBJS) -lpopt
-
-usernetctl.o: usernetctl.c
- $(CC) $(CFLAGS) -c usernetctl.c -o usernetctl.o
-
-usernetctl: usernetctl.c usernetctl.o
- $(CC) $(LDFLAGS) -o $@ $@.o
-
-netreport.o: netreport.c
- $(CC) $(CFLAGS) -c netreport.c -o netreport.o
-
-netreport: netreport.o
- $(CC) $(LDFLAGS) -o $@ $@.o
-
-shvar.o: shvar.c
- $(CC) $(CFLAGS) `pkg-config glib-2.0 --cflags` -c shvar.c -o shvar.o
-
-rename_device: rename_device.c
- $(CC) $(CFLAGS) `pkg-config glib-2.0 --cflags` -o $@ $< $(LDFLAGS) `pkg-config glib-2.0 --libs`
+ rm -f build/*
+
+consoletype: build/consoletype.o
+ $(CC) $(LDFLAGS) -o build/$@ $^
+
+build/consoletype.o: consoletype.c
+ $(CC) $(CFLAGS) -c -o $@ $^
+
+
+genhostid: build/genhostid.o
+ $(CC) $(LDFLAGS) -o build/$@ $^
+
+build/genhostid.o: genhostid.c
+ $(CC) $(CFLAGS) -c -o $@ $^
+
+
+rename_device: build/rename_device.o
+ $(CC) $(LDFLAGS) -o build/$@ $^ `pkg-config glib-2.0 --libs`
+
+build/rename_device.o: rename_device.c
+ $(CC) $(CFLAGS) -c -o $@ $^ `pkg-config glib-2.0 --cflags`
+
+
+usernetctl: build/usernetctl.o
+ $(CC) $(LDFLAGS) -o build/$@ $^
+
+build/usernetctl.o: usernetctl.c
+ $(CC) $(CFLAGS) -c -o $@ $^
+
+
+usleep: build/usleep.o
+ $(CC) $(LDFLAGS) -o build/$@ $^ -lpopt
+build/usleep.o: usleep.c
+ $(CC) $(CFLAGS) -c -o $@ $^
diff --git a/src/build/.gitkeep b/src/build/.gitkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/build/.gitkeep
diff --git a/src/consoletype.1 b/src/consoletype.1
deleted file mode 100644
index ebd1d88c..00000000
--- a/src/consoletype.1
+++ /dev/null
@@ -1,44 +0,0 @@
-.TH CONSOLETYPE 1 "Red Hat, Inc" "RH" \" -*- nroff -*-
-.SH NAME
-\fBconsoletype
-\- print type of the console connected to standard input
-.SH SYNOPSIS
-\fBconsoletype [\fIstdout\fR] [\fIfg\fR]
-.SH DESCRIPTION
-\fBconsoletype
-prints the type of console connected to standard input, and checks
-whether the console connected to standard input is the current
-foreground virtual console. With no arguments, it prints
-\fIvt\fR
-if console is a virtual terminal (/dev/tty* or /dev/console device if not on
-a serial console),
-\fIserial\fR
-if standard input is a serial console (/dev/console or /dev/ttyS*) and
-\fIpty\fR
-if standard input is a pseudo terminal.
-.SH RETURN VALUE
-\fBconsoletype
-when passed no arguments returns
-.TP
-\fI0
-if on virtual terminal
-.TP
-\fI1
-if on serial console
-.TP
-\fI2
-if on a pseudo terminal.
-.TP
-When passed the \fIstdout\fR argument, \fBconsoletype\fR returns
-.TP
-\fI0
-in all cases, and prints the console type to stdout.
-.TP
-When passed the \fIfg\fR argument, \fBconsoletype\fR returns
-.TP
-\fI0
-if the console connected to standard input is the current virtual
-terminal
-.TP
-\fI1
-otherwise.
diff --git a/src/consoletype.c b/src/consoletype.c
index 929969a4..dc3bd119 100644
--- a/src/consoletype.c
+++ b/src/consoletype.c
@@ -30,7 +30,10 @@ int main(int argc, char **argv)
char *type;
int maj, min, ret = 0, fg = -1;
struct stat sb;
-
+
+ fprintf(stderr, "warning: consoletype is now deprecated, and will be removed in the near future!\n"
+ "warning: use tty (1) instead! More info: 'man 1 tty'\n");
+
fstat(0, &sb);
maj = major(sb.st_rdev);
min = minor(sb.st_rdev);
diff --git a/src/genhostid.1 b/src/genhostid.1
deleted file mode 100644
index 436d9537..00000000
--- a/src/genhostid.1
+++ /dev/null
@@ -1,12 +0,0 @@
-.TH GENHOSTID 1
-.SH NAME
-genhostid \- generate and set a hostid for the current host
-.SH SYNOPSIS
-.B genhostid
-
-.SH DESCRIPTION
-\fBgenhostid\fR generates a random hostid and stores it in /etc/hostid,
-if /etc/hostid does not already exist.
-
-.SH "SEE ALSO"
-hostid(1), gethostid(2), sethostid(2)
diff --git a/src/genhostid.c b/src/genhostid.c
index c7561c9e..79dcb92e 100644
--- a/src/genhostid.c
+++ b/src/genhostid.c
@@ -12,7 +12,7 @@
* 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 <fcntl.h>
@@ -20,19 +20,32 @@
#include <time.h>
#include <unistd.h>
#include <sys/stat.h>
-int
-main (void)
+#include <stdio.h>
+
+int main (void)
{
struct stat st;
long int n;
- if (stat ("/etc/hostid", &st) == 0 && S_ISREG (st.st_mode)
- && st.st_size >= sizeof (n))
+
+ fprintf(stderr, "warning: genhostid is now deprecated, and will be removed in the near future!\n"
+ "warning: use systemd-machine-id-setup (1) instead! More info: 'man 5 machine-id'\n");
+
+ /*
+ * NOTE: gethostid() always returns 32-bit identifier, and st_size field
+ * of stat structure represents total size of file, in bytes.
+ */
+
+ if (stat ("/etc/hostid", &st) == 0 &&
+ S_ISREG (st.st_mode) && st.st_size == 4) {
return 0;
+ }
+
int fd = open ("/dev/random", O_RDONLY);
- if (fd == -1 || read (fd, &n, sizeof (n)) != sizeof (n))
- {
- srand48 ((long int) time (NULL) ^ (long int) getpid ());
- n = lrand48 ();
- }
- return sethostid ((int32_t)n);
+
+ if (fd == -1 || read (fd, &n, sizeof (n)) != sizeof (n)) {
+ srand48 ((long int) time (NULL) ^ (long int) getpid ());
+ n = lrand48 ();
+ }
+
+ return sethostid ((int32_t) n);
}
diff --git a/src/ifup.8 b/src/ifup.8
deleted file mode 100644
index 1cf1fcd8..00000000
--- a/src/ifup.8
+++ /dev/null
@@ -1,36 +0,0 @@
-.\" Copyright 2009 Petr Lautrbach (plautrba@redhat.com)
-.TH ifup 8 2009-10-27 "" "System Administration tools and Daemons"
-.SH NAME
-ifup - bring a network interface up
-
-ifdown - take a network interface down
-.SH SYNOPSIS
-.B ifup CONFIG [boot]
-
-.B ifdown CONFIG
-
-.SH DESCRIPTION
-The
-.B ifup
-and
-.B ifdown
-commands may be used to configure (or, respec-
-tively, deconfigure) network interfaces based on interface definitions
-in the files /etc/sysconfig/network and /etc/sysconfig/network-scripts/ifcfg-<configuration>
-
-These scripts take one argument normally: the name of the configuration
-(e.g. eth0). They are called with a second argument of "boot"
-during the boot sequence so that devices that are not meant to
-be brought up on boot (ONBOOT=no, see below) can be ignored at
-that time.
-
-.SH FILES
-.TP
-\fB/etc/sysconfig/network\fR
-
-.TP
-\fB/etc/sysconfig/network-scripts/ifcfg-<configuration>\fR
-The file defining an interface.
-
-.SH "SEE ALSO"
-/usr/share/doc/initscripts-*/sysconfig.txt
diff --git a/src/netreport.1 b/src/netreport.1
deleted file mode 100644
index 75ed0747..00000000
--- a/src/netreport.1
+++ /dev/null
@@ -1,22 +0,0 @@
-.TH NETREPORT 1 "Red Hat, Inc." "RH" \" -*- nroff -*-
-.SH NAME
-netreport \- request notification of network interface changes
-.SH SYNOPSIS
-.B netreport
-\fI[\fP-r\fI]\fP
-.SH DESCRIPTION
-.B netreport
-tells the network management scripts to send a SIGIO signal
-to the process which called netreport when any network interface
-status changes occur.
-.SH OPTIONS
-.TP
-.B -r
-Remove the current request (if any) for the calling process.
-.PP
-.SH NOTES
-If a program does not call netreport with the
-.B -r
-option before it exits, and another process is created with the
-same PID before any changes take place in interface status, it
-is possible that the new process will receive a spurious SIGIO.
diff --git a/src/netreport.c b/src/netreport.c
deleted file mode 100644
index 204a77d7..00000000
--- a/src/netreport.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 1997-2002 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 <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-/* this will be running setgid root, so be careful! */
-
-static void
-usage(void) {
- fprintf(stderr, "usage: netreport [-r]\n");
- exit(1);
-}
-
-#define ADD 1
-#define DEL 0
-int main(int argc, char ** argv) {
- int action = ADD;
- /* more than long enough for "/run/netreport/<pid>\0" */
- char netreport_name[64];
- int netreport_file;
-
- if (argc > 2) {
- usage();
- }
-
- if (argc > 1) {
- if (argc == 2 && strcmp(argv[1], "-r") == 0) {
- action = DEL;
- } else {
- usage();
- }
- }
-
- snprintf(netreport_name, sizeof(netreport_name),
- "/run/netreport/%d", getppid());
- if (action == ADD) {
- netreport_file = open(netreport_name,
- O_EXCL|O_CREAT|O_WRONLY|O_TRUNC|O_NOFOLLOW, 0);
- if (netreport_file == -1) {
- if (errno != EEXIST) {
- perror("Could not create netreport file");
- exit (1);
- }
- } else {
- close(netreport_file);
- }
- } else {
- /* ignore errors; not much we can do, won't hurt anything */
- unlink(netreport_name);
- }
-
- return 0;
-}
diff --git a/src/rename_device.c b/src/rename_device.c
index 6d6030eb..c39f447d 100644
--- a/src/rename_device.c
+++ b/src/rename_device.c
@@ -281,6 +281,7 @@ char *get_config_by_hwaddr(char *hwaddr, char *current) {
void take_lock() {
int count = 0;
int lockfd;
+ ssize_t ignored_retval __attribute__((unused));
while (1) {
lockfd = open(LOCKFILE, O_RDWR|O_CREAT|O_EXCL, 0644);
@@ -288,7 +289,7 @@ void take_lock() {
char buf[32];
snprintf(buf,32,"%d\n",getpid());
- write(lockfd,buf,strlen(buf));
+ ignored_retval = write(lockfd,buf,strlen(buf));
close(lockfd);
break;
} else if (errno == EACCES)
@@ -304,7 +305,7 @@ void take_lock() {
fd = open(LOCKFILE, O_RDONLY);
if (fd == -1)
break;
- read(fd,buf,32);
+ ignored_retval = read(fd,buf,32);
close(fd);
pid = atoi(buf);
if (pid && pid != 1) {
diff --git a/src/shvar.c b/src/shvar.c
deleted file mode 100644
index 9817d9a4..00000000
--- a/src/shvar.c
+++ /dev/null
@@ -1,393 +0,0 @@
-/*
- * shvar.c
- *
- * Implementation of non-destructively reading/writing files containing
- * only shell variable declarations and full-line comments.
- *
- * Includes explicit inheritance mechanism intended for use with
- * Red Hat Linux ifcfg-* files. There is no protection against
- * inheritance loops; they will generally cause stack overflows.
- * Furthermore, they are only intended for one level of inheritance;
- * the value setting algorithm assumes this.
- *
- * Copyright 1999,2000 Red Hat, Inc.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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 <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-#include "shvar.h"
-
-/* Open the file <name>, returning a shvarFile on success and NULL on failure.
- Add a wrinkle to let the caller specify whether or not to create the file
- (actually, return a structure anyway) if it doesn't exist. */
-static shvarFile *
-svOpenFile(const char *name, gboolean create)
-{
- shvarFile *s = NULL;
- int closefd = 0;
-
- s = g_malloc0(sizeof(shvarFile));
-
- s->fd = open(name, O_RDWR); /* NOT O_CREAT */
- if (s->fd == -1) {
- /* try read-only */
- s->fd = open(name, O_RDONLY); /* NOT O_CREAT */
- if (s->fd != -1) closefd = 1;
- }
- s->fileName = g_strdup(name);
-
- if (s->fd != -1) {
- struct stat buf;
- char *p, *q;
-
- if (fstat(s->fd, &buf) < 0) goto bail;
- s->arena = g_malloc0(buf.st_size + 1);
-
- if (read(s->fd, s->arena, buf.st_size) < 0) goto bail;
-
- /* we'd use g_strsplit() here, but we want a list, not an array */
- for(p = s->arena; (q = strchr(p, '\n')) != NULL; p = q + 1) {
- s->lineList = g_list_append(s->lineList, g_strndup(p, q - p));
- }
-
- /* closefd is set if we opened the file read-only, so go ahead and
- close it, because we can't write to it anyway */
- if (closefd) {
- close(s->fd);
- s->fd = -1;
- }
-
- return s;
- }
-
- if (create) {
- return s;
- }
-
-bail:
- if (s->fd != -1) close(s->fd);
- if (s->arena) g_free (s->arena);
- if (s->fileName) g_free (s->fileName);
- g_free (s);
- return NULL;
-}
-
-/* Open the file <name>, return shvarFile on success, NULL on failure */
-shvarFile *
-svNewFile(const char *name)
-{
- return svOpenFile(name, FALSE);
-}
-
-/* Create a new file structure, returning actual data if the file exists,
- * and a suitable starting point if it doesn't. */
-shvarFile *
-svCreateFile(const char *name)
-{
- return svOpenFile(name, TRUE);
-}
-
-/* remove escaped characters in place */
-static void
-unescape(char *s) {
- int len, i;
-
- len = strlen(s);
- if ((s[0] == '"' || s[0] == '\'') && s[0] == s[len-1]) {
- i = len - 2;
- memmove(s, s+1, i);
- s[i+1] = '\0';
- len = i;
- }
- for (i = 0; i < len; i++) {
- if (s[i] == '\\') {
- memmove(s+i, s+i+1, len-(i+1));
- len--;
- }
- s[len] = '\0';
- }
-}
-
-
-/* create a new string with all necessary characters escaped.
- * caller must free returned string
- */
-static const char escapees[] = "\"'\\$~`"; /* must be escaped */
-static const char spaces[] = " \t|&;()<>"; /* only require "" */
-static char *
-escape(const char *s) {
- char *new;
- int i, j, mangle = 0, space = 0;
- int newlen, slen;
- static int esclen, splen;
-
- if (!esclen) esclen = strlen(escapees);
- if (!splen) splen = strlen(spaces);
- slen = strlen(s);
-
- for (i = 0; i < slen; i++) {
- if (strchr(escapees, s[i])) mangle++;
- if (strchr(spaces, s[i])) space++;
- }
- if (!mangle && !space) return strdup(s);
-
- newlen = slen + mangle + 3; /* 3 is extra ""\0 */
- new = g_malloc0(newlen);
- if (!new) return NULL;
-
- j = 0;
- new[j++] = '"';
- for (i = 0; i < slen; i++) {
- if (strchr(escapees, s[i])) {
- new[j++] = '\\';
- }
- new[j++] = s[i];
- }
- new[j++] = '"';
- g_assert(j == slen + mangle + 2); /* j is the index of the '\0' */
-
- return new;
-}
-
-/* Get the value associated with the key, and leave the current pointer
- * pointing at the line containing the value. The char* returned MUST
- * be freed by the caller.
- */
-char *
-svGetValue(shvarFile *s, const char *key)
-{
- char *value = NULL;
- char *line;
- char *keyString;
- int len;
-
- g_assert(s);
- g_assert(key);
-
- keyString = g_malloc0(strlen(key) + 2);
- strcpy(keyString, key);
- keyString[strlen(key)] = '=';
- len = strlen(keyString);
-
- for (s->current = s->lineList; s->current; s->current = s->current->next) {
- line = s->current->data;
- if (!strncmp(keyString, line, len)) {
- value = g_strdup(line + len);
- unescape(value);
- break;
- }
- }
- g_free(keyString);
-
- if (value) {
- if (value[0]) {
- return value;
- } else {
- g_free(value);
- return NULL;
- }
- }
- if (s->parent) value = svGetValue(s->parent, key);
- return value;
-}
-
-/* return 1 if <key> resolves to any truth value (e.g. "yes", "y", "true")
- * return 0 if <key> resolves to any non-truth value (e.g. "no", "n", "false")
- * return <default> otherwise
- */
-int
-svTrueValue(shvarFile *s, const char *key, int def)
-{
- char *tmp;
- int returnValue = def;
-
- tmp = svGetValue(s, key);
- if (!tmp) return returnValue;
-
- if ( (!strcasecmp("yes", tmp)) ||
- (!strcasecmp("true", tmp)) ||
- (!strcasecmp("t", tmp)) ||
- (!strcasecmp("y", tmp)) ) returnValue = 1;
- else
- if ( (!strcasecmp("no", tmp)) ||
- (!strcasecmp("false", tmp)) ||
- (!strcasecmp("f", tmp)) ||
- (!strcasecmp("n", tmp)) ) returnValue = 0;
-
- g_free (tmp);
- return returnValue;
-}
-
-
-/* Set the variable <key> equal to the value <value>.
- * If <key> does not exist, and the <current> pointer is set, append
- * the key=value pair after that line. Otherwise, prepend the pair
- * to the top of the file. Here's the algorithm, as the C code
- * seems to be rather dense:
- *
- * if (value == NULL), then:
- * if val2 (parent): change line to key= or append line key=
- * if val1 (this) : delete line
- * else noop
- * else use this table:
- * val2
- * NULL value other
- * v NULL append line noop append line
- * a
- * l value noop noop noop
- * 1
- * other change line delete line change line
- *
- * No changes are ever made to the parent config file, only to the
- * specific file passed on the command line.
- *
- */
-void
-svSetValue(shvarFile *s, const char *key, const char *value)
-{
- char *newval = NULL, *val1 = NULL, *val2 = NULL;
- char *keyValue;
-
- g_assert(s);
- g_assert(key);
- /* value may be NULL */
-
- if (value) newval = escape(value);
- keyValue = g_strdup_printf("%s=%s", key, newval ? newval : "");
-
- val1 = svGetValue(s, key);
- if (val1 && newval && !strcmp(val1, newval)) goto bail;
- if (s->parent) val2 = svGetValue(s->parent, key);
-
- if (!newval || !newval[0]) {
- /* delete value somehow */
- if (val2) {
- /* change/append line to get key= */
- if (s->current) s->current->data = keyValue;
- else s->lineList = g_list_append(s->lineList, keyValue);
- s->freeList = g_list_append(s->freeList, keyValue);
- s->modified = 1;
- } else if (val1) {
- /* delete line */
- s->lineList = g_list_remove_link(s->lineList, s->current);
- g_list_free_1(s->current);
- s->modified = 1;
- goto bail; /* do not need keyValue */
- }
- goto end;
- }
-
- if (!val1) {
- if (val2 && !strcmp(val2, newval)) goto end;
- /* append line */
- s->lineList = g_list_append(s->lineList, keyValue);
- s->freeList = g_list_append(s->freeList, keyValue);
- s->modified = 1;
- goto end;
- }
-
- /* deal with a whole line of noops */
- if (val1 && !strcmp(val1, newval)) goto end;
-
- /* At this point, val1 && val1 != value */
- if (val2 && !strcmp(val2, newval)) {
- /* delete line */
- s->lineList = g_list_remove_link(s->lineList, s->current);
- g_list_free_1(s->current);
- s->modified = 1;
- goto bail; /* do not need keyValue */
- } else {
- /* change line */
- if (s->current) s->current->data = keyValue;
- else s->lineList = g_list_append(s->lineList, keyValue);
- s->freeList = g_list_append(s->freeList, keyValue);
- s->modified = 1;
- }
-
-end:
- if (newval) free(newval);
- if (val1) free(val1);
- if (val2) free(val2);
- return;
-
-bail:
- if (keyValue) free (keyValue);
- goto end;
-}
-
-/* Write the current contents iff modified. Returns -1 on error
- * and 0 on success. Do not write if no values have been modified.
- * The mode argument is only used if creating the file, not if
- * re-writing an existing file, and is passed unchanged to the
- * open() syscall.
- */
-int
-svWriteFile(shvarFile *s, int mode)
-{
- FILE *f;
- int tmpfd;
-
- if (s->modified) {
- if (s->fd == -1)
- s->fd = open(s->fileName, O_WRONLY|O_CREAT, mode);
- if (s->fd == -1)
- return -1;
- if (ftruncate(s->fd, 0) < 0)
- return -1;
-
- tmpfd = dup(s->fd);
- f = fdopen(tmpfd, "w");
- fseek(f, 0, SEEK_SET);
- for (s->current = s->lineList; s->current; s->current = s->current->next) {
- char *line = s->current->data;
- fprintf(f, "%s\n", line);
- }
- fclose(f);
- }
-
- return 0;
-}
-
-
-/* Close the file descriptor (if open) and delete the shvarFile.
- * Returns -1 on error and 0 on success.
- */
-int
-svCloseFile(shvarFile *s)
-{
-
- g_assert(s);
-
- if (s->fd != -1) close(s->fd);
-
- g_free(s->arena);
- for (s->current = s->freeList; s->current; s->current = s->current->next) {
- g_free(s->current->data);
- }
- g_free(s->fileName);
- g_list_free(s->freeList);
- g_list_free(s->lineList); /* implicitly frees s->current */
- g_free(s);
- return 0;
-}
diff --git a/src/shvar.h b/src/shvar.h
deleted file mode 100644
index 46fb6b7b..00000000
--- a/src/shvar.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * shvar.h
- *
- * Interface for non-destructively reading/writing files containing
- * only shell variable declarations and full-line comments.
- *
- * Includes explicit inheritance mechanism intended for use with
- * Red Hat Linux ifcfg-* files. There is no protection against
- * inheritance loops; they will generally cause stack overflows.
- * Furthermore, they are only intended for one level of inheritance;
- * the value setting algorithm assumes this.
- *
- * Copyright 1999 Red Hat, Inc.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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.
- *
- */
-#ifndef _SHVAR_H
-#define _SHVAR_H
-
-#include <glib.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-typedef struct _shvarFile shvarFile;
-struct _shvarFile {
- char *fileName; /* read-only */
- int fd; /* read-only */
- char *arena; /* ignore */
- GList *lineList; /* read-only */
- GList *freeList; /* ignore */
- GList *current; /* set implicitly or explicitly,
- points to element of lineList */
- shvarFile *parent; /* set explicitly */
- int modified; /* ignore */
-};
-
-
-/* Create the file <name>, return shvarFile on success, NULL on failure */
-shvarFile *
-svCreateFile(const char *name);
-
-/* Open the file <name>, return shvarFile on success, NULL on failure */
-shvarFile *
-svNewFile(const char *name);
-
-/* Get the value associated with the key, and leave the current pointer
- * pointing at the line containing the value. The char* returned MUST
- * be freed by the caller.
- */
-char *
-svGetValue(shvarFile *s, const char *key);
-
-/* return 1 if <key> resolves to any truth value (e.g. "yes", "y", "true")
- * return 0 if <key> resolves to any non-truth value (e.g. "no", "n", "false")
- * return <def> otherwise
- */
-int
-svTrueValue(shvarFile *s, const char *key, int def);
-
-/* Set the variable <key> equal to the value <value>.
- * If <key> does not exist, and the <current> pointer is set, append
- * the key=value pair after that line. Otherwise, prepend the pair
- * to the top of the file.
- */
-void
-svSetValue(shvarFile *s, const char *key, const char *value);
-
-
-/* Write the current contents iff modified. Returns -1 on error
- * and 0 on success. Do not write if no values have been modified.
- * The mode argument is only used if creating the file, not if
- * re-writing an existing file, and is passed unchanged to the
- * open() syscall.
- */
-int
-svWriteFile(shvarFile *s, int mode);
-
-/* Close the file descriptor (if open) and delete the shvarFile.
- * Returns -1 on error and 0 on success.
- */
-int
-svCloseFile(shvarFile *s);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* ! _SHVAR_H */
diff --git a/src/sushell b/src/sushell
deleted file mode 100755
index 7d969416..00000000
--- a/src/sushell
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-[ -z "$SUSHELL" ] && SUSHELL=/bin/bash
-
-exec $SUSHELL
diff --git a/src/sushell.8 b/src/sushell.8
deleted file mode 100644
index 9832a732..00000000
--- a/src/sushell.8
+++ /dev/null
@@ -1,16 +0,0 @@
-.TH SUSHELL 8 "Red Hat, Inc" \" -*- nroff -*-
-.SH NAME
-sushell \- execute the single-user shell
-.SH SYNOPSIS
-.B sushell
-.SH DESCRIPTION
-.B sushell
-executes the single-user shell. By default, this is
-\fI/bin/bash\fP
-This can be configured via the
-.B SUSHELL
-environment variable.
-.SH NOTES
-.B sushell
-is an implementation detail, required for proper SELinux
-usage. It is not intended to be run regularly.
diff --git a/src/usernetctl.8 b/src/usernetctl.8
deleted file mode 100644
index ebf86e1a..00000000
--- a/src/usernetctl.8
+++ /dev/null
@@ -1,43 +0,0 @@
-.TH USERNETCTL 8 "Red Hat, Inc." "RHS" \" -*- nroff -*-
-.SH NAME
-usernetctl \- allow a user to manipulate a network interface if permitted
-.SH SYNOPSIS
-.B usernetctl
-\fIinterface-name\fP up\fI|\fPdown\fI|\fPreport
-.SH DESCRIPTION
-.B usernetctl
-checks to see if users are allowed to manipulate the network interface
-specified by \fIinterface-name\fP, and then tries to bring the network
-interface up or down, if up or down was specified on the command line,
-or returns true or false status (respectively) if the report option was
-specified.
-
-.B usernetctl
-is not really meant to be called directly by users, though it currently
-works fine that way. It is used as a wrapper by the ifup and ifdown
-scripts, so that users can do exactly the same thing as root:
-.nf
-ifup \fIinterface-name\fP
-ifdown \fIinterface-name\fP
-.fi
-and \fBifup\fP and \fBifdown\fP will call usernetctl automatically to
-allow the interface status change.
-.SH OPTIONS
-.TP
-.I "\fIinterface-name"
-The name of the network interface to check; for example, "ppp0". For
-backwards compatibility, "ifcfg-ppp0" and
-"/etc/sysconfig/network-scripts/ifcfg-ppp0" are also supported.
-.TP
-up\fI|\fPdown
-Attempt to bring the interface up or down.
-.TP
-report
-Report on whether users can bring the interface up or down.
-
-.SH FILES
-.IR /etc/sysconfig/network-scripts/ifcfg-*
-
-.SH NOTES
-Alternate device configurations may inherit the default configuration's
-permissions.
diff --git a/src/usernetctl.c b/src/usernetctl.c
index 9e127604..d966dc71 100644
--- a/src/usernetctl.c
+++ b/src/usernetctl.c
@@ -155,6 +155,7 @@ main(int argc, char ** argv) {
char * cmd = NULL;
int report = 0;
char tmp;
+ int ignored_retval __attribute__((unused));
if (argc != 3) usage();
@@ -235,9 +236,9 @@ main(int argc, char ** argv) {
/* pppd wants the real uid to be the same as the effective (god only
knows why when it works fine setuid out of the box) */
- setuid(geteuid());
+ ignored_retval = setuid(geteuid());
/* Drop user gid (for temp files, SELinux) */
- setgid(0);
+ ignored_retval = setgid(0);
execle(cmd, cmd, ifaceConfig, NULL, safeEnviron);
fprintf(stderr, "exec of %s failed: %s\n", cmd, strerror(errno));
diff --git a/src/usleep.1 b/src/usleep.1
deleted file mode 100644
index 30db2bad..00000000
--- a/src/usleep.1
+++ /dev/null
@@ -1,30 +0,0 @@
-.TH USLEEP 1 "Red Hat, Inc" \" -*- nroff -*-
-.SH NAME
-usleep \- sleep some number of microseconds
-.SH SYNOPSIS
-.B usleep
-[\fInumber\fP]
-.SH DESCRIPTION
-.B usleep
-sleeps some number of microseconds. The default is 1.
-.SH WARNING
-.B usleep
-has been deprecated, and will be removed in near future. Use sleep(1) instead.
-.SH OPTIONS
-\fI--usage\fP
-Show short usage message.
-.TP
-\fI--help, -?\fP
-Print help information.
-.TP
-\fI-v, --version\fP
-Print version information.
-.SH BUGS
-Probably not accurate on many machines down to the microsecond. Count
-on precision only to -4 or maybe -5.
-.SH AUTHOR
-Donald Barnes <djb@redhat.com>
-.br
-Erik Troan <ewt@redhat.com>
-.SH SEE ALSO
-sleep(1)
diff --git a/src/usleep.c b/src/usleep.c
index e5e3077d..58ab2d79 100644
--- a/src/usleep.c
+++ b/src/usleep.c
@@ -28,13 +28,13 @@
#include "popt.h"
-int main(int argc, char **argv) {
+int main(const int argc, const char **argv) {
unsigned long count;
poptContext optCon;
int showVersion = 0;
int showOot = 0;
int rc;
- char * countStr = NULL;
+ const char * countStr = NULL;
struct poptOption options[] = {
{ "version", 'v', POPT_ARG_NONE, &showVersion, 0,
"Display the version of this program, and exit" },