Work on iscsi authentication

This commit is contained in:
Jamie Cameron
2012-11-06 17:58:11 -08:00
parent 660c50d393
commit 472aa23429
8 changed files with 70 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -1,4 +1,5 @@
targets_file=/etc/iscsi/targets
auths_file=/etc/iscsi/auths
iscsi_server=/usr/sbin/iscsi-target
pid_file=/var/run/iscsi-target.pid
init_name=netbsd-iscsi

View File

@ -1,4 +1,5 @@
targets_file=/usr/local/etc/iscsi/targets
auths_file=/usr/local/etc/iscsi/auths
iscsi_server=/usr/local/bin/iscsi-target
pid_file=/var/run/iscsi-target.pid
init_name=iscsi_target

View File

@ -1,4 +1,5 @@
targets_file=iSCSI server targets file,0
auths_file=iSCSI server authentication file,0
iscsi_server=Full path to iSCSI server,0
pid_file=Full path to PID file,0
init_name=Bootup script name,0

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 B

View File

@ -474,5 +474,31 @@ foreach my $o (keys %$opts) {
&save_iscsi_options_string(join(" ", @str));
}
# list_iscsi_users()
# Parses the auths file and returns an array of users
sub list_iscsi_users
{
my @rv;
my $fh = "AUTHS";
my $lnum = 0;
&open_readfile($fh, $config{'auths_file'}) || return ( );
while(<$fh>) {
s/\r|\n//;
s/\s+$//;
my ($user, $mode, $pass, @rest) = split(/:/, $_);
if ($user) {
my $uinfo = { 'user' => $user,
'mode' => $mode,
'pass' => $pass,
'rest' => \@rest,
'line' => $lnum };
push(@rv, $uinfo);
}
$lnum++;
}
close($fh);
return @rv;
}
1;

View File

@ -138,6 +138,10 @@ manual_desc=Use the text box below to edit the iSCSI server configuration file $
manual_err=Failed to save configuration file
manual_edata=No contents entered!
users_title=iSCSI Authentication
users_none=No iSCSI users have been created yet. Clients will be able to access shared devices without authenticating.
users_add=Add a new iSCSI user.
desc_extent=Device to share $1
desc_device=Device combination $1
desc_target=Sharing target $1

View File

@ -0,0 +1,37 @@
#!/usr/local/bin/perl
# List all iscsi users
use strict;
use warnings;
require './iscsi-server-lib.pl';
our (%text);
my @users = &list_iscsi_users();
&ui_print_header(undef, $text{'users_title'}, "");
my @links = ( "<a href='edit_user.cgi?new=1'>$text{'users_add'}</a>" );
if (@users) {
unshift(@links, &select_all_link("d"), &select_invert_link("d"));
print &ui_form_start("delete_devices.cgi");
print &ui_links_row(\@links);
my @tds = ( "width=5" );
print &ui_columns_start([ undef,
$text{'users_name'},
$text{'users_mode'} ], 100, 0, \@tds);
foreach my $e (@users) {
print &ui_checked_columns_row([
"<a href='edit_user.cgi?user=$e->{'user'}'>".
&html_escape($e->{'user'})."</a>",
uc($e->{'mode'}),
], \@tds, "d", $e->{'user'});
}
print &ui_columns_end();
print &ui_links_row(\@links);
print &ui_form_end([ [ undef, $text{'users_delete'} ] ]);
}
else {
print "<b>$text{'users_none'}</b><p>\n";
print &ui_links_row(\@links);
}
&ui_print_footer("", $text{'index_return'});