aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael K. Johnson <johnsonm@redhat.com>1997-09-30 23:53:29 +0000
committerMichael K. Johnson <johnsonm@redhat.com>1997-09-30 23:53:29 +0000
commitd698eaf561087d2375a2a6cad79100669a387bc7 (patch)
tree186a5a94c9488f1f2d484a63b1993984107aa140 /src
parent3bc8f95b0064a0e1990e95e272b453deb3dff78c (diff)
downloadinitscripts-d698eaf561087d2375a2a6cad79100669a387bc7.tar
initscripts-d698eaf561087d2375a2a6cad79100669a387bc7.tar.gz
initscripts-d698eaf561087d2375a2a6cad79100669a387bc7.tar.bz2
initscripts-d698eaf561087d2375a2a6cad79100669a387bc7.tar.xz
initscripts-d698eaf561087d2375a2a6cad79100669a387bc7.zip
Added report option for usernet.
Diffstat (limited to 'src')
-rw-r--r--src/usernetctl.117
-rw-r--r--src/usernetctl.c15
2 files changed, 24 insertions, 8 deletions
diff --git a/src/usernetctl.1 b/src/usernetctl.1
index 27287b68..ff3ca593 100644
--- a/src/usernetctl.1
+++ b/src/usernetctl.1
@@ -3,19 +3,26 @@
usernetctl \- allow a user to manipulate a network interface if permitted
.SH SYNOPSIS
.B usernetctl
-\fIconfig-file-name\fP up\fI|\fPdown
+\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 \fIconfig-file-name\fP, and then tries to bring the network
-interface up or down, as specified.
+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.
.SH OPTIONS
.TP
-.I "\fIconfig-file-name"
-The name of the network configuration file to read; for example, ifcfg-ppp0
+.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 NOTES
Alternate device configurations may inherit the default configuration's
permissions.
diff --git a/src/usernetctl.c b/src/usernetctl.c
index f642f332..ece0544b 100644
--- a/src/usernetctl.c
+++ b/src/usernetctl.c
@@ -11,7 +11,7 @@
/* this will be running setuid root, so be careful! */
void usage(void) {
- fprintf(stderr, "usage: usernetctl <interface-config> <up|down>\n");
+ fprintf(stderr, "usage: usernetctl <interface-config> <up|down|report>\n");
exit(1);
}
@@ -106,6 +106,7 @@ int main(int argc, char ** argv) {
char * ifaceConfig;
char * chptr;
char * cmd;
+ int report = 0;
if (argc != 3) usage();
@@ -113,6 +114,8 @@ int main(int argc, char ** argv) {
cmd = "./ifup";
} else if (!strcmp(argv[2], "down")) {
cmd = "./ifdown";
+ } else if (!strcmp(argv[2], "report")) {
+ report = 1;
} else {
usage();
}
@@ -157,12 +160,18 @@ int main(int argc, char ** argv) {
}
/* else fall through */
case FOUND_FALSE:
- fprintf(stderr, "Users are not allowed to control this interface.\n");
+ if (! report)
+ fprintf(stderr,
+ "Users are not allowed to control this interface.\n");
exit(1);
break;
}
- /* looks good to me -- let's go for it */
+ /* looks good to me -- let's go for it if we are changing the interface,
+ * report good status to the user otherwise */
+
+ if (report)
+ exit(0);
/* 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) */