[vhffs-dev] [693] Added --clear-pass option to allow password stripping. |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 693
Author: beuss
Date: 2007-07-08 17:14:13 +0000 (Sun, 08 Jul 2007)
Log Message:
-----------
Added --clear-pass option to allow password stripping.
Modified Paths:
--------------
trunk/vhffs-backend/src/mirror/nss-mirror.pl
Modified: trunk/vhffs-backend/src/mirror/nss-mirror.pl
===================================================================
--- trunk/vhffs-backend/src/mirror/nss-mirror.pl 2007-07-08 14:08:39 UTC (rev 692)
+++ trunk/vhffs-backend/src/mirror/nss-mirror.pl 2007-07-08 17:14:13 UTC (rev 693)
@@ -45,20 +45,25 @@
my $shell;
my $homedir;
my $showhelp;
+my $clearpass;
sub usage() {
print <<EOF;
-nss-mirror.pl: Replicates users information for libnss-sqlite\n
- --help this help\n
- --force-shell shell_path force 'shell' field value to shell_path\n
- --force-homedir home_path tforce 'homedir' field value to home_path\n
+
+nss-mirror.pl: Replicates users information for libnss-sqlite
+ --help this help
+ --force-shell shell_path force 'shell' field value to shell_path
+ --force-homedir home_path force 'homedir' field value to home_path
+ --clear-pass all passwords will be set to 'x'
+
EOF
exit(0);
}
if(!GetOptions( 'force-homedir=s' => \$homedir,
- 'force-shell=s' => \$shell,
- 'help' => \$showhelp
+ 'force-shell=s' => \$shell,
+ 'help' => \$showhelp,
+ 'clear-pass' => \$clearpass
)) {
exit(-1);
}
@@ -89,10 +94,9 @@
$st_dbh->do(q{CREATE TEMP TABLE tmp_user_group(uid INTEGER, gid INTEGER, CONSTRAINT pk_user_groups PRIMARY KEY(uid, gid))})
or die("Unable to create temporary user_group table\n");
-my $select = q{SELECT u.uid, u.gid, u.username, u.passwd %s %s FROM vhffs_users u INNER JOIN vhffs_object o ON o.object_id = u.object_id WHERE o.state = 6};
-
-my $ssth = $pg_dbh->prepare(sprintf( $select, ($homedir ? '' : ', u.homedir'), ($shell ? '' : ', u.shell') ))
+my $select = q{SELECT u.uid, u.gid, u.username %s %s %s FROM vhffs_users u INNER JOIN vhffs_object o ON o.object_id = u.object_id WHERE o.state = 6};
+my $ssth = $pg_dbh->prepare(sprintf( $select, ($clearpass ? '' : ', u.passwd'), ($homedir ? '' : ', u.homedir'), ($shell ? '' : ', u.shell') ))
or die("Unable to prepare users SELECT statement\n");
my $sth = $st_dbh->prepare(q{INSERT INTO tmp_shadow(uid, gid, username, passwd, shell, homedir) VALUES(?, ?, ?, ?, ?, ?)})
or die("Unable to prepare shadow insert statement\n");;
@@ -100,7 +104,8 @@
$ssth->execute() or die("Unable to execute users SELECT statement\n");
while(my $row = $ssth->fetchrow_hashref()) {
- $sth->execute($row->{uid}, $row->{gid}, $row->{username}, $row->{passwd},
+ $sth->execute($row->{uid}, $row->{gid}, $row->{username},
+ ($clearpass ? 'x' : $row->{passwd}),
($shell ? $shell : $row->{shell}), ($homedir ? $homedir : $row->{homedir}))
or die("Unable to insert shadow\n");
}