aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2015-11-19 15:03:47 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2015-11-19 15:06:33 +0200
commit0a3f8aae4a41c4aa8435214e235af509cd5f4435 (patch)
tree6b5e73c8ab74121123584dd2c62b80931d23a636
parentbedc4dc0057f4d713a4186e79d812f5e9552cfc2 (diff)
downloadeclat-0a3f8aae4a41c4aa8435214e235af509cd5f4435.tar.gz
eclat-0a3f8aae4a41c4aa8435214e235af509cd5f4435.tar.bz2
Add operations on egress rules for VPC security groups.
* src/sg-cl.opt: New options: --input (--ingress, -I), and --output (--egress, -O). * src/sg.c (command): const. * doc/eclat-sg.1: Document --input/--output modifiers. * TODO: Likewise. * etc/sg.fln: Add support for egress responses.
-rw-r--r--TODO4
-rw-r--r--doc/eclat-sg.135
-rw-r--r--etc/sg.fln10
-rw-r--r--src/sg-cl.opt32
-rw-r--r--src/sg.c2
5 files changed, 74 insertions, 9 deletions
diff --git a/TODO b/TODO
index 1a1686b..4fa62d9 100644
--- a/TODO
+++ b/TODO
@@ -17,7 +17,7 @@ AttachInternetGateway atigw [X] [ ]
17AttachNetworkInterface - [ ] [ ] 17AttachNetworkInterface - [ ] [ ]
18AttachVolume atvol [X] [X] 18AttachVolume atvol [X] [X]
19AttachVpnGateway - [ ] [ ] 19AttachVpnGateway - [ ] [ ]
20AuthorizeSecurityGroupEgress - [ ] [ ] 20AuthorizeSecurityGroupEgress sg [X] [X]
21AuthorizeSecurityGroupIngress sg [X] [X] 21AuthorizeSecurityGroupIngress sg [X] [X]
22BundleInstance - [ ] [ ] 22BundleInstance - [ ] [ ]
23CancelBundleTask - [ ] [ ] 23CancelBundleTask - [ ] [ ]
@@ -146,7 +146,7 @@ ResetImageAttribute - [ ] [ ]
146ResetInstanceAttribute - [ ] [ ] 146ResetInstanceAttribute - [ ] [ ]
147ResetNetworkInterfaceAttribute - [ ] [ ] 147ResetNetworkInterfaceAttribute - [ ] [ ]
148ResetSnapshotAttribute clrsattr [X] [X] 148ResetSnapshotAttribute clrsattr [X] [X]
149RevokeSecurityGroupEgress - [ ] [ ] 149RevokeSecurityGroupEgress sg [X] [X]
150RevokeSecurityGroupIngress sg [X] [X] 150RevokeSecurityGroupIngress sg [X] [X]
151RunInstances mkinst [X] [X] 151RunInstances mkinst [X] [X]
152StartInstances start [X] [X] 152StartInstances start [X] [X]
diff --git a/doc/eclat-sg.1 b/doc/eclat-sg.1
index 06a51cd..d60639b 100644
--- a/doc/eclat-sg.1
+++ b/doc/eclat-sg.1
@@ -13,13 +13,15 @@
13.\" 13.\"
14.\" You should have received a copy of the GNU General Public License 14.\" You should have received a copy of the GNU General Public License
15.\" along with Eclat. If not, see <http://www.gnu.org/licenses/>. 15.\" along with Eclat. If not, see <http://www.gnu.org/licenses/>.
16.TH ECLAT-SG 1 "January 26, 2015" "ECLAT" "Eclat User Reference" 16.TH ECLAT-SG 1 "November 19, 2015" "ECLAT" "Eclat User Reference"
17.SH NAME 17.SH NAME
18eclat-sg \- manipulate security groups 18eclat-sg \- manipulate security groups
19.SH SYNOPSIS 19.SH SYNOPSIS
20.nh 20.nh
21.na 21.na
22\fBeclat sg\fR \fB\-A\fR|\fB\-D\fR|\fB\-\-add\fR|\fB\-\-delete\fR [\fB\-Nn\fR]\ 22\fBeclat sg\fR\
23 [\fB\-\-input\fR|\fB\-\-ingress\fR|\fB\-I\fR|\fB\-\-output\fR|\fB\-\-egress\fR|\fB\-O\fR]\
24 \fB\-A\fR|\fB\-D\fR|\fB\-\-add\fR|\fB\-\-delete\fR [\fB\-Nn\fR]\
23 [\fB\-G\fR \fINAME\fR] [\fB\-P\fR \fIPORT\fR[\fB\-\fIPORT\fR]]\ 25 [\fB\-G\fR \fINAME\fR] [\fB\-P\fR \fIPORT\fR[\fB\-\fIPORT\fR]]\
24 [\fB\-g\fR \fIID\fR] [\fB\-p\fR \fIPROTO\fR] [\fB\-s\fR \fICIDR\fR]\ 26 [\fB\-g\fR \fIID\fR] [\fB\-p\fR \fIPROTO\fR] [\fB\-s\fR \fICIDR\fR]\
25 [\fB\-u\fR \fIUSER\fR] [\fB\-\-group\-id\fR=\fIID\fR]\ 27 [\fB\-u\fR \fIUSER\fR] [\fB\-\-group\-id\fR=\fIID\fR]\
@@ -48,8 +50,8 @@ either the group ID, or group name. In the latter case, the
48\fB\-\-name\fR (\fB\-n\fR) option should be given. 50\fB\-\-name\fR (\fB\-n\fR) option should be given.
49.PP 51.PP
50When used with \fB\-\-add\fR (\fB\-A\fR) option, the command adds the 52When used with \fB\-\-add\fR (\fB\-A\fR) option, the command adds the
51rules to the security groups. The rules are described using the command 53rules to the security groups. The rules to add are
52line options. For example: 54described by the command line options that follow. For example:
53.PP 55.PP
54.EX 56.EX
55.B eclat sg --add --proto tcp --port 22 --source 192.0.2.0/24 sg-01234567 57.B eclat sg --add --proto tcp --port 22 --source 192.0.2.0/24 sg-01234567
@@ -72,7 +74,32 @@ Several rules can be added in one invocation. The \fB\-\-next\fR
72.PP 74.PP
73The \fB\-\-delete\fR (\fB\-D\fR) option deletes existing rules, which 75The \fB\-\-delete\fR (\fB\-D\fR) option deletes existing rules, which
74are defined using the same syntax as described above. 76are defined using the same syntax as described above.
77.PP
78By default, both \fB\-\-add\fR and \fB\-\-delete\fR operate on ingress
79rules. This can be changed by placing the \fB\-\-output\fR
80(\fB\-O\fR) option before them. The \fB\-\-output\fR option remains
81in effect for all options that follow it. The \fB\-\-input option
82cancels its effect.
83.PP
84The \fB\-\-list\fR (\fB\-L\fR) option instructs the program to list
85rules in the named security group. If no group is specified, all
86existing groups will be listed.
75.SH OPTIONS 87.SH OPTIONS
88.SS Modifiers
89.TP
90\fB\-\-input\fR, \fB\-\-ingress\fR, \fB\-I\fR
91Operate on the ingress rules.
92.TP
93\fB\-\-output\fR, \fB\-\-egress\fR, \fB\-O\fR
94Operate on the egress rules.
95.PP
96These modifiers apply to all \fB\-\-add\fR and \fB\-\-delete\fR
97options that follow them, until another modifier or end of line is
98encountered.
99.PP
100By default, \fB\-\-input\fR is assumed.
101.PP
102The \fB\-\-output\fR modifier is valid only for EC2-VPC.
76.SS Commands 103.SS Commands
77These options define the operation to be performed over the security 104These options define the operation to be performed over the security
78group. A valid invocation of the \fBsg\fR subcommand must contain 105group. A valid invocation of the \fBsg\fR subcommand must contain
diff --git a/etc/sg.fln b/etc/sg.fln
index 7050c3a..10dac18 100644
--- a/etc/sg.fln
+++ b/etc/sg.fln
@@ -24,5 +24,15 @@ if (.AuthorizeSecurityGroupIngressResponse.return) {
24 error("Return: ",.RevokeSecurityGroupIngressResponse.return,"\n"); 24 error("Return: ",.RevokeSecurityGroupIngressResponse.return,"\n");
25 exit(1); 25 exit(1);
26 } 26 }
27} else if (.AuthorizeSecurityGroupEgressResponse.return) {
28 if (!.AuthorizeSecurityGroupEgressResponse.return[true]) {
29 error("Return: ",.AuthorizeSecurityGroupEressResponse.return,"\n");
30 exit(1);
31 }
32} else if (.RevokeSecurityGroupEgressResponse.return) {
33 if (!.RevokeSecurityGroupEgressResponse.return[true]) {
34 error("Return: ",.RevokeSecurityGroupEgressResponse.return,"\n");
35 exit(1);
36 }
27} 37}
28 38
diff --git a/src/sg-cl.opt b/src/sg-cl.opt
index 6b223b2..a54192a 100644
--- a/src/sg-cl.opt
+++ b/src/sg-cl.opt
@@ -14,20 +14,48 @@
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License
15 along with Eclat. If not, see <http://www.gnu.org/licenses/>. */ 15 along with Eclat. If not, see <http://www.gnu.org/licenses/>. */
16 16
17#define DIR_INGRESS 0
18#define DIR_EGRESS 1
19
20static char const *authorize_comtab[] = {
21 "AuthorizeSecurityGroupIngress",
22 "AuthorizeSecurityGroupEgress"
23};
24static char const *revoke_comtab[] = {
25 "RevokeSecurityGroupIngress",
26 "RevokeSecurityGroupEgress"
27};
28static int direction = DIR_INGRESS;
29
17ECLAT_CL_BEGIN([<modify ingress rules of a security group>], 30ECLAT_CL_BEGIN([<modify ingress rules of a security group>],
18 [<[GROUPARG]>]) 31 [<[GROUPARG]>])
19 32
33GROUP(Direction)
34OPTION(input,I,,
35 [<input (ingress)>])
36ALIAS(ingress)
37BEGIN
38 direction = DIR_INGRESS;
39END
40
41OPTION(output,O,,
42 [<output (egress)>])
43ALIAS(egress)
44BEGIN
45 direction = DIR_EGRESS;
46END
47
20GROUP(Commands) 48GROUP(Commands)
21OPTION(add,A,, 49OPTION(add,A,,
22 [<add rules>]) 50 [<add rules>])
23BEGIN 51BEGIN
24 command = "AuthorizeSecurityGroupIngress"; 52 command = authorize_comtab[direction];
25END 53END
26 54
27OPTION(delete,D,, 55OPTION(delete,D,,
28 [<delete rules>]) 56 [<delete rules>])
29BEGIN 57BEGIN
30 command = "RevokeSecurityGroupIngress"; 58 command = revoke_comtab[direction];
31END 59END
32 60
33OPTION(list,L,, 61OPTION(list,L,,
diff --git a/src/sg.c b/src/sg.c
index a1842c3..4ae0b60 100644
--- a/src/sg.c
+++ b/src/sg.c
@@ -26,7 +26,7 @@ struct groupkw groupkw[] = {
26}; 26};
27 27
28static struct ec2_request *request; 28static struct ec2_request *request;
29static char *command; 29static char const *command;
30static int list_option; 30static int list_option;
31static int dest_n = GROUP_ID; 31static int dest_n = GROUP_ID;
32static char *proto = "tcp"; 32static char *proto = "tcp";

Return to:

Send suggestions and report system problems to the System administrator.