This file is indexed.

/usr/share/gosa/plugins/admin/fai/migration/class_migrateFaiRDN.inc is in gosa-plugin-fai 2.7.4+reloaded1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php



class migrateFaiRDN extends migrateRDN implements propertyMigration
{
    protected $property = NULL;
    protected $config = NULL;
    protected $found = array();
    protected $filter ="";

    // Additional suffixes or prefixes 
    // e.g. for 'faiScriptRDN' (ou=scripts,) moving to new destination lets say 
    //  to 'ou=FAIscripts,' would break stuff with having 'ou=fai,ou=systems,ou=config' 
    // prepended.
    // 
    protected $suffix = ""; 
    protected $prefix = ""; 

    public $faiBaseRDN;

    function __construct($config,$property)
    {
        parent::__construct($config,$property);
    }   

    function checkForIssues()
    {
        // This is very tricky ... have to think about it. Its deactivated currently.
        $this->found = array();
        $ldap= $this->config->get_ldap_link();
        $ldap->cd($this->config->current['BASE']);
        $ldap2= $this->config->get_ldap_link();
        $ldap2->cd($this->config->current['BASE']);

        // If the userRDN wasn't empty, then only search for users inside of the old userRDN.
        $initialValue = $this->prefix.$this->property->getValue().$this->suffix;
        $targetValue = $this->prefix.$this->property->getValue(TRUE).$this->suffix;

        if(!empty($initialValue) && !preg_match("/,$/", $initialValue)) $initialValue.=",";
        if(!empty($targetValue) && !preg_match("/,$/", $targetValue)) $targetValue.=",";

        $dnMatch = "";
        if(!empty($initialValue)){
            foreach(preg_split("/,/", $initialValue) as $rdnPart){
                if(empty($rdnPart)) continue;
                list($namingAttrs, $container) = preg_split("/=/",$rdnPart,2);
                $container = trim($container,', ');
                $dnMatch.= "({$namingAttrs}:dn:={$container})";
            }
        }

        // Collect all FAI releases - this is nescessary to detect the release part
        //  of the dn
        $ldap->cd($this->config->current['BASE']);
        $releases = array();
        $ldap->search("(objectClass=FAIbranch)",array('dn'));
        while($attrs = $ldap->fetch()){
            $releases[$attrs['dn']] = $attrs['dn'];
        }

        // Add release bases 
        $faiBase = $this->config->get_cfg_value('faiManagement','faiBaseRDN').$this->config->current['BASE'];
        $releases[$faiBase] = $faiBase;
        
        // Search for users
        $filter = sprintf($this->filter,$dnMatch);
        $ldap->search($filter,array('dn'));
        $found = FALSE;
        while($attrs = $ldap->fetch()){

            // Detect release dn 
            $releaseDn  = $attrs['dn'];
            while(!isset($releases[$releaseDn]) && !isset($this->config->idepartments[$releaseDn])){
                $releaseDn = preg_replace("/^[^,]+,/","",$releaseDn);
            }
            
            // Build up the new dn
            $name = preg_replace("/^([^,]*+,).*$/","\\1",$attrs['dn']);
            $newDn = $name.$targetValue.$releaseDn;

            // Check if we've to create new sub departments 
            if(!$ldap2->dn_exists($targetValue.$releaseDn)){
                $this->found['add'][$targetValue.$releaseDn] = array();
            }

            // Queue object to be moved.
            if($newDn != $attrs['dn']){
                $this->found['move'][] = array('from' => $attrs['dn'], 'to' => $newDn);
                $found = TRUE;
            }
        }
        return($found);
    }
} 


?>