Schema file editing and viewing

This commit is contained in:
Jamie Cameron
2007-12-13 01:39:24 +00:00
parent f4d9539507
commit ef9f77d306
6 changed files with 75 additions and 2 deletions

View File

@@ -16,7 +16,7 @@ foreach $i (&find_value("include", $conf)) {
# Show a table of all known schema files, with checkboxes
print $text{'schema_pagedesc'},"<p>\n";
@tds = ( "width=5", undef, undef, "width=10%", "width=5%" );
@tds = ( "width=5", "width=20%", "width=65%", "width=10%", "width=5% nowrap" );
print &ui_form_start("save_schema.cgi", "post");
print &ui_columns_start([ "",
$text{'schema_file'},

View File

@@ -0,0 +1,30 @@
#!/usr/local/bin/perl
# Show a schema file for editing
require './ldap-server-lib.pl';
&local_ldap_server() == 1 || &error($text{'slapd_elocal'});
&ReadParse();
&is_under_directory($config{'schema_dir'}, $in{'file'}) ||
&error($text{'schema_edir'});
&ui_print_header(undef, $text{'schema_etitle'}, "");
print $text{'schema_edesc'},"<p>\n";
print &ui_form_start("save_sfile.cgi", "form-data");
print &ui_hidden("file", $in{'file'});
print &ui_table_start($text{'schema_eheader'}, undef, 2, [ "width=30%" ]);
# Filename
print &ui_table_row($text{'schema_path'},
"<tt>".&html_escape($in{'file'})."</tt>");
# Contents
print &ui_table_row(undef,
&ui_textarea("data", &read_file_contents($in{'file'}), 20, 80), 2);
print &ui_table_end();
print &ui_form_end([ [ undef, $text{'save'} ] ]);
&ui_print_footer("edit_schema.cgi", $text{'schema_return'});

View File

@@ -65,7 +65,7 @@ slapd_gencertdesc=To run your LDAP server in TLS mode, an SSL certificate and pr
slapd_gencertwarn=Warning - your existing certificate will no longer be used.
schema_title=Manage Schema
schema_file=Schema name
schema_file=Name
schema_desc=Description
schema_pagedesc=The LDAP schema determines which object classes and attributes can be stored in your LDAP database. This page allows you to select which schema types are supported by your server - but be careful de-selecting any entries that are used by existing objects.
schema_err=Failed to save schema
@@ -73,6 +73,12 @@ schema_move=Move
schema_act=Actions..
schema_view=View
schema_edit=Edit
schema_edir=File is not in the schema directory!
schema_etitle=Edit Schema File
schema_eheader=Schema file contents
schema_path=Full filename
schema_edesc=This page allows you to manually edit an LDAP schema file. This should only be done if you are familiar with the file format, as no checking is done by Webmin.
schema_return=schema list
acl_title=LDAP Access Control
@@ -180,6 +186,7 @@ log_apply=Applied configuration
log_slapd=Changed LDAP server configuration
log_schema=Changed enabled LDAP schemas
log_gencert=Generated new SSL certificate
log_sfile=Modified schema file $1
gencert_title=Generate SSL Certificate
gencert_header=New SSL certificate details

View File

@@ -32,6 +32,9 @@ elsif ($type eq 'attrs') {
return &text('log_'.$action.'_attrs', $object,
"<tt>".&html_escape($p->{'dn'})."</tt>");
}
elsif ($type eq 'sfile') {
return &text('log_sfile', "<tt>".&html_escape($object)."</tt>");
}
else {
return $text{'log_'.$action};
}

View File

@@ -0,0 +1,22 @@
#!/usr/local/bin/perl
# Write out a schema file
require './ldap-server-lib.pl';
&local_ldap_server() == 1 || &error($text{'slapd_elocal'});
&ReadParseMime();
# Validate
&error_setup($text{'schema_eerr'});
&is_under_directory($config{'schema_dir'}, $in{'file'}) ||
&error($text{'schema_edir'});
$in{'data'} =~ s/\r//g;
$in{'data'} =~ /\S/ || &error($text{'schema_edata'});
# Save
&open_lock_tempfile(FILE, ">$in{'file'}");
&print_tempfile(FILE, $in{'data'});
&close_tempfile(FILE);
&webmin_log("sfile", undef, $in{'file'});
&redirect("edit_schema.cgi");

View File

@@ -0,0 +1,11 @@
#!/usr/local/bin/perl
# Just output a schema file
require './ldap-server-lib.pl';
&local_ldap_server() == 1 || &error($text{'slapd_elocal'});
&ReadParse();
&is_under_directory($config{'schema_dir'}, $in{'file'}) ||
&error($text{'schema_edir'});
print "Content-type: text/plain\n\n";
print &read_file_contents($in{'file'});