steffen: server/kolabd/kolabd kolab_bootstrap, 1.15, 1.15.2.1 kolabpasswd, 1.7, 1.7.2.1
cvs at intevation.de
cvs at intevation.de
Sun Oct 2 13:07:15 CEST 2005
Author: steffen
Update of /kolabrepository/server/kolabd/kolabd
In directory doto:/tmp/cvs-serv11633/kolabd
Modified Files:
Tag: kolab_2_0_branch
kolab_bootstrap kolabpasswd
Log Message:
Backport of: Fix for issue919 (non-escaped shell metachars in passwd)
Index: kolab_bootstrap
===================================================================
RCS file: /kolabrepository/server/kolabd/kolabd/Attic/kolab_bootstrap,v
retrieving revision 1.15
retrieving revision 1.15.2.1
diff -u -d -r1.15 -r1.15.2.1
--- kolab_bootstrap 17 Jun 2005 18:02:59 -0000 1.15
+++ kolab_bootstrap 2 Oct 2005 11:07:13 -0000 1.15.2.1
@@ -33,6 +33,19 @@
##### Utility Functions
+# Shell double-quote a string
+# Borrored from Sysadm::Install
+sub qquote {
+ my($str, $metas) = @_;
+ $str =~ s/([\\"])/\\$1/g;
+ if(defined $metas) {
+ $metas = '!$`' if $metas eq ":shell";
+ $metas =~ s/\]/\\]/g;
+ $str =~ s/([$metas])/\\$1/g;
+ }
+ return "\"$str\"";
+}
+
# Try to get fqdn
sub myhostname {
my $host = '';
@@ -84,7 +97,7 @@
# Hash a password
sub hashPassword {
my $pw = shift;
- my $hashcmd = $kolab_prefix."/sbin/slappasswd -s '".$pw."'";
+ my $hashcmd = $kolab_prefix."/sbin/slappasswd -s ".qquote($pw,":shell");
(my $hashpw = `$hashcmd`) or die $@;
chomp($hashpw);
return $hashpw;
Index: kolabpasswd
===================================================================
RCS file: /kolabrepository/server/kolabd/kolabd/Attic/kolabpasswd,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -u -d -r1.7 -r1.7.2.1
--- kolabpasswd 18 Apr 2005 20:46:44 -0000 1.7
+++ kolabpasswd 2 Oct 2005 11:07:13 -0000 1.7.2.1
@@ -34,10 +34,23 @@
my $kolab_prefix = (getpwnam('kolab'))[7] || die "Error: could not determine the kolab directory prefix (e.g. /kolab)";
+# Shell double-quote a string
+# Borrored from Sysadm::Install
+sub qquote {
+ my($str, $metas) = @_;
+ $str =~ s/([\\"])/\\$1/g;
+ if(defined $metas) {
+ $metas = '!$`' if $metas eq ":shell";
+ $metas =~ s/\]/\\]/g;
+ $str =~ s/([$metas])/\\$1/g;
+ }
+ return "\"$str\"";
+}
+
# Hash a password
sub hashPassword {
my $pw = shift;
- my $hashcmd = $kolab_prefix."/sbin/slappasswd -s '".$pw."'";
+ my $hashcmd = $kolab_prefix."/sbin/slappasswd -s ".qquote($pw,":shell");
(my $hashpw = `$hashcmd`) or die $@;
chomp($hashpw);
return $hashpw;
More information about the commits
mailing list