software:dovecot:archiveserver
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| software:dovecot:archiveserver [2023/09/25 14:42] – rodolico | software:dovecot:archiveserver [2023/09/25 15:19] (current) – rodolico | ||
|---|---|---|---|
| Line 119: | Line 119: | ||
| which would give us greater security. | which would give us greater security. | ||
| + | |||
| + | If you want, here is a little utility written in Perl that will do all of it for you. It takes a username and a password, then either updates or adds that information to the password file. It is NOT very friendly, and could use some cleanup, and the username/ | ||
| + | |||
| + | <code perl updatePasswd> | ||
| + | #! / | ||
| + | |||
| + | # WARNING: This is insecure as it will leave the users password in the | ||
| + | # bash history file | ||
| + | |||
| + | use strict; | ||
| + | use warnings; | ||
| + | |||
| + | my $pwfile = '/ | ||
| + | my $user = shift; | ||
| + | my $password = shift; | ||
| + | |||
| + | die " | ||
| + | |||
| + | my $found = 0; # determines if user already exists | ||
| + | |||
| + | # call doveadm to get the hash | ||
| + | my $key = `/ | ||
| + | |||
| + | # read the password file | ||
| + | open PW,"< | ||
| + | my @data = <PW>; | ||
| + | close PW; | ||
| + | |||
| + | # go through it and see if the user already exists | ||
| + | my $newLine = " | ||
| + | for ( my $line = 0; $line < @data; $line++ ) { | ||
| + | my ($thisUser, | ||
| + | if ( $thisUser eq $user ) { # yes, so replace the line and mark found | ||
| + | $data[$line] = $newLine; | ||
| + | $found = 1; | ||
| + | last; | ||
| + | } # if statement | ||
| + | } # for loop | ||
| + | push @data, $newLine unless $found; # we did not find them, so add | ||
| + | chomp @data; # remove all line endings | ||
| + | |||
| + | # write the file back out | ||
| + | open PW,"> | ||
| + | print PW join( " | ||
| + | close PW; | ||
| + | |||
| + | # tell user what we did | ||
| + | print "User $user "; | ||
| + | print $found ? " | ||
| + | |||
| + | 1; | ||
| + | </ | ||
| + | |||
| + | |||
| ===== Setting up mail client ===== | ===== Setting up mail client ===== | ||
software/dovecot/archiveserver.1695670927.txt.gz · Last modified: 2023/09/25 14:42 by rodolico
