# htpasswd standalone package?

## captwiggum

I need only htpasswd and nothing more. I'm trying to avoid emerging all of apache and dependencies just to get this one utility. Is there any smaller package where this can be found? I searched portage and things like thttpd and mini_httpd just reference it, but don't include it. Any tips appreciated. Thanks.

----------

## GoofballJM1

Are you going to access these directories via a web interface?  If you are, you do need some sort of webserver to computer http requests.  htacess is part of apache.  htaccess files are for securing web directories.  If you don't want to load a full-blown webserver, perhaps  lighttpd might work for you.  It's not nearly as big as apache.  Good luck.

----------

## captwiggum

Thanks for the reply. To answer the question, I do not need a web server. I didn't want to complicate the question with the end use of htpasswd. This utility is used by many applications for generating access files, including certain ftp and email servers, and many company's proprietary apps. At issue here is the fact that most of these applications expect you to already have a binary of htpasswd.

So to that end, I'm trying to find a small ebuild that contains only htpasswd, or in lieu of that, a very small application that includes a copy.

Any help appreciated.

----------

## captwiggum

I've found a very nice and easy solution. This is a tiny 30 line perl script that is a replacement for htpasswd. Just cut-n-paste this to a file in your path as htpasswd.pl  and execute as "perl htpasswd.pl" 

This was taken from:

http://www.intuitive.com/wicked/examples/htpasswd-b.html

Here is a local copy in case the original site disappears:

---------------------------------------------------------------------------------------------

#!/usr/bin/perl

if (! scalar @ARGV ) {

  print "Usage: htpasswd.pl passwordfile user password\n";

  print "(this program automatically creates the pw file if needed.)\n";

  exit 0;

}

@saltsource = ('a'..'z', 'A'..'Z', '0'..'9','.','/');

$randum_num = int(rand(scalar @saltsource));

$salt = $saltsource[$randum_num];

$randum_num = int(rand(scalar @saltsource));

$salt .= $saltsource[$randum_num];

$outf=$ARGV[0];

$user=$ARGV[1];

$passwd=$ARGV[2];

if ($user && $passwd) {

  $encrypted = crypt($passwd, "$salt");

  if (-f $outf) {

    open(OUT, ">>$outf") || die "htpasswd-b error: $!\n";

  } else {

    open(OUT, ">$outf") || die "htpasswd-b error: $!\n";

  }

  print OUT "$user:$encrypted\n";

  close(OUT);

  exit 0;

}

---------------------------------------------------------------------------------------------

----------

## GoofballJM1

Very cool.  Thanks for the info!  :Laughing: 

----------

