Update documentation, now that multiline edits work. Minor other
cleanups. Bump version. FossilOrigin-Name: 94547dfd4be54043d4ec84266c5aa39fdc2f116bf034a6b923232e643abf1822
This commit is contained in:
parent
ae4fb82877
commit
dd6d12cad4
1 changed files with 29 additions and 27 deletions
50
shelldap
50
shelldap
|
|
@ -1,16 +1,18 @@
|
||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
# vim: set nosta noet ts=4 sw=4:
|
# vim: set nosta noet ts=4 sw=4:
|
||||||
#
|
#
|
||||||
# Copyright (c) 2006, Mahlon E. Smith <mahlon@martini.nu>
|
# Copyright (c) 2006-2011, Mahlon E. Smith <mahlon@martini.nu>
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted provided that the following conditions are met:
|
# modification, are permitted provided that the following conditions are met:
|
||||||
#
|
#
|
||||||
# * Redistributions of source code must retain the above copyright
|
# * Redistributions of source code must retain the above copyright
|
||||||
# notice, this list of conditions and the following disclaimer.
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
#
|
||||||
# * Redistributions in binary form must reproduce the above copyright
|
# * Redistributions in binary form must reproduce the above copyright
|
||||||
# notice, this list of conditions and the following disclaimer in the
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
# documentation and/or other materials provided with the distribution.
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
# * Neither the name of Mahlon E. Smith nor the names of his
|
# * Neither the name of Mahlon E. Smith nor the names of his
|
||||||
# contributors may be used to endorse or promote products derived
|
# contributors may be used to endorse or promote products derived
|
||||||
# from this software without specific prior written permission.
|
# from this software without specific prior written permission.
|
||||||
|
|
@ -345,13 +347,8 @@ weird, as both should probably work.
|
||||||
|
|
||||||
=head1 BUGS / LIMITATIONS
|
=head1 BUGS / LIMITATIONS
|
||||||
|
|
||||||
There is currently no attribute multiline support - attribute values
|
There is no support for editing binary data. If you need to edit base64
|
||||||
that span over one line will be ignored if modified. (Thankfully, they
|
stuff, just feed it to the regular ldapmodify/ldapadd/etc tools.
|
||||||
are generally rare.)
|
|
||||||
|
|
||||||
There is no support for editing binary data. This is actually related
|
|
||||||
to the lack of multiline support - if you just base64 encode data and
|
|
||||||
paste it in, it will be ignored for the same reasons.
|
|
||||||
|
|
||||||
=head1 AUTHOR
|
=head1 AUTHOR
|
||||||
|
|
||||||
|
|
@ -867,21 +864,27 @@ sub comp_create
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Given an $arrayref, remove LDIF continuation wrapping,
|
||||||
|
# effectively making each entry a single line.
|
||||||
|
#
|
||||||
sub unwrap {
|
sub unwrap {
|
||||||
my $array = shift;
|
my $array = shift;
|
||||||
|
|
||||||
my $iter = 1;
|
my $i = 1;
|
||||||
while ($iter < $#$array) {
|
while ( $i < scalar(@$array) ) {
|
||||||
if (@$array[$iter] =~ m/^\W/) {
|
if ( $array->[$i] =~ /^\s/ ) {
|
||||||
@$array[$iter - 1] =~ s/\n$//;
|
$array->[ $i - 1 ] =~ s/\n$//;
|
||||||
@$array[$iter] =~ s/^\W//;
|
$array->[ $i ] =~ s/^\s//;
|
||||||
splice(@$array, $iter - 1, 2, @$array[$iter - 1] . @$array[$iter]);
|
splice( @$array, $i - 1, 2, $array->[$i - 1] . $array->[$i] );
|
||||||
} else {
|
}
|
||||||
$iter++;
|
else {
|
||||||
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
###############################################################
|
###############################################################
|
||||||
#
|
#
|
||||||
# SHELL METHODS
|
# SHELL METHODS
|
||||||
|
|
@ -1158,12 +1161,12 @@ sub run_delete
|
||||||
print "No dn specified.\n";
|
print "No dn specified.\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $filter;
|
my $filter;
|
||||||
unless ( $DNs[0] eq '*' ) {
|
unless ( $DNs[0] eq '*' ) {
|
||||||
$filter = $self->make_filter( \@DNs ) or return;
|
$filter = $self->make_filter( \@DNs ) or return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
my $s = $self->search({ scope => 'one', filter => $filter });
|
my $s = $self->search({ scope => 'one', filter => $filter });
|
||||||
if ( $s->{'code'} ) {
|
if ( $s->{'code'} ) {
|
||||||
print "$s->{'message'}\n";
|
print "$s->{'message'}\n";
|
||||||
|
|
@ -1212,9 +1215,8 @@ sub run_edit
|
||||||
$ldif->done(); # force sync
|
$ldif->done(); # force sync
|
||||||
|
|
||||||
# load it into an array for potential comparison
|
# load it into an array for potential comparison
|
||||||
my @orig_ldif;
|
|
||||||
open LDIF, "$self->{'ldif_fname'}" or return;
|
open LDIF, "$self->{'ldif_fname'}" or return;
|
||||||
@orig_ldif = <LDIF>;
|
my @orig_ldif = <LDIF>;
|
||||||
close LDIF;
|
close LDIF;
|
||||||
|
|
||||||
# checksum it, then open it in an editor
|
# checksum it, then open it in an editor
|
||||||
|
|
@ -1239,9 +1241,8 @@ sub run_edit
|
||||||
}
|
}
|
||||||
|
|
||||||
# load changes into a new array for comparison
|
# load changes into a new array for comparison
|
||||||
my @new_ldif;
|
|
||||||
open LDIF, "$self->{'ldif_fname'}" or return;
|
open LDIF, "$self->{'ldif_fname'}" or return;
|
||||||
@new_ldif = <LDIF>;
|
my @new_ldif = <LDIF>;
|
||||||
close LDIF;
|
close LDIF;
|
||||||
|
|
||||||
$e->changetype('modify');
|
$e->changetype('modify');
|
||||||
|
|
@ -1250,12 +1251,13 @@ sub run_edit
|
||||||
my $line = shift || $_;
|
my $line = shift || $_;
|
||||||
return if $line =~ /^\#/; # ignore comments
|
return if $line =~ /^\#/; # ignore comments
|
||||||
my ( $attr, $val ) = ( $1, $2 ) if $line =~ /^(.+?): (.*)$/;
|
my ( $attr, $val ) = ( $1, $2 ) if $line =~ /^(.+?): (.*)$/;
|
||||||
|
return unless $attr;
|
||||||
return if index($attr, ':') != -1; # ignore base64
|
return if index($attr, ':') != -1; # ignore base64
|
||||||
return ( $attr, $val );
|
return ( $attr, $val );
|
||||||
};
|
};
|
||||||
|
|
||||||
unwrap(\@orig_ldif);
|
unwrap( \@orig_ldif );
|
||||||
unwrap(\@new_ldif);
|
unwrap( \@new_ldif );
|
||||||
|
|
||||||
my $diff = Algorithm::Diff->new( \@orig_ldif, \@new_ldif );
|
my $diff = Algorithm::Diff->new( \@orig_ldif, \@new_ldif );
|
||||||
HUNK:
|
HUNK:
|
||||||
|
|
@ -1662,7 +1664,7 @@ use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
$0 = 'shelldap';
|
$0 = 'shelldap';
|
||||||
my $VERSION = '0.2';
|
my $VERSION = '0.3';
|
||||||
|
|
||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
use YAML::Syck;
|
use YAML::Syck;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue