*
* (c) Mark Wormgoor, 2001
* Simple program intended to be installed setuid(0) that can be used for
- * restarting SSHd.
- *
+ * restarting SSHd.
+ *
* $Id: sshctrl.c,v 1.3 2003/12/11 10:57:34 riddles Exp $
- *
+ *
*/
#include <stdio.h>
#define BUFFER_SIZE 1024
-char command[BUFFER_SIZE];
+char command[BUFFER_SIZE];
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 );
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 );
+ 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/^AllowAgentForwarding .*$/AllowAgentForwarding no/;", STRING_SIZE - 1 );
freekeyvalues(kv);
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");