]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - src/misc-progs/sshctrl.c
change AllowAgentForwarding in SSHD configuration if, necessary
[ipfire-2.x.git] / src / misc-progs / sshctrl.c
index d0799730f3d29887e52a5202a93ce21f9cea4dee..476dbc9d5481991e99e19c3612a95fcc75c66d35 100644 (file)
@@ -54,10 +54,7 @@ int main(int argc, char *argv[])
                                                exit(1);
                                }
 
-                               if(findkey(kv, "ENABLE_SSH_PROTOCOL1", buffer) && !strcmp(buffer,"on"))
-                                               strlcat(command, "s/^Protocol .*$/Protocol 2,1/;", STRING_SIZE - 1 );
-                               else
-                                               strlcat(command, "s/^Protocol .*$/Protocol 2/;", STRING_SIZE - 1 );
+                               strlcat(command, "s/^Protocol .*$/Protocol 2/;", STRING_SIZE - 1 );
 
                                if(findkey(kv, "ENABLE_SSH_KEYS", buffer) && !strcmp(buffer,"off"))
                                                strlcat(command, "s/^RSAAuthentication .*$/RSAAuthentication no/;"              "s/^PubkeyAuthentication .*$/PubkeyAuthentication no/;", STRING_SIZE - 1 );
@@ -70,9 +67,19 @@ int main(int argc, char *argv[])
                                                strlcat(command, "s/^PasswordAuthentication .*$/PasswordAuthentication yes/;", STRING_SIZE - 1 );
 
                                if(findkey(kv, "ENABLE_SSH_PORTFW", buffer) && !strcmp(buffer,"on"))
-                                               strlcat(command, "s/^AllowTcpForwarding .*$/AllowTcpForwarding yes/", STRING_SIZE - 1 );
+                                               strlcat(command, "s/^AllowTcpForwarding .*$/AllowTcpForwarding yes/;", STRING_SIZE - 1 );
+                               else
+                                               strlcat(command, "s/^AllowTcpForwarding .*$/AllowTcpForwarding no/;", STRING_SIZE - 1 );
+                                               
+                               if(findkey(kv, "SSH_PORT", buffer) && !strcmp(buffer,"on"))
+                                               strlcat(command, "s/^Port .*$/Port 22/", STRING_SIZE - 1 );
+                               else
+                                               strlcat(command, "s/^Port .*$/Port 222/", STRING_SIZE - 1 );
+
+                               if(findkey(kv, "SSH_AGENT_FORWARDING", buffer) && !strcmp(buffer,"on"))
+                                               strlcat(command, "s/^AllowAgentForwarding .*$/AllowAgentForwarding yes/;", STRING_SIZE - 1 );
                                else
-                                               strlcat(command, "s/^AllowTcpForwarding .*$/AllowTcpForwarding no/", STRING_SIZE - 1 );
+                                               strlcat(command, "s/^AllowAgentForwarding .*$/AllowAgentForwarding no/;", STRING_SIZE - 1 );
 
                                freekeyvalues(kv);
 
@@ -130,6 +137,7 @@ int main(int argc, char *argv[])
                                sleep(5);
                                unlink("/var/ipfire/remote/enablessh");
                                safe_system("cat /var/ipfire/remote/settings | sed 's/ENABLE_SSH=on/ENABLE_SSH=off/' > /var/ipfire/remote/settings2 && mv /var/ipfire/remote/settings2 /var/ipfire/remote/settings");
+        safe_system("chown nobody.nobody /var/ipfire/remote/settings");
                                snprintf(command, BUFFER_SIZE-1, "sleep %s && /usr/local/bin/sshctrl &", argv[2]);
                                safe_system(command);
        }