]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - src/misc-progs/sshctrl.c
misc-progs: sshctrl: Sanitise runtime for "tempstart"
[ipfire-2.x.git] / src / misc-progs / sshctrl.c
index 30074973daa9dd768b6bd958b62e69db0ad2d432..0d458a865e9723f27cf45cfb56d6ce4e4dd219f6 100644 (file)
@@ -67,14 +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/;"   "s/^PermitOpen .*$/PermitOpen any/;", STRING_SIZE - 1 );
                                else
-                                               strlcat(command, "s/^AllowTcpForwarding .*$/AllowTcpForwarding no/;", STRING_SIZE - 1 );
-                                               
+                                               strlcat(command, "s/^AllowTcpForwarding .*$/AllowTcpForwarding no/;"    "s/^PermitOpen .*$/PermitOpen none/;", STRING_SIZE - 1 );
+
                                if(findkey(kv, "SSH_PORT", buffer) && !strcmp(buffer,"on"))
-                                               strlcat(command, "s/^Port .*$/Port 22/", STRING_SIZE - 1 );
+                                               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/^Port .*$/Port 222/", STRING_SIZE - 1 );
+                                               strlcat(command, "s/^AllowAgentForwarding .*$/AllowAgentForwarding no/;", STRING_SIZE - 1 );
 
                                freekeyvalues(kv);
 
@@ -128,6 +133,11 @@ int main(int argc, char *argv[])
                                return 0;
        }
        else if (strcmp(argv[1], "tempstart") == 0) {
+               if (!is_valid_argument_num(argv[2])) {
+                       fprintf(stderr, "Invalid time '%s'\n", argv[2]);
+                       exit(2);
+               }
+
                                safe_system("/usr/local/bin/sshctrl");
                                sleep(5);
                                unlink("/var/ipfire/remote/enablessh");