6.0.0-beta1
7/8/25

[#12284] Expect driver params broken when used with Composite driver
Summary Expect driver params broken when used with Composite driver
Queue Passwd
Queue Version Git master
Type Bug
State Resolved
Priority 1. Low
Owners jan (at) horde (dot) org
Requester delrio (at) mie (dot) utoronto (dot) ca
Created 05/30/2013 (4422 days ago)
Due
Updated 06/11/2013 (4410 days ago)
Assigned
Resolved 06/11/2013 (4410 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
06/11/2013 02:36:45 PM Git Commit Comment #2 Reply to this comment
Changes have been made in Git (master):

commit df11ff4cfa438b417435844b21c55babf3122fb7
Author: Jan Schneider <jan@horde.org>
Date:   Tue Jun 11 16:34:32 2013 +0200

     [jan] Don't overwrite parameters for composite sub-drivers (Bug #12284).

  passwd/docs/CHANGES           |    1 +
  passwd/lib/Factory/Driver.php |    2 +-
  passwd/package.xml            |    2 ++
  3 files changed, 4 insertions(+), 1 deletions(-)

http://git.horde.org/horde-git/-/commit/df11ff4cfa438b417435844b21c55babf3122fb7
06/11/2013 02:35:13 PM Jan Schneider Assigned to Jan Schneider
State ⇒ Resolved
Version ⇒ Git master
 
05/30/2013 01:39:30 PM delrio (at) mie (dot) utoronto (dot) ca Comment #1
Priority ⇒ 1. Low
Patch ⇒ No
Milestone ⇒
Queue ⇒ Passwd
Summary ⇒ Expect driver params broken when used with Composite driver
Type ⇒ Bug
State ⇒ Unconfirmed
Reply to this comment
The Expect driver works well by itself, with the following backend.local.php

  $backends['expect']['disabled'] = false;
  $backends['expect']['params']['script'] = PASSWD_BASE . 
'/scripts/passwd-expect';
  $backends['expect']['params']['params'] = '-host servername';

The successful command called by Driver/Expect.php is

LANG=C LC_ALL=C /usr/bin/expect -f 
'/horde/passwd/lib/../scripts/passwd-expect' -- -host servername -log 
'/var/tmp/passwdZ4aqha'

Now trying to use Expect with the Composite driver:

$backends['combo'] = array(
     'disabled' => false,
     'name' => 'Passwords',
     'driver' => 'Composite',
     'policy' => array(
         'minLength' => 6,
         'minNumeric' => 1,
     ),
     'params' => array('drivers' => array(
         'expect' => array(
             'name' => 'Unix Server',
             'driver' => 'Expect',
             'required' => true,
             'params' => array(
                 'program' => '/usr/bin/expect',
                 'script' => PASSWD_BASE . '/scripts/passwd-expect',
                 'params' => '-host servername',
             ),
         ),
         'samba' => array(
             'name' => 'Samba Server',
             'driver' => 'Smbpasswd',
             'params' => array(
                 'program' => '/usr/bin/smbpasswd',
                 'host' => 'sambaserver',
             ),
         ),
     )),
);

Expect fail to connect to server.  Debugging the code in 
Driver/Expect.php, the command that it is trying to execute is

LANG=C LC_ALL=C /usr/bin/expect -f 
'/horde/passwd/lib/../scripts/passwd-expect' -- Array -log 
'/var/tmp/passwdiBa4pa'

Note "Array" in the command instead of the script params "-host 
servername"  ($this->_params['params'] in the Expect.php code)

The following is a workaround for the Expect driver, but the bug might 
be somewhere in the Composite driver:

--- Driver/Expect.php.orig      Wed May 29 12:07:22 2013
+++ Driver/Expect.php   Wed May 29 14:16:33 2013
@@ -34,10 +34,12 @@
          // Temporary logfile for error messages.
          $log = Horde::getTempFile('passwd');

+        $params = is_array($this->_params['params']) ? 
$this->_params['params']['params'] : $this->_params['params'];
+
          // Open expect script for writing.
          $prog = 'LANG=C LC_ALL=C ' . $this->_params['program'] .
              ' -f ' . escapeshellarg($this->_params['script']) .
-            ' -- ' . $this->_params['params'] . ' -log ' . 
escapeshellarg($log);
+            ' -- ' . $params . ' -log ' . escapeshellarg($log);

          $exp = @popen($prog, 'w');
          @fwrite($exp, $user . "\n");

Saved Queries