Conversation
| my $ldap_base = 'ou=People,dc=example,dc=com'; | ||
|
|
||
| my $revbank_file = File::Spec->catfile(File::HomeDir->my_home, '.revbank', 'accounts'); | ||
| my $log_file = '/var/log/revbank_ldap_sync.log'; |
There was a problem hiding this comment.
RevBank normally doesn't write outside its own data directory.
| my @only_in_ldap = grep { !$revbank_hash{$_} } @ldap_users; | ||
| my @only_in_revbank = grep { !$ldap_hash{$_} } @revbank_users; | ||
|
|
||
| foreach my $user (@only_in_ldap) { |
There was a problem hiding this comment.
Plugins typically run their code in hooks, or the command sub. Maybe this is intended as a script to run from a regular shell? If so, the file should probably go in the contrib/ directory instead of plugins/.
| return @uids; | ||
| } | ||
|
|
||
| sub get_revbank_users { |
There was a problem hiding this comment.
You could use RevBank::Accounts::names() for this.
| open my $fh, '<', $file or die "Could not open revbank file: $file: $!"; | ||
| my @users; | ||
| while (<$fh>) { | ||
| next if /^\s*-/; # skip system transactions |
There was a problem hiding this comment.
System accounts currently begin with +, -, or *. You could use RevBank::Accounts::is_special() instead of a regex, so your logic always aligns with what revbank uses.
| my @users; | ||
| while (<$fh>) { | ||
| next if /^\s*-/; # skip system transactions | ||
| if (/^(\w+)\s+/) { |
There was a problem hiding this comment.
RevBank has valid user names that start with a non-\w character.
| my $line = sprintf "%-20s +0.00 %s +@%s\n", $user, $ts, $ts; | ||
|
|
||
| open my $fh, '>>', $file or die "Could not write to $file: $!"; | ||
| print $fh $line; |
There was a problem hiding this comment.
You could use RevBank::Accounts::create() for this.
If you're rolling your own implementation, consider at least supporting the global lock.
Work in progress, lots of loose ends, needs some rework.