HEX
Server: Apache
System: Linux vps-cdc32557.vps.ovh.ca 5.15.0-156-generic #166-Ubuntu SMP Sat Aug 9 00:02:46 UTC 2025 x86_64
User: hanode (1017)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //usr/share/usermin/ssh/save_auth.cgi
#!/usr/bin/perl
# save_auth.cgi
# Save, create or delete an authorized key

require './ssh-lib.pl';
&ReadParse();
@auths = &list_auths();
if ($in{'new'}) {
	$auth = { 'type' => $in{'type'} };
	}
else {
	$auth = $auths[$in{'idx'}];
	}

if ($in{'delete'}) {
	# Just delete this authorized key
	&delete_auth($auth);
	}
else {
	# Validate inputs
	&error_setup($text{'auth_err'});
	$in{'name'} =~ /^\S+$/ || &error($text{'auth_ename'});
	$auth->{'name'} = $in{'name'};
	if ($auth->{'type'} == 1) {
		$in{'bits'} =~ /^\d+$/ || &error($text{'auth_ebits'});
		$auth->{'bits'} = $in{'bits'};
		$in{'exp'} =~ /^\d+$/ || &error($text{'auth_eexp'});
		$auth->{'exp'} = $in{'exp'};
		}
	else {
		$auth->{'keytype'} = $in{'keytype'};
		}
	$in{'key'} =~ s/\s//g;
	if ($auth->{'type'} == 1) {
		$in{'key'} =~ /^\d+$/ || &error($text{'auth_ekey'});
		}
	else {
		$in{'key'} =~ /^[a-z0-9\+\/=]+$/i || &error($text{'auth_ekey2'});
		}
	$auth->{'key'} = $in{'key'};

	# Validate option inputs
	&parse_options($auth->{'opts'}, \%opts);
	if ($in{'from_def'}) {
		delete($opts{'from'});
		}
	else {
		$opts{'from'} = [ join(",", split(/\s+/, $in{'from'})) ];
		}
	if ($in{'command'}) {
		$opts{'command'} = [ $in{'command'} ];
		}
	else {
		delete($opts{'command'});
		}
	if ($in{'noport'}) { $opts{'no-port-forwarding'} = [ undef ]; }
	else { delete($opts{'no-port-forwarding'}); }
	if ($in{'nox11'}) { $opts{'no-x11-forwarding'} = [ undef ]; }
	else { delete($opts{'no-x11-forwarding'}); }
	if ($in{'noagent'}) { $opts{'no-agent-forwarding'} = [ undef ]; }
	else { delete($opts{'no-agent-forwarding'}); }
	if ($in{'nopty'}) { $opts{'no-pty'} = [ undef ]; }
	else { delete($opts{'no-pty'}); }
	$auth->{'opts'} = &join_options(\%opts);

	# Create or save the authorized key
	if ($in{'new'}) {
		&create_auth($auth);
		}
	else {
		&modify_auth($auth);
		}
	}
&redirect("list_auths.cgi");