Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

ph (cso nameserver) Frequently Asked Questions (FAQ)
Section - 1.7 How to I give everyone passwords?

( Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Sex offenders ]


Top Document: ph (cso nameserver) Frequently Asked Questions (FAQ)
Previous Document: 1.6 How can I register my CSO server?
Next Document: Section 2: Common problems / error messages
See reader questions & answers on this topic! - Help others by sharing your knowledge
(contributed by Brian T. Shelden)

Password is just a field in the database, like any other. So, in your
tab-separated input file (see question 1.3) just add values for the
Password field in your .cnf file.  (Usually 7.)

Here's how I give everyone randomly generated passwords for the Directory
of Legal Academia <gopher://gopher.law.cornell.edu/11/csodir/>. 

% mdump all > output.qi
% qi2readable output.qi | givepw | readable2qi > input.qi

Now remake the database with input.qi.  Below are the scripts qi2readable,
givepw, and readable2qi.  (Yes, it could be done in one script, but
qi2readable and and readable2qi are useful for other things, too.)


==================== qi2readable ==================== (cut here)
#! /usr/local/bin/perl

while (<>) {
        chop;
        @a = split(/\t/);
        foreach $a (@a) {
                print "$a\n" if $a !~ /^\s*$/;
        }
        print "--------------------\n";
}

==================== readable2qi ==================== (cut here)
#! /usr/local/bin/perl

while (<>) {
        if (/^[-]+$/) {
                print "\t\n";
        }
        elsif (/\S+/) {
                chop;
                print $_, "\t";
        }
}

==================== givepw ==================== (cut here)
#! /usr/local/bin/perl -w

$pwnum = 7;

srand($$|time);

$hadapw = 0;
while (<>) {
        if (/^[\-]+$/) {
                if (! $hadapw) {
                        $ascii_passwd = &pw_generate;
                        print "${pwnum}:$ascii_passwd\n";
                }
                $hadapw = 0;
        }
        elsif (/^${pwnum}:/) {
                $hadapw = 1;
        }
        print;
}

#------------------------------------------------------------------------------
# Generate funky random password:
#------------------------------------------------------------------------------
sub pw_generate {
        local(@passset, $rnd_passwd, $randum_num);
        local($randum_num);
        
        @passset = ('a'..'k', 'm'..'z', 'A'..'N', 'P'..'Z', '2'..'9');
        $rnd_passwd = "";
        for ($i = 0; $i < 8; $i++) {
                $randum_num = int(rand($#passset + 1));
                $rnd_passwd .= @passset[$randum_num];
        }

        return $rnd_passwd;
}


User Contributions:

Comment about this article, ask questions, or add new information about this topic:




Top Document: ph (cso nameserver) Frequently Asked Questions (FAQ)
Previous Document: 1.6 How can I register my CSO server?
Next Document: Section 2: Common problems / error messages

Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
noel@camelcity.com (PH FAQ Coordinators)





Last Update March 27 2014 @ 02:12 PM