Allow default attributes to be set via config and cmdline

This commit changes the default attribute list from a fixed '*'
to a configurable list, defaulting to ['*'].

It allows one to use config file or command line to set default
attributes to retrieve and display - i.e. to set default attributes
to '+' or to a list of multiple specific attributes.

Printing or changing this value through env/setenv is currently not
supported because env/setenv only work properly with string values
while attributes is a list.

FossilOrigin-Name: 8c312e181611c61d43a588d2aa2c6e3d231db490c29f40aee861a0e1832039fc
This commit is contained in:
docelic@crystallabs.io 2019-04-28 19:40:06 +00:00
parent 9949c492ce
commit da79de2320

View file

@ -1437,7 +1437,7 @@ sub run_cat
{ {
my $self = shift; my $self = shift;
my $dn = shift; my $dn = shift;
my @attrs = (@_) ? @_ : ('*'); my @attrs = (@_) ? @_ : @{$conf->{'attributes'}};
$self->display( $dn, \@attrs, 0 ); $self->display( $dn, \@attrs, 0 );
} }
@ -2381,6 +2381,7 @@ Getopt::Long::GetOptions(
'binddn|D=s', 'binddn|D=s',
'basedn|b=s', 'basedn|b=s',
'cacheage=i', 'cacheage=i',
'attributes=s@',
'paginate=i', 'paginate=i',
'promptpass|W', 'promptpass|W',
'timeout=i', 'timeout=i',
@ -2413,8 +2414,9 @@ if ( $conf->{'configfile'} ) {
# defaults # defaults
$conf->{'configfile'} ||= "$ENV{'HOME'}/.shelldap.rc"; $conf->{'configfile'} ||= "$ENV{'HOME'}/.shelldap.rc";
$conf->{'cacheage'} ||= 300; $conf->{'cacheage'} ||= 300;
$conf->{'timeout'} ||= 10; $conf->{'timeout'} ||= 10;
$conf->{'attributes'} ||= ['*'];
# create and enter shell loop # create and enter shell loop
my $shell = LDAP::Shell->new(); my $shell = LDAP::Shell->new();